VIPIcEnergyMgrScreen.java 150 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491
  1. package kr.co.icontrols.wallpadenergyctrl.screen;
  2. import android.annotation.SuppressLint;
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.content.IntentFilter;
  7. import android.graphics.Bitmap;
  8. import android.graphics.BitmapFactory;
  9. import android.graphics.Canvas;
  10. import android.graphics.Color;
  11. import android.graphics.Matrix;
  12. import android.graphics.Paint;
  13. import android.graphics.Path;
  14. import android.os.Build;
  15. import android.os.Handler;
  16. import android.os.Message;
  17. import android.util.Log;
  18. import android.view.Gravity;
  19. import android.view.MotionEvent;
  20. import android.view.View;
  21. import android.widget.RelativeLayout;
  22. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  23. import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
  24. import com.artncore.WallPadDataMgr.WallpadStatusData;
  25. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  26. import com.artncore.commons.DataClasses;
  27. import com.artncore.commons.define;
  28. import com.artncore.wallpadapi.RealTimeMeterAPI;
  29. import com.artncore.wallpadapi.WallPadAPI;
  30. import com.artncore.wallpadimap.RetProci;
  31. import com.util.LogUtil;
  32. import java.text.SimpleDateFormat;
  33. import java.util.ArrayList;
  34. import java.util.Arrays;
  35. import java.util.Calendar;
  36. import java.util.Date;
  37. import kr.co.icontrols.wallpadenergyctrl.R;
  38. import kr.co.icontrols.wallpadenergyctrl.declare.Common;
  39. import kr.co.icontrols.wallpadenergyctrl.declare.ID;
  40. import kr.co.icontrols.wallpadenergyctrl.declare.LayoutDevice_hems;
  41. import kr.co.icontrols.wallpadenergyctrl.imap.iMAPRemotemeter;
  42. import kr.co.icontrols.wallpadsupport.WpadImageView;
  43. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  44. import kr.co.icontrols.wallpadsupport.WpadScale;
  45. import kr.co.icontrols.wallpadsupport.WpadScreen;
  46. import kr.co.icontrols.wallpadsupport.WpadSound;
  47. import kr.co.icontrols.wallpadsupport.WpadTextView;
  48. import static kr.co.icontrols.wallpadenergyctrl.declare.Common.SKIN_01;
  49. /**
  50. * Created by julia on 2018-01-08.
  51. */
  52. @SuppressLint("RtlHardcoded")
  53. public class VIPIcEnergyMgrScreen extends WpadScreen {
  54. String TAG = "VIPIcEnergyMgrScreen";
  55. private final boolean DEBUG_LOG_ON = true;
  56. private final boolean DEBUG_REALMETER_DATA_LOG_ON = false;
  57. private void DebugLogOutput(String s) {
  58. if (DEBUG_LOG_ON) Log.d(TAG, s);
  59. }
  60. //2015.03.24 Support API 변경으로 인한 폰트사이즈 재조정
  61. private final int ContentsFontSize = 16;
  62. private final int TitleFontSize = 18;
  63. // =================================================================================================
  64. // [[ Declaration ]] region
  65. // =================================================================================================
  66. // [API]
  67. private WallPadAPI m_wpapi = null;
  68. private RealTimeMeterAPI realTimeMeterAPI;
  69. // [View]
  70. WpadImageView Background;
  71. WpadImageView Background_02; //실시간 사용량
  72. WpadImageView Background_03; //그래프
  73. WpadImageView Background_04; //당월누적사용량
  74. WpadImageView Background_Title;
  75. WpadImageView Background_Title_Comment;
  76. WpadImageView m_ViewBottomMoveLeft, m_ViewBottomMoveHome, m_ViewBottomMoveRight;
  77. WpadImageView Btn_DetailView;
  78. WpadImageView Btn_Kepco, Btn_Solar, Btn_Fuel;
  79. WpadImageView m_LOGO = null;
  80. //WpadTextView Info_text;
  81. private String m_MainSkin = SKIN_01;
  82. // [공통 변수]
  83. private int OPERATION_MODE = -1;
  84. private boolean TempbSupportKind = true;
  85. private boolean APIInit = false;
  86. private boolean mCostInfo_Enable = false;
  87. // [Sample Data]
  88. //1. 전기
  89. private String[] SampleUsedData1 = new String[]{"15.1", "22.1", "33.1", "57", "76.2", "83.2", "95.6", "133.3", "212.2"};
  90. private String[] SampleUsedData2 = new String[]{"215.2", "223.2", "241.3", "260.6", "290.1", "330.3", "370.1", "400.4", "410.2"};
  91. //2. 난방 0 ~ 2.4
  92. private String[] SampleUsedData3 = new String[]{"3.1", "5.5", "14.2", "16.7", "20.2", "21.2", "22.6", "30.3", "36.2"};
  93. private String[] SampleUsedData4 = new String[]{"36.2", "44.2", "45.3", "48.6", "55.1", "56.3", "58.1", "62.4", "68.2"};
  94. //3. 온수 0 ~ 2.4
  95. private String[] SampleUsedData5 = new String[]{"5.1", "6.1", "8.1", "15.1", "18.2", "20.2", "20.6", "25.3", "28.2"};
  96. private String[] SampleUsedData6 = new String[]{"30.2", "30.3", "35.3", "36.6", "37.1", "38.3", "40.1", "46.4", "54.2"};
  97. //4. 수도 0 ~ 1.2
  98. private String[] SampleUsedData7 = new String[]{"1.1", "2.1", "5.1", "6.1", "7", "8.2", "10.6", "13.3", "13.6"};
  99. private String[] SampleUsedData8 = new String[]{"14.2", "15.2", "18.3", "20.6", "21.1", "22.3", "22.4", "26.4", "30.2"};
  100. //5. 가스 0 ~ 3.0
  101. private String[] SampleUsedData9 = new String[]{"7.1", "10.1", "20.1", "22", "23.2", "23.2", "25.6", "33.3", "35.2"};
  102. private String[] SampleUsedData10 = new String[]{"36.2", "37.2", "40.3", "41.6", "44.1", "45.3", "50.1", "55.4", "60.2"};
  103. //계기판 배경
  104. private int[] CircleGraph_bg = new int[]{
  105. R.drawable.bg_graph_power,
  106. R.drawable.bg_graph_heating,
  107. R.drawable.bg_graph_hot_water,
  108. R.drawable.bg_graph_gas,
  109. R.drawable.bg_graph_water,
  110. R.drawable.bg_graph_carbon
  111. };
  112. // [Thread]
  113. public Thread mThread_saveRealMeterData = null;
  114. private int[] setdata;
  115. private boolean RealtimeMeterUse;
  116. private int RealtimeMeterCountFromDB;
  117. // [Time]
  118. private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
  119. // [실시간 검침 관련 View 변수]
  120. WpadImageView RealTimeData_image;
  121. WpadImageView RealTimeData_bg2;
  122. WpadTextView RealTimeData; //실시간 사용량 데이터
  123. double RealTimeData_Double = 0;
  124. double EnergyMax_Double = 20;
  125. WpadTextView CalorieUnit1, CalorieUnit2; //난방 단위
  126. // WpadTextView RealtimeMeter_Marking1, RealtimeMeter_Marking2, RealtimeMeter_Marking3,
  127. // RealtimeMeter_Marking4, RealtimeMeter_Marking5, RealtimeMeter_Marking6, RealtimeMeter_Marking7;
  128. int NowShowEnergyKind = 0;
  129. private DataClasses.RealTimeMeter data = null;
  130. // [원 관련 변수]
  131. WpadImageView Energy_half_circle, CircleGraph, CircleGraph_backside;
  132. int Energy_half_circle_x = Common.ImgPosion.GetX(300);
  133. int Energy_half_circle_y = Common.ImgPosion.GetY(359);
  134. // [바늘 그리기]
  135. private float mScrewDegree = 0.0f;
  136. DrawScrew drawScrew[] = new DrawScrew[1];
  137. // [실시간 그래프 그리기]
  138. private float mGraphDegree = 0.0f;
  139. DrawGraph drawgraph[] = new DrawGraph[1];
  140. // [사용량 추이 그래프 관련 변수]
  141. WpadImageView Dot_img_Yesterday[] = new WpadImageView[9];
  142. private int ArrayDot_Yesterday[][] = new int[2][9];
  143. WpadImageView Dot_img_Today[] = new WpadImageView[9];
  144. private int ArrayDot_Today[][] = new int[2][9];
  145. // [사용량 추이 그래프 - 실시간 검침 지원하지 않을 시]
  146. WpadImageView Background_DayEnergy;
  147. WpadTextView DayMarking[] = new WpadTextView[9]; //아랫쪽 날짜
  148. WpadTextView DayEnergyMarking[] = new WpadTextView[9];
  149. private int RecentDay = 0;
  150. private boolean isStartSaveData = false;
  151. private int TotalServerInquiryCount = 0;
  152. ArrayList<DayEnergyDataClass> arrayListDayEnergyData = new ArrayList<DayEnergyDataClass>();
  153. DayEnergyDataClass realTimeEnergyData;
  154. class DayEnergyDataClass {
  155. private int Year;
  156. private int Month;
  157. private int Day;
  158. private float kepco_used;
  159. private float solar_used;
  160. private float fuel_used;
  161. public DayEnergyDataClass(int Year, int Month, int Day, float kepco_used, float solar_used, float fuel_used) {
  162. this.Year = Year;
  163. this.Month = Month;
  164. this.Day = Day;
  165. this.kepco_used = kepco_used;
  166. this.solar_used = solar_used;
  167. this.fuel_used = fuel_used;
  168. }
  169. public int getYear() {
  170. return Year;
  171. }
  172. public int getMonth() {
  173. return Month;
  174. }
  175. public int getDay() {
  176. return Day;
  177. }
  178. public float getKepco_used() {
  179. return kepco_used;
  180. }
  181. public float getSolar_used() {
  182. return solar_used;
  183. }
  184. public float getFuel_used() {
  185. return fuel_used;
  186. }
  187. }
  188. //6:전기 누적 사용량, 7:수도 누적 사용량, 8:가스 누적 사용량, 9:온수 누적 사용량, 10:열량 누적 사용량
  189. private final static int DB_ELECTRIC = 6;
  190. private final static int DB_WATER = 7;
  191. private final static int DB_GAS = 8;
  192. private final static int DB_HOTWATER = 9;
  193. private final static int DB_HEATING = 10;
  194. private final static int DB_KEPCO = 11;
  195. private final static int DB_SOLAR = 12;
  196. private final static int DB_FUEL = 13;
  197. private float UsedData_Today[] = new float[9];
  198. private float UsedData_Yesterday[] = new float[9];
  199. private float UsedData_Today_AfterCalc[] = new float[9];
  200. private float UsedData_Yesterday_AfterCalc[] = new float[9];
  201. private float UsedData_MaxData[] = new float[4];
  202. WpadTextView UsedData_MaxData_textView[] = new WpadTextView[4];
  203. WpadTextView UsedData_Unit;
  204. WpadTextView TotalUsedData_Today_textView, TotalUsedData_Yesterday_textView;
  205. DrawLine[] drawLines = new DrawLine[2];
  206. private float TotalUsedData_Today;
  207. private float TotalUsedData_Yesterday;
  208. // [당월 누적 사용량 그래프 그리기]
  209. int TempEnergyCount;
  210. DrawRect[] drawRect = new DrawRect[13];
  211. WpadTextView Kepco_HomeUse;
  212. WpadTextView Fuel_HomeUse;
  213. WpadTextView Photovoltaics_HomeUse;
  214. // [메뉴 리스트 처리 및 서브 스크린 호출]
  215. //private CallSubMenuScreen m_CallSubMenuScreen = null;
  216. // [좌표값 관련 변수]
  217. private LayoutDevice_hems getPos = new LayoutDevice_hems();
  218. public VIPIcEnergyMgrScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode) {
  219. super(context, layout);
  220. Log.d(TAG, "[START - Screen] --------------------------------------------" + Build.MODEL);
  221. //m_CallSubMenuScreen = callAPK;
  222. m_wpapi = wpapi;
  223. // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
  224. if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600))
  225. Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
  226. else Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
  227. // 1. Data Create
  228. DebugLogOutput("[Create] - Step1 : Data Create");
  229. data = new DataClasses.RealTimeMeter();
  230. TempbSupportKind = false; //true면 5종
  231. // initInfo();
  232. RegisterMainEventBr();
  233. NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.SOLAR;
  234. nowCal = Calendar.getInstance();
  235. // 2. Device API Load & Update
  236. DebugLogOutput("[Create] - Step2 : Device API Load & Update");
  237. //시간정보 저장
  238. HourCal = Calendar.getInstance();
  239. DateCal = Calendar.getInstance();
  240. MonthCal = Calendar.getInstance();
  241. YearCal = Calendar.getInstance();
  242. // 2.1 실시간 검침기 사용유무 판단
  243. // 고급주택은 실시간 검침 데이터도 단지서버로 부터 받아온다.
  244. /*
  245. WallpadDeviceSet devset = new WallpadDeviceSet(getContext());
  246. setdata = devset.Get_RealTimeMetor_Info();
  247. devset.closeDB();
  248. if (setdata[0] == 0) {
  249. // 실시간 검침 사용하지 않음
  250. RealtimeMeterUse = false;
  251. DebugLogOutput("RealtimeMeterUse = false");
  252. } else {
  253. // 실시간 검침사용함
  254. RealtimeMeterUse = true;
  255. RealtimeMeterCountFromDB = setdata[1];
  256. if (RealtimeMeterCountFromDB == 3) {
  257. TempbSupportKind = false;
  258. }
  259. DebugLogOutput("RealtimeMeterUse = true, RealtimeMeterCountFromDB + " + RealtimeMeterCountFromDB);
  260. }
  261. */
  262. RealtimeMeterUse = false;
  263. // 2.2 영업샘플 모드 판단
  264. if (Common.GetDeviceSampleMode(context) == true) {
  265. //영업샘플 모드임!
  266. //OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  267. DebugLogOutput("OPERATION_MODE = MODE_BUSINESS_SAMPLE");
  268. } else {
  269. // 정상 모드!
  270. OPERATION_MODE = Common.MODE_NOMAL;
  271. DebugLogOutput("OPERATION_MODE = MODE_NOMAL");
  272. if (RealtimeMeterUse == true) {
  273. mIntDriverCheckHandler.sendEmptyMessage(0);
  274. }
  275. }
  276. //테스트 위함
  277. TempbSupportKind = false;
  278. //OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
  279. //테스트 끝
  280. // 3. Image & Text Create
  281. DebugLogOutput("[Create] - Step3 : Image & Text Create");
  282. Background = new WpadImageView(context, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, 0, ID.RemoteMeterMainScreenID.image.BACKGROUND);
  283. ViewRegistration(layout, Background, Common.ImgPosion.GetX(0), Common.ImgPosion.GetY(110));
  284. //계기판 배경
  285. CircleGraph = new WpadImageView(context, TOUCH_KIND.NONE, 340, 170, R.drawable.bg_graph_gray_3, 0, ID.IcEnergyMgrID.image.MOMENT_GRAPH);
  286. ViewRegistration(layout, CircleGraph, Common.ImgPosion.GetX(300), Common.ImgPosion.GetY(190));
  287. drawgraph[0] = new DrawGraph(getContext(), 0);
  288. if (getLayout() != null) getLayout().addView(drawgraph[0]);
  289. //실시간 사용량 배경 + 사용량추이 그래프 배경
  290. Background_02 = new WpadImageView(context, TOUCH_KIND.NONE, 670, 576, R.drawable.box_1_2, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  291. ViewRegistration(layout, Background_02, Common.ImgPosion.GetX(49), Common.ImgPosion.GetY(135));
  292. drawScrew[0] = new DrawScrew(getContext(), mScrewDegree);
  293. if (getLayout() != null) getLayout().addView(drawScrew[0]);
  294. Energy_half_circle_x = getPos.Get(R.drawable.man_energy_half_circle_graph_focus_circle).x;
  295. Energy_half_circle_y = getPos.Get(R.drawable.man_energy_half_circle_graph_focus_circle).y;
  296. Energy_half_circle = new WpadImageView(context, TOUCH_KIND.NONE, 74, 52, R.drawable.man_energy_half_circle_graph_focus_circle, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  297. ViewRegistration(layout, Energy_half_circle, Common.ImgPosion.GetX(433), Common.ImgPosion.GetY(322));
  298. //실시간사용량
  299. RealTimeData = new WpadTextView(context, false, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).width, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).height, Gravity.CENTER, Color.WHITE, TitleFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  300. ViewRegistration(layout, RealTimeData, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).x, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).y);
  301. // 4. Draw_Update
  302. DebugLogOutput("[Create] - Step4 : Draw_Update");
  303. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  304. Sample_Start();
  305. mEMS_Enable = true;
  306. mNumberOfEnergy = 3; //수정필요
  307. } else {
  308. GetMeteringCount();
  309. }
  310. TempEnergyCount = mNumberOfEnergy;
  311. DebugLogOutput("[Create] - Step5 : mNumberOfEnergy : " + mNumberOfEnergy);
  312. if (mNumberOfEnergy == 3) {
  313. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
  314. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
  315. Btn_Kepco.setVisibility(View.GONE);
  316. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
  317. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  318. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_normal, R.drawable.btn_3_fuel_cell_pressed, ID.IcEnergyMgrID.button.FUEL);
  319. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  320. Background_04 = new WpadImageView(context, TOUCH_KIND.NONE, 499, 576, R.drawable.vip_box_3_2_metercheckdate, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  321. ViewRegistration(layout, Background_04, Common.ImgPosion.GetX(731), Common.ImgPosion.GetY(135));
  322. Kepco_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE);
  323. ViewRegistration(layout, Kepco_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(343));
  324. Kepco_HomeUse.setVisibility(View.GONE);
  325. Photovoltaics_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE);
  326. ViewRegistration(layout, Photovoltaics_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(343));
  327. Fuel_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE);
  328. ViewRegistration(layout, Fuel_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(515));
  329. }
  330. if (RealtimeMeterUse == false) {
  331. // 실시간 검침 사용하지 않음
  332. Background_DayEnergy = new WpadImageView(getContext(), TOUCH_KIND.NONE, 670, 282, R.drawable.box_2_2, 0, ID.IcEnergyMgrID.image.BACKGROUND); //그래프 변경
  333. ViewRegistration(getLayout(), Background_DayEnergy, Common.ImgPosion.GetX(49), Common.ImgPosion.GetY(429));
  334. for (int i = 0; i < 9; i++) {
  335. // 아랫쪽
  336. DayMarking[i] = new WpadTextView(context, false, getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_1, i).width,
  337. 30,
  338. Gravity.CENTER, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  339. if (i < 2) {
  340. ViewRegistration(layout, DayMarking[i], getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_1, i).x, getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_1, i).y);
  341. } else if (i == 2) {
  342. ViewRegistration(layout, DayMarking[i], getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_2, i).x, getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_2, i).y);
  343. } else {
  344. ViewRegistration(layout, DayMarking[i], getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_3, i).x, getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_3, i).y);
  345. }
  346. }
  347. for (int i = 0; i < 4; i++) {
  348. // 왼쪽 기준
  349. UsedData_MaxData_textView[i] = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_1, i).width, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_1, i).height, Gravity.RIGHT, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  350. if (i == 0) {
  351. ViewRegistration(getLayout(), UsedData_MaxData_textView[i], getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_1, i).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_1, i).y);
  352. } else {
  353. ViewRegistration(getLayout(), UsedData_MaxData_textView[i], getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).y);
  354. }
  355. UsedData_MaxData_textView[i].setText(String.valueOf(i * 4));
  356. }
  357. UsedData_Unit = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).width, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).height, Gravity.RIGHT, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  358. ViewRegistration(getLayout(), UsedData_Unit, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).y);
  359. } else {
  360. if (RealtimeMeterCountFromDB == 3) {
  361. // 실시간 검침 DB값 3종일 경우
  362. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.ELECTRIC);
  363. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
  364. Btn_Kepco.setVisibility(View.GONE);
  365. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_normal, R.drawable.btn_3_solar_e_pressed, ID.IcEnergyMgrID.button.SOLAR);
  366. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  367. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_normal, R.drawable.btn_3_fuel_cell_pressed, ID.IcEnergyMgrID.button.FUEL);
  368. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  369. }
  370. }
  371. for (int i = 1; i <= 12; i++) {
  372. drawRect[i] = new DrawRect(context, i, 0, mNumberOfEnergy);
  373. layout.addView(drawRect[i]);
  374. }
  375. String str;
  376. if (RealtimeMeterUse == false) {
  377. // 실시간 검침 사용하지 않음
  378. str = "0";
  379. str += " kWh";
  380. } else {
  381. str = "0";
  382. str += " W";
  383. }
  384. RealTimeData.setText(str);
  385. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  386. SampleDatainsert_MonthTableData();
  387. } else {
  388. ShowMonthGraph();
  389. if (RealtimeMeterUse == true) {
  390. RemoveUsedData();
  391. ShowUsedDataGraph();
  392. } else {
  393. new Handler().postDelayed(new Runnable() {
  394. @Override
  395. public void run() {
  396. ShowUsedDataGraph_DayVersion();
  397. }
  398. }, 300);
  399. new Handler().postDelayed(new Runnable() {
  400. @Override
  401. public void run() {
  402. ShowRealTimeDataGraph_DayVersion();
  403. }
  404. }, 700);
  405. new Handler().postDelayed(new Runnable() {
  406. @Override
  407. public void run() {
  408. ShowDayGraph();
  409. }
  410. }, 800);
  411. }
  412. }
  413. Log.d(TAG, "[End - Screen] -------------------------------------------- ");
  414. }
  415. private void ShowRealTimeDataGraph_DayVersion() {
  416. // 사용량추이
  417. nowCal = Calendar.getInstance();
  418. CalendarYear = nowCal.get(Calendar.YEAR);
  419. CalendarMonth = nowCal.get(Calendar.MONTH);
  420. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  421. if (arrayListDayEnergyData.size() == 0) {
  422. arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 2, 3, 22, 34));
  423. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 1, 4, 23, 35));
  424. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 28, 5, 24, 36));
  425. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 27, 6, 25, 37));
  426. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 26, 7, 26, 38));
  427. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 25, 8, 27, 39));
  428. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 24, 9, 28, 40));
  429. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 23, 9, 29, 41));
  430. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 22, 6, 30, 42));
  431. }
  432. ShowDayGraph();
  433. } else {
  434. LoadRemotemeterDataFromServer(2, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
  435. }
  436. }
  437. private void ShowUsedDataGraph_DayVersion() {
  438. // 사용량추이
  439. nowCal = Calendar.getInstance();
  440. CalendarYear = nowCal.get(Calendar.YEAR);
  441. CalendarMonth = nowCal.get(Calendar.MONTH);
  442. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  443. if (arrayListDayEnergyData.size() == 0) {
  444. arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 2, 3, 22, 34));
  445. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 1, 4, 23, 35));
  446. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 28, 5, 24, 36));
  447. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 27, 6, 25, 37));
  448. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 26, 7, 26, 38));
  449. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 25, 8, 27, 39));
  450. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 24, 9, 28, 40));
  451. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 23, 9, 29, 41));
  452. //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 22, 6, 30, 42));
  453. }
  454. ShowDayGraph();
  455. } else {
  456. RecentDay = 0;
  457. isStartSaveData = false;
  458. TotalServerInquiryCount = 0;
  459. arrayListDayEnergyData.clear();
  460. LoadRemotemeterDataFromServer(1, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
  461. }
  462. }
  463. private void ShowMonthGraph() {
  464. /* if(Flag_SendMSG_RandomCheckHandler == true)
  465. {
  466. return;
  467. }*/
  468. nowCal = Calendar.getInstance();
  469. CalendarYear = nowCal.get(Calendar.YEAR);
  470. CalendarMonth = nowCal.get(Calendar.MONTH);
  471. LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
  472. }
  473. private void RemoveUsedData() {
  474. DebugLogOutput("[RemoveUsedData] is called");
  475. int NowHourint;
  476. long now = System.currentTimeMillis();
  477. Date date_Now = new Date(now);
  478. SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
  479. String strCurHour = CurHourFormat.format(date_Now);
  480. NowHourint = Integer.parseInt(strCurHour) / 3;
  481. for (int i = 0; i < 4; i++) {
  482. if (getLayout() != null) getLayout().removeView(UsedData_MaxData_textView[i]);
  483. }
  484. if (getLayout() != null) getLayout().removeView(UsedData_Unit);
  485. if (getLayout() != null) getLayout().removeView(drawLines[0]);
  486. for (int i = 0; i < 9; i++) {
  487. if (getLayout() != null) getLayout().removeView(Dot_img_Yesterday[i]);
  488. }
  489. if (getLayout() != null) getLayout().removeView(drawLines[1]);
  490. for (int i = 0; i < 9; i++) {
  491. if (Dot_img_Today[i] != null) {
  492. if (getLayout() != null) getLayout().removeView(Dot_img_Today[i]);
  493. }
  494. }
  495. if (getLayout() != null) getLayout().removeView(TotalUsedData_Today_textView);
  496. if (getLayout() != null) getLayout().removeView(TotalUsedData_Yesterday_textView);
  497. }
  498. public static float[] reverseArrayfloat(float[] array) {
  499. float temp;
  500. for (int i = 0; i < array.length / 2; i++) {
  501. temp = array[i];
  502. array[i] = array[(array.length - 1) - i];
  503. array[(array.length - 1) - i] = temp;
  504. }
  505. return array;
  506. }
  507. public static int[] reverseArrayint(int[] array) {
  508. int temp;
  509. for (int i = 0; i < array.length / 2; i++) {
  510. temp = array[i];
  511. array[i] = array[(array.length - 1) - i];
  512. array[(array.length - 1) - i] = temp;
  513. }
  514. return array;
  515. }
  516. /**
  517. * 사용량 추이 데이터 그리는 함수 - 실시간 검침 지원하지 않을 시 최근 8일 사용량 출력
  518. **/
  519. private void ShowDayGraph() {
  520. DebugLogOutput("ShowDayGraph");
  521. //실시간 사용량 배경 + 사용량추이 그래프 배경
  522. if (arrayListDayEnergyData.size() < 1) {
  523. DebugLogOutput("arrayListDayEnergyData.size() != 9. Return!!!");
  524. DebugLogOutput("arrayListDayEnergyData.size(): " + arrayListDayEnergyData.size());
  525. return;
  526. }
  527. //기존에 있던 그래프 삭제
  528. if (drawLines[0] != null) {
  529. if (getLayout() != null) getLayout().removeView(drawLines[0]);
  530. }
  531. for (int i = 0; i < 9; i++) {
  532. if (Dot_img_Yesterday[i] != null) {
  533. if (getLayout() != null) getLayout().removeView(Dot_img_Yesterday[i]);
  534. }
  535. if (DayEnergyMarking[i] != null) {
  536. if (getLayout() != null) getLayout().removeView(DayEnergyMarking[i]);
  537. }
  538. }
  539. int size = arrayListDayEnergyData.size() > 9 ? 9 : arrayListDayEnergyData.size();
  540. //그리기
  541. float[] tempFloatArray = new float[size];
  542. int[] tempintArray = new int[size];
  543. int j = 1;
  544. switch (NowShowEnergyKind) {
  545. case ID.IcEnergyMgrID.DataKind.KEPCO:
  546. for (int i = (size - 1); i >= 0; i--) {
  547. tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getKepco_used();
  548. j++;
  549. }
  550. break;
  551. case ID.IcEnergyMgrID.DataKind.SOLAR:
  552. for (int i = (size - 1); i >= 0; i--) {
  553. tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getSolar_used();
  554. j++;
  555. }
  556. break;
  557. case ID.IcEnergyMgrID.DataKind.FUEL:
  558. for (int i = (size - 1); i >= 0; i--) {
  559. tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getFuel_used();
  560. j++;
  561. }
  562. break;
  563. default:
  564. break;
  565. }
  566. UsedData_MaxData[3] = CalcMaxValue_float(tempFloatArray);
  567. if (UsedData_MaxData[3] <= (float) 0.3) {
  568. UsedData_MaxData[3] = (float) 0.3;
  569. }
  570. for (int i = 0; i < 4; i++) {
  571. // 왼쪽 에너지 기준 데이터 표시
  572. UsedData_MaxData[i] = UsedData_MaxData[3] / 3 * i;
  573. if (UsedData_MaxData[i] == 0) {
  574. UsedData_MaxData[i] = i * 2;
  575. }
  576. if (NowShowEnergyKind == ID.IcEnergyMgrID.DataKind.HEATING) {
  577. UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint2(UsedData_MaxData[i]));
  578. } else {
  579. UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint2(UsedData_MaxData[i]));
  580. }
  581. }
  582. switch (NowShowEnergyKind) {
  583. // 왼쪽 에너지 기준 데이터의 단위 표시
  584. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  585. case ID.IcEnergyMgrID.DataKind.KEPCO:
  586. case ID.IcEnergyMgrID.DataKind.SOLAR:
  587. case ID.IcEnergyMgrID.DataKind.FUEL:
  588. UsedData_Unit.setText("kWh"); // ㎥, ㎥/MWh, kWh;
  589. break;
  590. default:
  591. break;
  592. }
  593. //하단 날짜 출력, 에너지 데이터 삽입
  594. for (int i = 0; i < size; i++) {
  595. //if(i>=arrayListDayEnergyData.size()-1) break;
  596. tempintArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - size + i).getDay();
  597. }
  598. //int배열을 역순으로
  599. //tempintArray = reverseArrayint(tempintArray);
  600. for (int i = size - 1; i >= 0; i--) {
  601. DayMarking[i].setText(String.valueOf(tempintArray[i]) + "일");
  602. }
  603. //float배열 역순으로
  604. //tempFloatArray = reverseArrayfloat(tempFloatArray);
  605. UsedData_Yesterday_AfterCalc = tempFloatArray;
  606. //Yesterday 그래프그리기
  607. for (int i = 0; i < size; i++) {
  608. if (i < 2) {
  609. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
  610. } else if (i == 2) {
  611. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
  612. } else {
  613. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
  614. }
  615. int index = UsedData_Yesterday_AfterCalc.length - size + i;
  616. if (Float.isNaN((getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Yesterday_AfterCalc[index]) / UsedData_MaxData[3])))) {
  617. ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  618. } else {
  619. ArrayDot_Yesterday[1][i] = (int) (getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Yesterday_AfterCalc[index]) / UsedData_MaxData[3]) + 6); // y좌표
  620. if (ArrayDot_Yesterday[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
  621. ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  622. }
  623. }
  624. // DebugLogOutput("ArrayDot_Yesterday["+i+"] = "+ArrayDot_Yesterday[0][i]+", "+ArrayDot_Yesterday[1][i]);
  625. }
  626. drawLines[0] = new DrawLine(getContext(), ArrayDot_Yesterday, size - 1, 0);
  627. if (getLayout() != null) getLayout().addView(drawLines[0]);
  628. for (int i = 0; i < size; i++) {
  629. Dot_img_Yesterday[i] = new WpadImageView(getContext(), TOUCH_KIND.NONE, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).width, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).height, R.drawable.man_energy_moment_graph_dot_yesterday, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  630. ViewRegistration(getLayout(), Dot_img_Yesterday[i], ArrayDot_Yesterday[0][i], ArrayDot_Yesterday[1][i]);
  631. DayEnergyMarking[i] = new WpadTextView(getContext(), false, (60), 20, Gravity.CENTER, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  632. if (i == 0) {
  633. ViewRegistration(getLayout(), DayEnergyMarking[i], ArrayDot_Yesterday[0][i] - (38 / 2) + 15, ArrayDot_Yesterday[1][i] - 19);
  634. } else {
  635. ViewRegistration(getLayout(), DayEnergyMarking[i], ArrayDot_Yesterday[0][i] - (38 / 2) + 4, ArrayDot_Yesterday[1][i] - 19);
  636. }
  637. int index = UsedData_Yesterday_AfterCalc.length - size + i;
  638. DayEnergyMarking[i].setText(Convter2_DoubleTOStr_CutPoint2((double) UsedData_Yesterday_AfterCalc[index]));
  639. }
  640. //arrayListDayEnergyData.clear();
  641. Draw_Update();
  642. }
  643. /**
  644. * 사용량 추이 데이터 그리는 함수 - 실시간 검침 지원 시
  645. **/
  646. private void ShowUsedDataGraph() {
  647. DebugLogOutput("[ShowUsedDataGraph] is called");
  648. String tempstr;
  649. int NowHourint;
  650. //DB
  651. wallpaddbmgr WallpadDBMGR = null;
  652. WallpadDBMGR = new wallpaddbmgr(getContext());
  653. // 현재 시간을 msec으로 구한다.
  654. long now = System.currentTimeMillis();
  655. // 현재 시간을 저장 한다.
  656. Date date_Now = new Date(now);
  657. Date date_Yesterday;
  658. // 어제 날짜 구하기
  659. Calendar cal = Calendar.getInstance();
  660. cal.setTime(new Date(now));
  661. cal.add(Calendar.DATE, -1);
  662. date_Yesterday = new Date(cal.getTimeInMillis());
  663. // 시간 포맷 지정
  664. //SimpleDateFormat CurDateFormat = new SimpleDateFormat("yyyy년 MM월 dd일");
  665. //SimpleDateFormat CurTimeFormat = new SimpleDateFormat("HH시 mm분");
  666. SimpleDateFormat CurYearFormat = new SimpleDateFormat("yyyy");
  667. SimpleDateFormat CurMonthFormat = new SimpleDateFormat("MM");
  668. SimpleDateFormat CurDayFormat = new SimpleDateFormat("dd");
  669. SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
  670. SimpleDateFormat CurMinuteFormat = new SimpleDateFormat("mm");
  671. // 지정된 포맷으로 String 타입 리턴
  672. //String strCurDate = CurDateFormat.format(date);
  673. //String strCurTime = CurTimeFormat.format(date);
  674. String strCurYear = CurYearFormat.format(date_Now);
  675. String strCurMonth = CurMonthFormat.format(date_Now);
  676. String strCurDay = CurDayFormat.format(date_Now);
  677. String strCurHour = CurHourFormat.format(date_Now);
  678. NowHourint = Integer.parseInt(strCurHour) / 3;
  679. String strYesterYear = CurYearFormat.format(date_Yesterday);
  680. String strYesterMonth = CurMonthFormat.format(date_Yesterday);
  681. String strYesterDay = CurDayFormat.format(date_Yesterday);
  682. //DebugLogOutput("now :"+ strCurYear+"-"+strCurMonth+'-'+strCurDay+" "+strCurHour);
  683. int NowShowEnergy = DB_KEPCO;
  684. switch (NowShowEnergyKind) {
  685. case ID.IcEnergyMgrID.DataKind.KEPCO:
  686. NowShowEnergy = DB_KEPCO;
  687. break;
  688. case ID.IcEnergyMgrID.DataKind.SOLAR:
  689. NowShowEnergy = DB_SOLAR;
  690. break;
  691. case ID.IcEnergyMgrID.DataKind.FUEL:
  692. NowShowEnergy = DB_FUEL;
  693. break;
  694. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  695. NowShowEnergy = DB_ELECTRIC;
  696. break;
  697. case ID.IcEnergyMgrID.DataKind.HEATING:
  698. NowShowEnergy = DB_HEATING;
  699. break;
  700. case ID.IcEnergyMgrID.DataKind.GAS:
  701. NowShowEnergy = DB_GAS;
  702. break;
  703. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  704. NowShowEnergy = DB_HOTWATER;
  705. break;
  706. case ID.IcEnergyMgrID.DataKind.WATER:
  707. NowShowEnergy = DB_WATER;
  708. break;
  709. default:
  710. break;
  711. }
  712. try {
  713. Arrays.fill(UsedData_Yesterday, 0);
  714. Arrays.fill(UsedData_Today, 0);
  715. for (int i = 0; i < 9; i++) {
  716. if ((i * 3) < 12) {
  717. tempstr = "0";
  718. } else {
  719. tempstr = "";
  720. }
  721. String tempString;
  722. if (i == 8) {
  723. tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strCurYear, strCurMonth, strCurDay, "00");
  724. } else {
  725. tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strYesterYear, strYesterMonth, strYesterDay, tempstr + (String.valueOf(i * 3)));
  726. }
  727. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  728. switch (NowShowEnergyKind) {
  729. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  730. case ID.IcEnergyMgrID.DataKind.KEPCO:
  731. tempString = SampleUsedData1[i];
  732. break;
  733. case ID.IcEnergyMgrID.DataKind.HEATING:
  734. case ID.IcEnergyMgrID.DataKind.SOLAR:
  735. tempString = SampleUsedData3[i];
  736. break;
  737. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  738. case ID.IcEnergyMgrID.DataKind.FUEL:
  739. tempString = SampleUsedData5[i];
  740. break;
  741. case ID.IcEnergyMgrID.DataKind.WATER:
  742. tempString = SampleUsedData7[i];
  743. break;
  744. case ID.IcEnergyMgrID.DataKind.GAS:
  745. tempString = SampleUsedData9[i];
  746. break;
  747. default:
  748. break;
  749. }
  750. }
  751. if (tempString == null) {
  752. UsedData_Yesterday[i] = 0;
  753. } else {
  754. UsedData_Yesterday[i] = Float.parseFloat(tempString);
  755. }
  756. DebugLogOutput(strYesterYear + "-" + strYesterMonth + '-' + strYesterDay + " hour:" + String.valueOf(i * 3) + " - Data:" + UsedData_Yesterday[i]);
  757. if (UsedData_Yesterday[i] < 0) {
  758. UsedData_Yesterday[i] = 0;
  759. }
  760. }
  761. for (int i = 0; i <= NowHourint; i++) {
  762. if ((i * 3) < 12) {
  763. tempstr = "0";
  764. } else {
  765. tempstr = "";
  766. }
  767. String tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strCurYear, strCurMonth, strCurDay, tempstr + (String.valueOf(i * 3)));
  768. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  769. switch (NowShowEnergyKind) {
  770. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  771. case ID.IcEnergyMgrID.DataKind.KEPCO:
  772. tempString = SampleUsedData2[i];
  773. break;
  774. case ID.IcEnergyMgrID.DataKind.HEATING:
  775. case ID.IcEnergyMgrID.DataKind.SOLAR:
  776. tempString = SampleUsedData4[i];
  777. break;
  778. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  779. case ID.IcEnergyMgrID.DataKind.FUEL:
  780. tempString = SampleUsedData6[i];
  781. break;
  782. case ID.IcEnergyMgrID.DataKind.WATER:
  783. tempString = SampleUsedData8[i];
  784. break;
  785. case ID.IcEnergyMgrID.DataKind.GAS:
  786. tempString = SampleUsedData10[i];
  787. break;
  788. default:
  789. break;
  790. }
  791. }
  792. if (tempString == null) {
  793. UsedData_Today[i] = 0;
  794. } else {
  795. UsedData_Today[i] = Float.parseFloat(tempString);
  796. }
  797. DebugLogOutput(strCurYear + "-" + strCurMonth + '-' + strCurDay + " hour:" + String.valueOf(i * 3) + " - Data:" + UsedData_Today[i]);
  798. if (UsedData_Today[i] < 0) {
  799. UsedData_Today[i] = 0;
  800. }
  801. }
  802. } catch (RuntimeException re) {
  803. if (WallpadDBMGR != null) {
  804. WallpadDBMGR.closeDB();
  805. }
  806. Log.e(TAG, "exception : " + re);
  807. } catch (Exception e) {
  808. if (WallpadDBMGR != null) {
  809. WallpadDBMGR.closeDB();
  810. }
  811. //e.printStackTrace();
  812. LogUtil.errorLogInfo("", TAG, e);
  813. }
  814. //DB
  815. WallpadDBMGR.closeDB();
  816. Arrays.fill(UsedData_Yesterday_AfterCalc, 0);
  817. Arrays.fill(UsedData_Today_AfterCalc, 0);
  818. for (int i = 0; i < 9; i++) {
  819. if (i == 8) {
  820. UsedData_Yesterday_AfterCalc[i] = UsedData_Today[0] - UsedData_Yesterday[i];
  821. } else {
  822. UsedData_Yesterday_AfterCalc[i + 1] = UsedData_Yesterday[i + 1] - UsedData_Yesterday[i];
  823. if (UsedData_Yesterday[i] == 0) {
  824. UsedData_Yesterday_AfterCalc[i + 1] = 0;
  825. } else {
  826. UsedData_Yesterday_AfterCalc[i + 1] = UsedData_Yesterday[i + 1] - UsedData_Yesterday[i];
  827. }
  828. }
  829. if (UsedData_Yesterday_AfterCalc[i] < 0) {
  830. UsedData_Yesterday_AfterCalc[i] = 0;
  831. }
  832. DebugLogOutput("UsedData_Yesterday_AfterCalc[" + i + "] = " + UsedData_Yesterday_AfterCalc[i]);
  833. }
  834. for (int i = 0; i <= NowHourint; i++) {
  835. UsedData_Today_AfterCalc[i + 1] = UsedData_Today[i + 1] - UsedData_Today[i];
  836. if (UsedData_Today[i] == 0) {
  837. UsedData_Today_AfterCalc[i + 1] = 0;
  838. } else {
  839. UsedData_Today_AfterCalc[i + 1] = UsedData_Today[i + 1] - UsedData_Today[i];
  840. }
  841. if (UsedData_Today_AfterCalc[i] < 0) {
  842. UsedData_Today_AfterCalc[i] = 0;
  843. }
  844. if (UsedData_Today_AfterCalc[i + 1] < 0) {
  845. UsedData_Today_AfterCalc[i + 1] = 0;
  846. }
  847. DebugLogOutput("UsedData_Today_AfterCalc[" + i + "] = " + UsedData_Today_AfterCalc[i]);
  848. }
  849. //어제 사용량, 오늘 사용량 구하기
  850. float TempTotalUsedData_Yesterday = 0;
  851. float TempTotalUsedData_today = 0;
  852. for (int i = 0; i < 9; i++) {
  853. if (UsedData_Yesterday_AfterCalc[i] >= 0) {
  854. TempTotalUsedData_Yesterday = TempTotalUsedData_Yesterday + UsedData_Yesterday_AfterCalc[i];
  855. }
  856. DebugLogOutput("TotalUsedData_Yesterday[" + i + "] = " + TempTotalUsedData_Yesterday);
  857. }
  858. for (int i = 0; i <= NowHourint; i++) {
  859. if (UsedData_Today_AfterCalc[i] >= 0) {
  860. TempTotalUsedData_today = TempTotalUsedData_today + UsedData_Today_AfterCalc[i];
  861. }
  862. DebugLogOutput("TotalUsedData_Today[" + i + "] = " + TempTotalUsedData_today);
  863. }
  864. TotalUsedData_Yesterday = TempTotalUsedData_Yesterday;
  865. TotalUsedData_Today = TempTotalUsedData_today;
  866. //어제사용량
  867. TotalUsedData_Yesterday_textView = new WpadTextView(getContext(), false, 70, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.UsedData_MaxData_textView.TotalUsedData_Yesterday_textView);
  868. ViewRegistration(getLayout(), TotalUsedData_Yesterday_textView, Common.ImgPosion.GetX(556), Common.ImgPosion.GetY(456));
  869. TotalUsedData_Yesterday_textView.setText(Convter2_DoubleTOStr_CutPoint1(TotalUsedData_Yesterday));
  870. //오늘 사용량
  871. TotalUsedData_Today_textView = new WpadTextView(getContext(), false, 70, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.UsedData_MaxData_textView.TotalUsedData_Today_textView);
  872. ViewRegistration(getLayout(), TotalUsedData_Today_textView, Common.ImgPosion.GetX(556), Common.ImgPosion.GetY(481));
  873. TotalUsedData_Today_textView.setText(Convter2_DoubleTOStr_CutPoint1(TotalUsedData_Today));
  874. //어제 사용량, 오늘 사용량 구하기
  875. if (CalcMaxValue_float(UsedData_Yesterday_AfterCalc) >= CalcMaxValue_float(UsedData_Today_AfterCalc)) {
  876. UsedData_MaxData[3] = CalcMaxValue_float(UsedData_Yesterday_AfterCalc);
  877. } else {
  878. UsedData_MaxData[3] = CalcMaxValue_float(UsedData_Today_AfterCalc);
  879. }
  880. if (UsedData_MaxData[3] <= (float) 0.3) {
  881. UsedData_MaxData[3] = (float) 0.3;
  882. }
  883. for (int i = 0; i < 4; i++) {
  884. UsedData_MaxData[i] = UsedData_MaxData[3] / 3 * i;
  885. if (UsedData_MaxData[i] == 0) {
  886. UsedData_MaxData[i] = i * 2;
  887. }
  888. UsedData_MaxData_textView[i] = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).width, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).height, Gravity.RIGHT, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  889. ViewRegistration(getLayout(), UsedData_MaxData_textView[i], getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.MARKING_2, i).y);
  890. UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint1(UsedData_MaxData[i]));
  891. }
  892. UsedData_Unit = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).width, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).height, Gravity.RIGHT, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
  893. ViewRegistration(getLayout(), UsedData_Unit, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).y);
  894. switch (NowShowEnergyKind) {
  895. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  896. UsedData_Unit.setText("kWh"); // ㎥, ㎥/MWh, kWh;
  897. break;
  898. case ID.IcEnergyMgrID.DataKind.HEATING:
  899. UsedData_Unit.setText("㎥/MWh"); // ㎥, ㎥/MWh, kWh;
  900. break;
  901. case ID.IcEnergyMgrID.DataKind.GAS:
  902. UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
  903. break;
  904. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  905. UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
  906. break;
  907. case ID.IcEnergyMgrID.DataKind.WATER:
  908. UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
  909. break;
  910. default:
  911. break;
  912. }
  913. //Yesterday 그래프그리기
  914. for (int i = 0; i < 9; i++) {
  915. if (i < 2) {
  916. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
  917. } else if (i == 2) {
  918. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
  919. } else {
  920. ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
  921. }
  922. if (Float.isNaN((getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Yesterday_AfterCalc[i]) / UsedData_MaxData[3])))) {
  923. ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  924. } else {
  925. ArrayDot_Yesterday[1][i] = (int) (getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Yesterday_AfterCalc[i]) / UsedData_MaxData[3]) + 6); // y좌표
  926. if (ArrayDot_Yesterday[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
  927. ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  928. }
  929. }
  930. /*
  931. DebugLogOutput("UsedData_MaxData[3]" + UsedData_MaxData[3]);
  932. DebugLogOutput("UsedData_Yesterday_AfterCalc[i]" + UsedData_Yesterday_AfterCalc[i]);
  933. DebugLogOutput("Calc value " + (506-(69*(UsedData_Yesterday_AfterCalc[i])/UsedData_MaxData[3])));
  934. */
  935. //DebugLogOutput("ArrayDot_Yesterday["+i+"] = "+ArrayDot_Yesterday[0][i]+", "+ArrayDot_Yesterday[1][i]);
  936. }
  937. drawLines[0] = new DrawLine(getContext(), ArrayDot_Yesterday, 9, 0);
  938. if (getLayout() != null) getLayout().addView(drawLines[0]);
  939. for (int i = 0; i < 9; i++) {
  940. Dot_img_Yesterday[i] = new WpadImageView(getContext(), TOUCH_KIND.NONE, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).width, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).height, R.drawable.man_energy_moment_graph_dot_yesterday, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  941. ViewRegistration(getLayout(), Dot_img_Yesterday[i], ArrayDot_Yesterday[0][i], ArrayDot_Yesterday[1][i]);
  942. }
  943. //Today 그래프그리기
  944. for (int i = 0; i <= NowHourint; i++) {
  945. if (i < 2) {
  946. ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
  947. } else if (i == 2) {
  948. ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
  949. } else {
  950. ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
  951. }
  952. if (Float.isNaN((getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Today_AfterCalc[i]) / UsedData_MaxData[3])))) {
  953. ArrayDot_Today[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  954. } else {
  955. ArrayDot_Today[1][i] = (int) (getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y - (getPos.Get(ID.IcEnergyMgrID.Graph.y_1, i).y * (UsedData_Today_AfterCalc[i]) / UsedData_MaxData[3]) + 6); // y좌표
  956. if (ArrayDot_Today[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
  957. ArrayDot_Today[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
  958. }
  959. }
  960. //DebugLogOutput("ArrayDot_Today["+i+"+] = "+ArrayDot_Today[0][i]+", "+ArrayDot_Today[1][i]);
  961. }
  962. drawLines[1] = new DrawLine(getContext(), ArrayDot_Today, NowHourint, 1);
  963. if (getLayout() != null) getLayout().addView(drawLines[1]);
  964. for (int i = 0; i <= NowHourint; i++) {
  965. Dot_img_Today[i] = new WpadImageView(getContext(), TOUCH_KIND.NONE, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).width, getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).height, R.drawable.man_energy_moment_graph_dot_today, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  966. ViewRegistration(getLayout(), Dot_img_Today[i], ArrayDot_Today[0][i], ArrayDot_Today[1][i]);
  967. }
  968. }
  969. /**
  970. * 배열의 최대값 구하는 함수
  971. *
  972. * @param ArrayFloat float[]
  973. * @return flaot (최대값)
  974. **/
  975. public float CalcMaxValue_float(float[] ArrayFloat) {
  976. float max = ArrayFloat[0];
  977. for (int i = 1; i < ArrayFloat.length; i++) {
  978. if (ArrayFloat[i] >= max) {
  979. max = ArrayFloat[i];
  980. }
  981. }
  982. return max;
  983. }
  984. @Override
  985. protected void onClose() {
  986. super.onClose();
  987. UnRegisterMainEventBr();
  988. if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) Sample_End();
  989. if (realTimeMeterAPI != null) {
  990. Device_BrRegistration(false);
  991. }
  992. Log.i(TAG, "[END - Screen] ********************************************");
  993. }
  994. @Override
  995. public void Close() {
  996. Log.i(TAG, "[END - Screen] ********************************************");
  997. super.Close();
  998. }
  999. @Override
  1000. protected void onTouchEvent(View v, MotionEvent event) {
  1001. super.onTouchEvent(v, event);
  1002. int TargetId = v.getId();
  1003. int MoveEvent = event.getAction();
  1004. if (MoveEvent == MotionEvent.ACTION_DOWN) {
  1005. } else if (MoveEvent == MotionEvent.ACTION_UP) {
  1006. if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_LEFT) {
  1007. } else if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_HOME) {
  1008. } else if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_RIGHT) {
  1009. } else if (TargetId == ID.IcEnergyMgrID.button.DETAIL_VIEW) {
  1010. // 확대버튼 누를경우 Energy관리 app 실행되야 함!
  1011. DebugLogOutput("callStartEnergyAPK");
  1012. Sound().Play(WpadSound.SND.effect.TOUCH_LATCHED);
  1013. //m_CallSubMenuScreen.callStartEnergyAPK();
  1014. } else if ((TargetId >= ID.IcEnergyMgrID.button.KEPCO) && (TargetId <= ID.IcEnergyMgrID.button.FUEL)) {
  1015. Sound().Play(WpadSound.SND.effect.TOUCH_LATCHED);
  1016. switch (NowShowEnergyKind) {
  1017. case ID.IcEnergyMgrID.DataKind.KEPCO:
  1018. if (getLayout() != null) getLayout().removeView(Btn_Kepco);
  1019. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_normal, R.drawable.btn_3_kepco_pressed, ID.IcEnergyMgrID.button.KEPCO);
  1020. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1021. Btn_Kepco.setVisibility(View.GONE);
  1022. break;
  1023. case ID.IcEnergyMgrID.DataKind.SOLAR:
  1024. if (getLayout() != null) getLayout().removeView(Btn_Solar);
  1025. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_normal, R.drawable.btn_3_solar_e_pressed, ID.IcEnergyMgrID.button.SOLAR);
  1026. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  1027. break;
  1028. case ID.IcEnergyMgrID.DataKind.FUEL:
  1029. if (getLayout() != null) getLayout().removeView(Btn_Fuel);
  1030. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_normal, R.drawable.btn_3_fuel_cell_pressed, ID.IcEnergyMgrID.button.FUEL);
  1031. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  1032. break;
  1033. }
  1034. switch (TargetId) {
  1035. case ID.IcEnergyMgrID.button.KEPCO:
  1036. //계기판 배경
  1037. CircleGraph.setImageResource(CircleGraph_bg[0]);
  1038. NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.KEPCO;
  1039. if (RealtimeMeterUse == false) {
  1040. // 실시간 검침 사용하지 않음
  1041. EnergyMax_Double = 20;
  1042. if (RealTimeData != null) RealTimeData.setText("0 kWh");
  1043. } else {
  1044. EnergyMax_Double = 3000;
  1045. if (RealTimeData != null) RealTimeData.setText("0 W");
  1046. }
  1047. if (getLayout() != null) getLayout().removeView(Btn_Kepco);
  1048. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
  1049. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
  1050. Btn_Kepco.setVisibility(View.GONE);
  1051. break;
  1052. case ID.IcEnergyMgrID.button.SOLAR:
  1053. CircleGraph.setImageResource(CircleGraph_bg[0]);
  1054. NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.SOLAR;
  1055. if (RealtimeMeterUse == false) {
  1056. // 실시간 검침 사용하지 않음
  1057. EnergyMax_Double = 20;
  1058. if (RealTimeData != null) RealTimeData.setText("0 kWh");
  1059. } else {
  1060. EnergyMax_Double = 3000;
  1061. if (RealTimeData != null) RealTimeData.setText("0 W");
  1062. }
  1063. if (getLayout() != null) getLayout().removeView(Btn_Solar);
  1064. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
  1065. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_pressed).x, getPos.Get(R.drawable.btn_3_solar_e_pressed).y);
  1066. break;
  1067. case ID.IcEnergyMgrID.button.FUEL:
  1068. CircleGraph.setImageResource(CircleGraph_bg[2]);
  1069. NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.FUEL;
  1070. if (RealtimeMeterUse == false) {
  1071. // 실시간 검침 사용하지 않음
  1072. EnergyMax_Double = 1.2;
  1073. if (RealTimeData != null) RealTimeData.setText("0 kWh");
  1074. } else {
  1075. EnergyMax_Double = 3000;
  1076. if (RealTimeData != null) RealTimeData.setText("0 W");
  1077. }
  1078. if (getLayout() != null) getLayout().removeView(Btn_Fuel);
  1079. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_selected, 0, ID.IcEnergyMgrID.button.FUEL);
  1080. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_pressed).x, getPos.Get(R.drawable.btn_3_fuel_cell_pressed).y);
  1081. break;
  1082. default:
  1083. break;
  1084. }
  1085. //Draw_Update();
  1086. if (RealtimeMeterUse == true) {
  1087. RemoveUsedData();
  1088. ShowUsedDataGraph();
  1089. } else {
  1090. ShowRealTimeDataGraph_DayVersion();
  1091. //ShowUsedDataGraph_DayVersion();
  1092. ShowDayGraph();
  1093. }
  1094. }
  1095. }
  1096. }
  1097. @Override
  1098. public void ViewRegistration(RelativeLayout ParentsLayout, WpadImageView nImageView, int MarginLeft, int MarginTop) {
  1099. // TODO Auto-generated method stub
  1100. super.ViewRegistration(ParentsLayout, nImageView, MarginLeft, MarginTop);
  1101. }
  1102. @Override
  1103. public void ViewRegistration(RelativeLayout ParentsLayout, WpadTextView nTextView, int MarginLeft, int MarginTop) {
  1104. // TODO Auto-generated method stub
  1105. super.ViewRegistration(ParentsLayout, nTextView, MarginLeft, MarginTop);
  1106. }
  1107. private void RegisterMainEventBr() {
  1108. IntentFilter filter = new IntentFilter();
  1109. filter.addAction(Common.MAIN_EVENT_TIMER);
  1110. filter.addAction(Common.MAIN_SCREEN_NOW_UPDATE);
  1111. filter.addAction(ID.IcEnergyMgrID.BR_REALMETER);
  1112. this.getContext().registerReceiver(m_MainEventBR, filter);
  1113. }
  1114. private void UnRegisterMainEventBr() {
  1115. this.getContext().unregisterReceiver(m_MainEventBR);
  1116. }
  1117. BroadcastReceiver m_MainEventBR = new BroadcastReceiver() {
  1118. @Override
  1119. public void onReceive(Context context, Intent intent) {
  1120. String acname = intent.getAction();
  1121. /* if( acname.equals(Common.MAIN_SCREEN_NOW_UPDATE) )
  1122. {
  1123. if( Background != null )
  1124. {
  1125. GetDBMainSkinBg();
  1126. Background.setImageResource(getResourceIdMainSkin());
  1127. }
  1128. }*/
  1129. if (acname.equals(ID.IcEnergyMgrID.BR_REALMETER)) {
  1130. //DebugLogOutput("onBrReceive - BR_REALMETER");
  1131. int bRet = Device_Update(false);
  1132. if ((bRet == 0) && (APIInit == false)) {
  1133. DebugLogOutput("APIInit = true;");
  1134. APIInit = true;
  1135. }
  1136. Draw_Update();
  1137. }
  1138. }
  1139. };
  1140. // =================================================================================================
  1141. // [[ Draw ]] region
  1142. // =================================================================================================
  1143. protected void Draw_Update() {
  1144. if ((data.GetAllSupport() != TempbSupportKind) && (RealtimeMeterUse == true) && (APIInit == true)) {
  1145. DebugLogOutput("if((data.GetAllSupport() != TempbSupportKind) && (RealtimeMeterUse == true))");
  1146. TempbSupportKind = data.GetAllSupport();
  1147. //NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.KEPCO;
  1148. if (data.GetAllSupport() == false && getLayout() != null) {
  1149. // 종 버튼 등록.
  1150. //버튼 해제
  1151. if (getLayout() != null) getLayout().removeView(Btn_Kepco);
  1152. if (getLayout() != null) getLayout().removeView(Btn_Solar);
  1153. if (getLayout() != null) getLayout().removeView(Btn_Fuel);
  1154. switch (NowShowEnergyKind) {
  1155. case ID.IcEnergyMgrID.DataKind.KEPCO:
  1156. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
  1157. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
  1158. Btn_Kepco.setVisibility(View.GONE);
  1159. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_normal, R.drawable.btn_3_solar_e_pressed, ID.IcEnergyMgrID.button.SOLAR);
  1160. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  1161. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_normal, R.drawable.btn_3_fuel_cell_pressed, ID.IcEnergyMgrID.button.FUEL);
  1162. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  1163. break;
  1164. case ID.IcEnergyMgrID.DataKind.SOLAR:
  1165. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_normal, R.drawable.btn_3_kepco_pressed, ID.IcEnergyMgrID.button.KEPCO);
  1166. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1167. Btn_Kepco.setVisibility(View.GONE);
  1168. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
  1169. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  1170. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_normal, R.drawable.btn_3_fuel_cell_pressed, ID.IcEnergyMgrID.button.FUEL);
  1171. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  1172. break;
  1173. case ID.IcEnergyMgrID.DataKind.FUEL:
  1174. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_normal, R.drawable.btn_3_kepco_pressed, ID.IcEnergyMgrID.button.KEPCO);
  1175. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1176. Btn_Kepco.setVisibility(View.GONE);
  1177. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_normal, R.drawable.btn_3_solar_e_pressed, ID.IcEnergyMgrID.button.SOLAR);
  1178. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
  1179. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_fuel_cell_selected, 0, ID.IcEnergyMgrID.button.FUEL);
  1180. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
  1181. break;
  1182. }
  1183. } else {
  1184. if (getLayout() != null) getLayout().removeView(Btn_Kepco);
  1185. if (getLayout() != null) getLayout().removeView(Btn_Solar);
  1186. if (getLayout() != null) getLayout().removeView(Btn_Fuel);
  1187. switch (NowShowEnergyKind) {
  1188. case ID.IcEnergyMgrID.DataKind.KEPCO:
  1189. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
  1190. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1191. Btn_Kepco.setVisibility(View.GONE);
  1192. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.man_energy_btn_water_3set_normal, R.drawable.man_energy_btn_water_3set_pressed, ID.IcEnergyMgrID.button.SOLAR);
  1193. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).y);
  1194. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.man_energy_btn_gas_3set_normal, R.drawable.man_energy_btn_gas_3set_pressed, ID.IcEnergyMgrID.button.FUEL);
  1195. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).y);
  1196. break;
  1197. case ID.IcEnergyMgrID.DataKind.SOLAR:
  1198. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_normal, R.drawable.btn_3_kepco_normal, ID.IcEnergyMgrID.button.KEPCO);
  1199. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1200. Btn_Kepco.setVisibility(View.GONE);
  1201. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.man_energy_btn_water_3set_pressed, 0, ID.IcEnergyMgrID.button.SOLAR);
  1202. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).y);
  1203. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.man_energy_btn_gas_3set_normal, R.drawable.man_energy_btn_gas_3set_pressed, ID.IcEnergyMgrID.button.FUEL);
  1204. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).y);
  1205. break;
  1206. case ID.IcEnergyMgrID.DataKind.FUEL:
  1207. Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_normal, R.drawable.btn_3_kepco_normal, ID.IcEnergyMgrID.button.KEPCO);
  1208. ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
  1209. Btn_Kepco.setVisibility(View.GONE);
  1210. Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.man_energy_btn_water_3set_normal, R.drawable.man_energy_btn_water_3set_pressed, ID.IcEnergyMgrID.button.SOLAR);
  1211. ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_water_3set_normal).y);
  1212. Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.man_energy_btn_gas_3set_pressed, 0, ID.IcEnergyMgrID.button.FUEL);
  1213. ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).x, getPos.Get(R.drawable.man_energy_btn_gas_3set_normal).y);
  1214. break;
  1215. }
  1216. }
  1217. }
  1218. if (RealtimeMeterUse == false) {
  1219. // 실시간 검침 사용하지 않음
  1220. if ((arrayListDayEnergyData.size() != 0) && (arrayListDayEnergyData.isEmpty() != true)) {
  1221. switch (NowShowEnergyKind) {
  1222. case ID.IcEnergyMgrID.DataKind.KEPCO:
  1223. //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getKepco_used());
  1224. if(realTimeEnergyData!=null)
  1225. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getKepco_used());
  1226. break;
  1227. case ID.IcEnergyMgrID.DataKind.SOLAR:
  1228. //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.SOLAR, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getSolar_used());
  1229. if(realTimeEnergyData!=null)
  1230. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getSolar_used());
  1231. CircleGraph.setImageResource(CircleGraph_bg[0]);
  1232. break;
  1233. case ID.IcEnergyMgrID.DataKind.FUEL:
  1234. //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.FUEL, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getFuel_used());
  1235. if(realTimeEnergyData!=null)
  1236. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getFuel_used());
  1237. break;
  1238. default:
  1239. break;
  1240. }
  1241. }
  1242. } else {
  1243. // 실시간 검침 지원함
  1244. switch (NowShowEnergyKind) {
  1245. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  1246. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.ELECTRIC, data.Elec.Now);
  1247. break;
  1248. case ID.IcEnergyMgrID.DataKind.WATER:
  1249. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.WATER, data.Water.Now);
  1250. break;
  1251. case ID.IcEnergyMgrID.DataKind.GAS:
  1252. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.GAS, data.Gas.Now);
  1253. break;
  1254. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  1255. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HOTWATER, data.HotWater.Now);
  1256. break;
  1257. case ID.IcEnergyMgrID.DataKind.HEATING:
  1258. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HEATING, data.Calorie.Now);
  1259. break;
  1260. default:
  1261. break;
  1262. }
  1263. }
  1264. ReDraw();
  1265. }
  1266. /**
  1267. * 바늘 그리기
  1268. */
  1269. public class DrawScrew extends View {
  1270. private float Degree;
  1271. Path mScrewPath;
  1272. Paint mScrewPaint, mGraphPaint;
  1273. Bitmap resizedBitmap;
  1274. private boolean init_flag = false;
  1275. Matrix matrix;
  1276. public DrawScrew(Context context, float degree) {
  1277. super(context);
  1278. Degree = degree;
  1279. }
  1280. @Override
  1281. protected void onDraw(Canvas canvas) {
  1282. super.onDraw(canvas);
  1283. if (init_flag == false) {
  1284. init_flag = true;
  1285. //그래프 그리기
  1286. resizedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg_graph_holder_2);
  1287. // AutoScale 설정시에만 bitmapOrg 을 Scaled 한다.
  1288. if (WpadScale.getAutoScale()) {
  1289. //resizedBitmap = Bitmap.createScaledBitmap(resizedBitmap,74,37,true);
  1290. resizedBitmap = Bitmap.createScaledBitmap(resizedBitmap, WpadScale.getWidth(resizedBitmap.getWidth()), WpadScale.getHeight(resizedBitmap.getHeight()), true);
  1291. }
  1292. matrix = new Matrix();
  1293. mScrewPaint = new Paint();
  1294. mScrewPaint.setAntiAlias(true);
  1295. }
  1296. // rotate the Bitmap
  1297. matrix.reset();
  1298. matrix.setRotate(Degree, resizedBitmap.getWidth() / 2, 0);
  1299. canvas.translate(getPos.Get(R.drawable.bg_graph_holder_2).x, getPos.Get(R.drawable.bg_graph_holder_2).y); //201, 131
  1300. //canvas.translate(Common.ImgPosion.GetX(470-37),Common.ImgPosion.GetY(359)); //37: 반지름
  1301. canvas.drawBitmap(resizedBitmap, matrix, mScrewPaint);
  1302. }
  1303. public void Rotate_ReDraw(float degree) {
  1304. Degree = degree;
  1305. invalidate();
  1306. }
  1307. }
  1308. /**
  1309. * 실시간 생산량 계기판 그리는 함수
  1310. **/
  1311. public void ReDraw() {
  1312. if (EnergyMax_Double <= RealTimeData_Double) {
  1313. RealTimeData_Double = EnergyMax_Double;
  1314. }
  1315. mScrewDegree = (float) (180 / (EnergyMax_Double / RealTimeData_Double) - 270);
  1316. drawScrew[0].Rotate_ReDraw(mScrewDegree);
  1317. mGraphDegree = (float) (180 / (EnergyMax_Double / RealTimeData_Double) - 180);
  1318. drawgraph[0].Rotate_ReDraw(mGraphDegree);
  1319. }
  1320. /**
  1321. * 실시간 생산량 계기판 그리는 클래스
  1322. **/
  1323. public class DrawGraph extends View {
  1324. private float Degree;
  1325. Paint mGraphPaint;
  1326. Matrix matrix;
  1327. Bitmap resizedBitmap;
  1328. Bitmap bitmapOrg;
  1329. private boolean init_flag = false;
  1330. public DrawGraph(Context context, float degree) {
  1331. super(context);
  1332. Degree = degree;
  1333. }
  1334. @Override
  1335. protected void onDraw(Canvas canvas) {
  1336. super.onDraw(canvas);
  1337. if (init_flag == false) {
  1338. init_flag = true;
  1339. //그래프 그리기
  1340. bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.man_energy_moment_graph2);
  1341. // AutoScale 설정시에만 bitmapOrg 을 Scaled 한다.
  1342. if (WpadScale.getAutoScale()) {
  1343. //bitmapOrg= Bitmap.createScaledBitmap(bitmapOrg,356,186,true);
  1344. bitmapOrg = Bitmap.createScaledBitmap(bitmapOrg, WpadScale.getWidth(bitmapOrg.getWidth()), WpadScale.getHeight(bitmapOrg.getHeight()), true);
  1345. }
  1346. matrix = new Matrix();
  1347. mGraphPaint = new Paint();
  1348. mGraphPaint.setAntiAlias(true);
  1349. }
  1350. // rotate the Bitmap
  1351. matrix.reset();
  1352. matrix.setRotate(Degree, bitmapOrg.getWidth() / 2, 0);
  1353. //canvas.translate(Common.ImgPosion.GetX(292),Common.ImgPosion.GetY(360));
  1354. canvas.translate(getPos.Get(R.drawable.man_energy_moment_graph2).x, getPos.Get(R.drawable.man_energy_moment_graph2).y); //201, 131
  1355. canvas.drawBitmap(bitmapOrg, matrix, mGraphPaint);
  1356. }
  1357. public void Rotate_ReDraw(float degree) {
  1358. Degree = degree;
  1359. invalidate();
  1360. }
  1361. }
  1362. /**
  1363. * 실시간 사용량 추이 그래프 그리기
  1364. **/
  1365. public class DrawLine extends View {
  1366. private float[] linePoint;
  1367. private int[][] InputLinePoint;
  1368. Paint mLinePaint;
  1369. boolean init_flag = false;
  1370. private int SEGS;
  1371. private int count;
  1372. private int colorKind; //0이면 어제, 1이면 오늘
  1373. private static final int X = 0;
  1374. private static final int Y = 1;
  1375. public DrawLine(Context context, int[][] arrayDot_Yesterday, int Count, int ColorKind) {
  1376. super(context);
  1377. InputLinePoint = arrayDot_Yesterday;
  1378. count = Count;
  1379. colorKind = ColorKind;
  1380. buildPoints();
  1381. }
  1382. private void buildPoints() {
  1383. SEGS = count;
  1384. final int ptCount = (SEGS + 1) * 2;
  1385. linePoint = new float[ptCount * 2];
  1386. for (int i = 0; i < SEGS; i++) {
  1387. linePoint[i * 4 + X] = WpadScale.getWidth((float) InputLinePoint[0][i] + 4.5f);
  1388. linePoint[i * 4 + Y] = WpadScale.getHeight((float) InputLinePoint[1][i] + 4.5f);
  1389. if (i == 8) {
  1390. linePoint[i * 4 + X + 2] = linePoint[i * 4 + X];
  1391. linePoint[i * 4 + Y + 2] = linePoint[i * 4 + Y];
  1392. } else {
  1393. linePoint[i * 4 + X + 2] = WpadScale.getWidth((float) InputLinePoint[0][i + 1] + 4.5f);
  1394. linePoint[i * 4 + Y + 2] = WpadScale.getHeight((float) InputLinePoint[1][i + 1] + 4.5f);
  1395. }
  1396. /*
  1397. DebugLogOutput("linePoint[i*4 + X]: "+linePoint[i*4 + X]);
  1398. DebugLogOutput("linePoint[i*4 + Y]: "+linePoint[i*4 + Y]);
  1399. DebugLogOutput("linePoint[i*4 + X + 2]: "+linePoint[i*4 + X + 2]);
  1400. DebugLogOutput("linePoint[i*4 + Y + 2]: "+linePoint[i*4 + Y + 2]);
  1401. */
  1402. }
  1403. }
  1404. @Override
  1405. protected void onDraw(Canvas canvas) {
  1406. super.onDraw(canvas);
  1407. if (init_flag == false) {
  1408. init_flag = true;
  1409. mLinePaint = new Paint();
  1410. mLinePaint.setAntiAlias(true);
  1411. if (colorKind == 0) {
  1412. mLinePaint.setColor(Color.parseColor("#99d300"));
  1413. } else {
  1414. mLinePaint.setColor(Color.parseColor("#3588d5"));
  1415. }
  1416. mLinePaint.setStrokeWidth(3);
  1417. }
  1418. canvas.drawLines(linePoint, mLinePaint);
  1419. }
  1420. public void ReDraw(int[][] LinePoint, int Count, int ColorKind) {
  1421. int[][] temp_LinePort = LinePoint;
  1422. if (temp_LinePort != null) {
  1423. InputLinePoint = new int[temp_LinePort.length][InputLinePoint[0].length];
  1424. for (int i = 0; i < temp_LinePort.length; i++) {
  1425. InputLinePoint[i] = temp_LinePort[i].clone();
  1426. }
  1427. }
  1428. count = Count;
  1429. colorKind = ColorKind;
  1430. buildPoints();
  1431. invalidate();
  1432. }
  1433. }
  1434. /**
  1435. * 누적사용량 그래프 그리기
  1436. **/
  1437. public class DrawRect extends View {
  1438. Paint mLinePaint;
  1439. boolean init_flag = false;
  1440. //1280*800 : x: 829,y: 257
  1441. private int X_Base = 650 + 13;
  1442. private int Y_Base = 184 + 36;
  1443. int Y_Coordinate;
  1444. int RectHeight; //그래프의 높이
  1445. int Index;
  1446. int Size;
  1447. int EnergyCount;
  1448. /**
  1449. * @param index <br>
  1450. * 1-전기의 우리집 사용량, 2-전기의 동평형 사용량 <br>
  1451. * 3-난방의 우리집 사용량, 4-난방의 동평형 사용량 <br>
  1452. * 5-온수의 우리집 사용량, 6-온수의 동평형 사용량 <br>
  1453. * 7-가스의 우리집 사용량, 8-가스의 동평형 사용량 <br>
  1454. * 9-수도의 우리집 사용량, 10-수도의 동평형 사용량 <br>
  1455. * 11-탄소의 우리집 사용량, 12-탄소의 동평형 사용량 <br>
  1456. * @param size 막대 그래프의 가로 길이
  1457. **/
  1458. public DrawRect(Context context, int index, int size, int energyCount) {
  1459. super(context);
  1460. Index = index;
  1461. Size = size;
  1462. EnergyCount = energyCount;
  1463. if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
  1464. X_Base = 829;
  1465. Y_Base = 257;
  1466. }
  1467. }
  1468. @Override
  1469. protected void onDraw(Canvas canvas) {
  1470. super.onDraw(canvas);
  1471. if (init_flag == false) {
  1472. init_flag = true;
  1473. mLinePaint = new Paint(); //Paint: 붓
  1474. mLinePaint.setAntiAlias(true); //경계면을 부드럽게 처리
  1475. /*
  1476. *
  1477. 99d300(전기)
  1478. 26b6b4(난방)
  1479. 3588d5(온수)
  1480. 6c44a3(가스)
  1481. a55f7f(수도)
  1482. d4b96f(탄소)
  1483. 동평형(#4b4b4b)
  1484. *
  1485. * */
  1486. mLinePaint.setStyle(Paint.Style.FILL); //FILL: 색상이 채워지고 테두리는 그려지지 않음
  1487. }
  1488. switch (Index) {
  1489. case 1://전기
  1490. mLinePaint.setColor(Color.parseColor("#99d300"));
  1491. if (EnergyCount >= 5) {
  1492. Y_Coordinate = 0;
  1493. } else if (EnergyCount == 3) {
  1494. Y_Coordinate = 86;
  1495. }
  1496. RectHeight = 26;
  1497. if (EnergyCount == 6) {
  1498. RectHeight = RectHeight;
  1499. }
  1500. break;
  1501. case 2:
  1502. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1503. if (EnergyCount >= 5) {
  1504. Y_Coordinate = 28;
  1505. } else if (EnergyCount == 3) {
  1506. Y_Coordinate = 28 + (86);
  1507. }
  1508. RectHeight = 12;
  1509. if (EnergyCount == 6) {
  1510. RectHeight = RectHeight;
  1511. }
  1512. break;
  1513. case 3://난방
  1514. mLinePaint.setColor(Color.parseColor("#26b6b4"));
  1515. //5개 or 6개 일때만
  1516. if (EnergyCount == 6) {
  1517. Y_Coordinate = (71);
  1518. } else {
  1519. // EnergyCount == 5
  1520. Y_Coordinate = (86);
  1521. }
  1522. RectHeight = 26;
  1523. if (EnergyCount == 6) {
  1524. // RectHeight = RectHeight - 1;
  1525. }
  1526. break;
  1527. case 4:
  1528. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1529. if (EnergyCount == 6) {
  1530. Y_Coordinate = (71 + 28);
  1531. } else {
  1532. Y_Coordinate = (86 + 28);
  1533. }
  1534. RectHeight = 12;
  1535. if (EnergyCount == 6) {
  1536. // RectHeight = RectHeight - 1;
  1537. }
  1538. break;
  1539. case 5://온수
  1540. mLinePaint.setColor(Color.parseColor("#3588d5"));
  1541. if (EnergyCount == 5) {
  1542. Y_Coordinate = (86 * 2);
  1543. } else if (EnergyCount == 3) {
  1544. Y_Coordinate = (332 - Y_Base);
  1545. } else if (EnergyCount == 6) {
  1546. Y_Coordinate = (71 * 2);
  1547. }
  1548. RectHeight = 26;
  1549. if (EnergyCount == 6) {
  1550. // RectHeight = RectHeight - 1;
  1551. }
  1552. break;
  1553. case 6:
  1554. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1555. if (EnergyCount == 5) {
  1556. Y_Coordinate = ((86 * 2) + (28));
  1557. } else if (EnergyCount == 3) {
  1558. Y_Coordinate = (332 - Y_Base) + 26;
  1559. } else if (EnergyCount == 6) {
  1560. Y_Coordinate = ((71 * 2) + (28));
  1561. }
  1562. RectHeight = 12;
  1563. if (EnergyCount == 6) {
  1564. // Y_Coordinate = Y_Coordinate + 2;
  1565. }
  1566. break;
  1567. case 7://연료전지
  1568. mLinePaint.setColor(Color.parseColor("#3588d5"));
  1569. if (EnergyCount == 6) {
  1570. Y_Coordinate = (71 * 3);
  1571. } else if (EnergyCount == 3) {
  1572. Y_Coordinate = (258);
  1573. } else {
  1574. Y_Coordinate = (86 * 3);
  1575. }
  1576. RectHeight = 26;
  1577. if (EnergyCount == 6) {
  1578. // RectHeight = RectHeight - 1;
  1579. }
  1580. break;
  1581. case 8:
  1582. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1583. if (EnergyCount == 6) {
  1584. Y_Coordinate = ((71 * 3) + (28));
  1585. } else if (EnergyCount == 3) {
  1586. Y_Coordinate = ((258) + (28));
  1587. } else {
  1588. Y_Coordinate = ((86 * 3) + (28));
  1589. }
  1590. RectHeight = 12;
  1591. if (EnergyCount == 6) {
  1592. // RectHeight = RectHeight - 1;
  1593. // Y_Coordinate = Y_Coordinate + 1;
  1594. }
  1595. break;
  1596. case 9://연료전지
  1597. mLinePaint.setColor(Color.parseColor("#99d300"));
  1598. if (EnergyCount == 5) {
  1599. Y_Coordinate = (86 * 4);
  1600. } else if (EnergyCount == 3) {
  1601. Y_Coordinate = (107);
  1602. } else if (EnergyCount == 6) {
  1603. Y_Coordinate = (71 * 4);
  1604. }
  1605. RectHeight = 26;
  1606. if (EnergyCount == 6) {
  1607. // RectHeight = RectHeight - 1;
  1608. }
  1609. break;
  1610. case 10:
  1611. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1612. if (EnergyCount == 5) {
  1613. Y_Coordinate = ((86 * 4) + (28));
  1614. } else if (EnergyCount == 3) {
  1615. Y_Coordinate = (172) + 28;
  1616. } else if (EnergyCount == 6) {
  1617. Y_Coordinate = ((71 * 4) + (28));
  1618. }
  1619. RectHeight = 12;
  1620. if (EnergyCount == 6) {
  1621. // RectHeight = RectHeight - 1;
  1622. }
  1623. break;
  1624. case 11://탄소
  1625. mLinePaint.setColor(Color.parseColor("#d4b96f"));
  1626. Y_Coordinate = (71 * 5);
  1627. RectHeight = 26;
  1628. if (EnergyCount == 6) {
  1629. // RectHeight = RectHeight - 1;
  1630. }
  1631. break;
  1632. case 12:
  1633. mLinePaint.setColor(Color.parseColor("#4b4b4b"));
  1634. Y_Coordinate = ((71 * 5) + (28));
  1635. RectHeight = 12;
  1636. if (EnergyCount == 6) {
  1637. // RectHeight = RectHeight - 1;
  1638. }
  1639. break;
  1640. default:
  1641. break;
  1642. }
  1643. /*
  1644. DebugLogOutput("===============================");
  1645. DebugLogOutput("[drawRect] - X_Base :" +X_Base);
  1646. DebugLogOutput("[drawRect] - Y_Base :" +Y_Base);
  1647. DebugLogOutput("[drawRect] - Y_Coordinate :" +(Y_Coordinate));
  1648. DebugLogOutput("[drawRect] - Size :" +Size);
  1649. DebugLogOutput("[drawRect] - RectHeight :" +RectHeight);
  1650. DebugLogOutput("===============================");
  1651. */
  1652. int x_1280 = 0;
  1653. int y_800 = 0;
  1654. canvas = getPos.GetScaleCanvas(canvas);
  1655. y_800 = getPos.GetGraph_y_1280(EnergyCount, Index);
  1656. canvas.translate(Common.ImgPosion.GetX(X_Base + x_1280), Common.ImgPosion.GetY(Y_Base + (Y_Coordinate) + y_800));
  1657. //canvas.translate(WpadScale.getWidth(X_Base+x_1280), WpadScale.getHeight(Y_Base+(Y_Coordinate) + y_800));
  1658. canvas.drawRect(0, 0, (float) WpadScale.getWidth(Size), (float) WpadScale.getHeight(RectHeight), mLinePaint);
  1659. }
  1660. /**
  1661. * @param size
  1662. * @param energyCount
  1663. */
  1664. public void ReDraw(int size, int energyCount) {
  1665. Size = size;
  1666. EnergyCount = energyCount;
  1667. invalidate();
  1668. }
  1669. }
  1670. /**
  1671. * 검침기의 사용량을 표시한다.
  1672. *
  1673. * @param TextId - 변경할 대상 ID 를 입력한다. ( ID.realMain.text.ELEC ~ ID.realMain.text.CALORIE [ELEC or WATER or GAS or HOTWATER or CALORIE] )
  1674. * @param value - 변경할 값을 입력한다.
  1675. */
  1676. @SuppressLint("DefaultLocale")
  1677. private void Draw_TextValueWrite(int TextId, double value) {
  1678. String str = new String();
  1679. RealTimeData_Double = value;
  1680. if (RealTimeData == null) return;
  1681. switch (TextId) {
  1682. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  1683. case ID.IcEnergyMgrID.DataKind.KEPCO:
  1684. case ID.IcEnergyMgrID.DataKind.SOLAR:
  1685. case ID.IcEnergyMgrID.DataKind.FUEL:
  1686. if (RealtimeMeterUse == false) {
  1687. // 실시간 검침 사용하지 않음
  1688. str = Convter2_DoubleTOStr(value);
  1689. str += " kWh";
  1690. } else {
  1691. str = Convter1_DoubleTOStr(value);
  1692. str += " W";
  1693. }
  1694. RealTimeData.setText(str);
  1695. //DebugLogOutput("[Draw_TextValueWrite] - ELEC str = (" + str + ") " + "value = " + value);
  1696. break;
  1697. default:
  1698. Log.e(TAG, "[Draw_TextValueWrite] - TextId Out of range !!! (" + TextId + ")");
  1699. break;
  1700. }
  1701. }
  1702. /**
  1703. * 실시간 검침값 1가지 (ELEC) 에 대하여 <br>
  1704. * 소수점을 제거한다.
  1705. *
  1706. * @param value - 현재검침값
  1707. * @return (String) 포멧변환된 스트링
  1708. */
  1709. private String Convter1_DoubleTOStr(double value) {
  1710. if (value <= 0) return "0";
  1711. String str = new String();
  1712. try {
  1713. str = String.format("%.0f", value);
  1714. } catch (RuntimeException re) {
  1715. Log.e(TAG, "exception : " + re);
  1716. return "0";
  1717. } catch (Exception e) {
  1718. Log.e(TAG, "[Convter1_DoubleTOStr] - [Exception Error] ");
  1719. Log.e(TAG, "[Convter1_DoubleTOStr] - " + e.toString());
  1720. //e.printStackTrace();
  1721. LogUtil.errorLogInfo("", TAG, e);
  1722. return "0";
  1723. }
  1724. return str;
  1725. }
  1726. /**
  1727. * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
  1728. * 소수점 3자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
  1729. *
  1730. * @param value - 현재검침값
  1731. * @return (String) 포멧변환된 스트링
  1732. */
  1733. private String Convter2_DoubleTOStr(double value) {
  1734. if (value <= 0) return "0";
  1735. String str = new String();
  1736. try {
  1737. str = String.format("%.3f", value);
  1738. // 끝자리 0 자르기
  1739. byte[] strArray = str.getBytes();
  1740. for (int i = str.length() - 1; i >= 0; i--) {
  1741. if (strArray[i] == '0') {
  1742. str = str.substring(0, i);
  1743. } else break;
  1744. }
  1745. } catch (RuntimeException re) {
  1746. Log.e(TAG, "exception : " + re);
  1747. return "0";
  1748. } catch (Exception e) {
  1749. Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
  1750. Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
  1751. //e.printStackTrace();
  1752. LogUtil.errorLogInfo("", TAG, e);
  1753. return "0";
  1754. }
  1755. str.trim();
  1756. if (str.endsWith(".") == true) {
  1757. return str.substring(0, str.length() - 1);
  1758. }
  1759. return str;
  1760. }
  1761. /**
  1762. * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
  1763. * 소수점 1자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
  1764. *
  1765. * @param value - 현재검침값
  1766. * @return (String) 포멧변환된 스트링
  1767. */
  1768. private String Convter2_DoubleTOStr_CutPoint1(double value) {
  1769. if (value <= 0) return "0";
  1770. String str = new String();
  1771. try {
  1772. str = String.format("%.1f", value);
  1773. // 끝자리 0 자르기
  1774. byte[] strArray = str.getBytes();
  1775. for (int i = str.length() - 1; i >= 0; i--) {
  1776. if (strArray[i] == '0') {
  1777. str = str.substring(0, i);
  1778. } else break;
  1779. }
  1780. } catch (RuntimeException re) {
  1781. Log.e(TAG, "exception : " + re);
  1782. return "0";
  1783. } catch (Exception e) {
  1784. Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
  1785. Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
  1786. //e.printStackTrace();
  1787. LogUtil.errorLogInfo("", TAG, e);
  1788. return "0";
  1789. }
  1790. str.trim();
  1791. if (str.endsWith(".") == true) {
  1792. return str.substring(0, str.length() - 1);
  1793. }
  1794. return str;
  1795. }
  1796. /**
  1797. * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
  1798. * 소수점 2자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
  1799. *
  1800. * @param value - 현재검침값
  1801. * @return (String) 포멧변환된 스트링
  1802. */
  1803. private String Convter2_DoubleTOStr_CutPoint2(double value) {
  1804. if (value <= 0) return "0";
  1805. String str = new String();
  1806. try {
  1807. str = String.format("%.2f", value);
  1808. // 끝자리 0 자르기
  1809. byte[] strArray = str.getBytes();
  1810. for (int i = str.length() - 1; i >= 0; i--) {
  1811. if (strArray[i] == '0') {
  1812. str = str.substring(0, i);
  1813. } else break;
  1814. }
  1815. } catch (RuntimeException re) {
  1816. Log.e(TAG, "exception : " + re);
  1817. return "0";
  1818. } catch (Exception e) {
  1819. Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
  1820. Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
  1821. //e.printStackTrace();
  1822. LogUtil.errorLogInfo("", TAG, e);
  1823. return "0";
  1824. }
  1825. str.trim();
  1826. if (str.endsWith(".") == true) {
  1827. return str.substring(0, str.length() - 1);
  1828. }
  1829. return str;
  1830. }
  1831. /* // =================================================================================================
  1832. // [[ TimeCheck ]] region
  1833. // =================================================================================================
  1834. @SuppressLint("HandlerLeak")
  1835. private Handler mTimeCheckHandler = new Handler()
  1836. {
  1837. @SuppressLint("HandlerLeak")
  1838. @Override
  1839. public void handleMessage(Message msg)
  1840. {
  1841. if(msg.what == 0)
  1842. {
  1843. mTimeCheckHandler.sendEmptyMessageDelayed(0, 1000*10); //10초 마다
  1844. nowCal = Calendar.getInstance();
  1845. *//*
  1846. DebugLogOutput("[TimeCheck] time is tick");
  1847. DebugLogOutput("[TimeCheck] nowCal.get(Calendar.DATE) :" + nowCal.get(Calendar.DATE) );
  1848. DebugLogOutput("[TimeCheck] DateCal.get(Calendar.DATE) :" + DateCal.get(Calendar.DATE) );
  1849. DebugLogOutput("[TimeCheck] Year.get(Calendar.DATE) :" + YearCal.get(Calendar.YEAR) );
  1850. DebugLogOutput("[TimeCheck] DateCal.get(Calendar.DATE) :" + DateCal.get(Calendar.DATE) );
  1851. *//*
  1852. if(nowCal.get(Calendar.DATE) != DateCal.get(Calendar.DATE))
  1853. {
  1854. DebugLogOutput("[TimeCheck] Date is changed");
  1855. Draw_Update();
  1856. if(RealtimeMeterUse == true)
  1857. {
  1858. RemoveUsedData();
  1859. ShowUsedDataGraph();
  1860. }
  1861. else
  1862. {
  1863. }
  1864. SendMSG_RandomCheckHandler();
  1865. DateCal = Calendar.getInstance();
  1866. HourCal = Calendar.getInstance();
  1867. MonthCal = Calendar.getInstance();
  1868. YearCal = Calendar.getInstance();
  1869. }
  1870. if(nowCal.get(Calendar.HOUR_OF_DAY) != HourCal.get(Calendar.HOUR_OF_DAY))
  1871. {
  1872. DebugLogOutput("[TimeCheck] Hour is changed");
  1873. Draw_Update();
  1874. if(RealtimeMeterUse == true)
  1875. {
  1876. RemoveUsedData();
  1877. ShowUsedDataGraph();
  1878. }
  1879. else
  1880. {
  1881. //ShowUsedDataGraph_DayVersion();
  1882. SendMSG_RandomCheckHandler_forDayData(); //현장에서 동시 다발적으로 메시지를 요청해서 수신 못하는 세대 있음
  1883. }
  1884. HourCal = Calendar.getInstance();
  1885. }
  1886. if(nowCal.get(Calendar.MONTH) != MonthCal.get(Calendar.MONTH))
  1887. {
  1888. DebugLogOutput("[TimeCheck] Month is changed");
  1889. MonthCal = Calendar.getInstance();
  1890. SendMSG_RandomCheckHandler();
  1891. }
  1892. if(nowCal.get(Calendar.YEAR) != YearCal.get(Calendar.YEAR))
  1893. {
  1894. DebugLogOutput("[TimeCheck] Year is changed");
  1895. YearCal = Calendar.getInstance();
  1896. SendMSG_RandomCheckHandler();
  1897. }
  1898. //수정필요
  1899. // 목표량값이 달라진 경우 갱신
  1900. if (OPERATION_MODE == Common.MODE_NOMAL)
  1901. {
  1902. WallpadStatusData StatusDBMGR = null;
  1903. try
  1904. {
  1905. StatusDBMGR = new WallpadStatusData(getContext());
  1906. boolean TargetValueChanged = false;
  1907. for (int i = 0; i < mNumberOfEnergy; i++)
  1908. {
  1909. if (monthTableClass[i] != null)
  1910. {
  1911. if (monthTableClass[i].Goal.equalsIgnoreCase(StatusDBMGR.GetRemoteMeteringTargetValue(i)) == false)
  1912. {
  1913. DebugLogOutput("[TimeCheck] GetRemoteMeteringTargetValue is changed");
  1914. DebugLogOutput("[TimeCheck] monthTableClass[" + i + "].Goal :" + monthTableClass[i].Goal);
  1915. DebugLogOutput("[TimeCheck] StatusDBMGR.GetRemoteMeteringTargetValue(" + i + ") :"
  1916. + StatusDBMGR.GetRemoteMeteringTargetValue(i));
  1917. TargetValueChanged = true;
  1918. monthTableClass[i].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(i);
  1919. }
  1920. }
  1921. }
  1922. StatusDBMGR.closeDB();
  1923. if (TargetValueChanged == true)
  1924. {
  1925. DebugLogOutput("[TimeCheck] ShowMonthGraph() is called");
  1926. ShowMonthGraph();
  1927. }
  1928. }
  1929. catch (RuntimeException re) {
  1930. Log.e(TAG, "exception : " + re );
  1931. }
  1932. catch (Exception e)
  1933. {
  1934. if (StatusDBMGR != null)
  1935. {
  1936. StatusDBMGR.closeDB();
  1937. }
  1938. e.printStackTrace();
  1939. }
  1940. }
  1941. }
  1942. }
  1943. };
  1944. boolean Flag_SendMSG_RandomCheckHandler = false;
  1945. private void SendMSG_RandomCheckHandler()
  1946. {
  1947. try
  1948. {
  1949. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  1950. if(DelayTime < 1)
  1951. {
  1952. return;
  1953. }
  1954. DebugLogOutput("[SendMSG_RandomCheckHandler] DelayTime : "+ DelayTime);
  1955. mRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  1956. Flag_SendMSG_RandomCheckHandler = true;
  1957. }
  1958. catch (RuntimeException re) {
  1959. Log.e(TAG, "exception : " + re );
  1960. }
  1961. catch (Exception e)
  1962. {
  1963. e.printStackTrace();
  1964. return;
  1965. }
  1966. }
  1967. @SuppressLint("HandlerLeak")
  1968. private Handler mRandomCheckHandler = new Handler()
  1969. {
  1970. @SuppressLint("HandlerLeak")
  1971. @Override
  1972. public void handleMessage(Message msg)
  1973. {
  1974. if(msg.what == 0)
  1975. {
  1976. Flag_SendMSG_RandomCheckHandler = false;
  1977. DebugLogOutput("[mRandomCheckHandler] ShowMonthGraph() will be called");
  1978. ShowMonthGraph();
  1979. }
  1980. }
  1981. };
  1982. */
  1983. /**
  1984. * ==================================================
  1985. **//*
  1986. boolean Flag_SendMSG_RandomCheckHandler_forDayData = false;
  1987. private void SendMSG_RandomCheckHandler_forDayData()
  1988. {
  1989. try
  1990. {
  1991. int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
  1992. if(DelayTime < 1)
  1993. {
  1994. return;
  1995. }
  1996. DebugLogOutput("[SendMSG_RandomCheckHandler_forDayData] DelayTime : "+ DelayTime);
  1997. mRandomCheckHandler_forDayData.sendEmptyMessageDelayed(0, 1000 * DelayTime);
  1998. Flag_SendMSG_RandomCheckHandler_forDayData = true;
  1999. }
  2000. catch (RuntimeException re) {
  2001. Log.e(TAG, "exception : " + re );
  2002. }
  2003. catch (Exception e)
  2004. {
  2005. e.printStackTrace();
  2006. return;
  2007. }
  2008. }
  2009. @SuppressLint("HandlerLeak")
  2010. private Handler mRandomCheckHandler_forDayData = new Handler()
  2011. {
  2012. @SuppressLint("HandlerLeak")
  2013. @Override
  2014. public void handleMessage(Message msg)
  2015. {
  2016. if(msg.what == 0)
  2017. {
  2018. Flag_SendMSG_RandomCheckHandler_forDayData = false;
  2019. DebugLogOutput("[mRandomCheckHandler_forDayData] ShowUsedDataGraph_DayVersion() will be called");
  2020. ShowUsedDataGraph_DayVersion();
  2021. }
  2022. }
  2023. };*/
  2024. // =================================================================================================
  2025. // [[ Sample ]] region
  2026. // =================================================================================================
  2027. private double[] SampleArrayElec;
  2028. private double[] SampleArrayWater;
  2029. private double[] SampleArrayGas;
  2030. private double[] SampleArrayHotWater;
  2031. private double[] SampleArrayCalorie;
  2032. private int SampleCountElec;
  2033. private int SampleCountWater;
  2034. private int SampleCountGas;
  2035. private int SampleCountHotWater;
  2036. private int SampleCountCalorie;
  2037. /**
  2038. * (영업샘플모드) 실시간검침기 데이터를 변경한다.
  2039. */
  2040. @SuppressLint("HandlerLeak")
  2041. private Handler mSampleHandler = new Handler() {
  2042. @SuppressLint("HandlerLeak")
  2043. @Override
  2044. public void handleMessage(Message msg) {
  2045. if (msg.what == 0) {
  2046. switch (NowShowEnergyKind) {
  2047. case ID.IcEnergyMgrID.DataKind.ELECTRIC:
  2048. if (SampleArrayElec != null) {
  2049. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.ELECTRIC, SampleArrayElec[SampleCountElec]);
  2050. if (++SampleCountElec >= SampleArrayElec.length) SampleCountElec = 0;
  2051. }
  2052. break;
  2053. case ID.IcEnergyMgrID.DataKind.WATER:
  2054. if (SampleArrayWater != null) {
  2055. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.WATER, SampleArrayWater[SampleCountWater]);
  2056. if (++SampleCountWater >= SampleArrayWater.length) SampleCountWater = 0;
  2057. }
  2058. break;
  2059. case ID.IcEnergyMgrID.DataKind.GAS:
  2060. if (SampleArrayGas != null) {
  2061. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.GAS, SampleArrayGas[SampleCountGas]);
  2062. if (++SampleCountGas >= SampleArrayGas.length) SampleCountGas = 0;
  2063. }
  2064. break;
  2065. case ID.IcEnergyMgrID.DataKind.HOTWATER:
  2066. if (SampleArrayHotWater != null) {
  2067. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HOTWATER, SampleArrayHotWater[SampleCountHotWater]);
  2068. if (++SampleCountHotWater >= SampleArrayHotWater.length)
  2069. SampleCountHotWater = 0;
  2070. }
  2071. break;
  2072. case ID.IcEnergyMgrID.DataKind.HEATING:
  2073. if (SampleArrayCalorie != null) {
  2074. Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HEATING, SampleArrayCalorie[SampleCountCalorie]);
  2075. if (++SampleCountCalorie >= SampleArrayCalorie.length)
  2076. SampleCountCalorie = 0;
  2077. }
  2078. break;
  2079. default:
  2080. break;
  2081. }
  2082. ReDraw();
  2083. mSampleHandler.sendEmptyMessageDelayed(0, 5000);
  2084. }
  2085. }
  2086. };
  2087. /**
  2088. * (영업샘플모드) 실시간검침기 데이터를 변경을 시작한다.
  2089. */
  2090. private void Sample_Start() {
  2091. if (OPERATION_MODE != Common.MODE_BUSINESS_SAMPLE) return;
  2092. SampleArrayElec = new double[]{1320.23, 2405.867, 3090, 1560, 101, 90.98};
  2093. SampleArrayWater = new double[]{0.101, 1.121, 0.5, 0.8, 1.22, 1.53};
  2094. SampleArrayGas = new double[]{2.2, 0.7, 1.4, 3.0, 1.1, 2.6};
  2095. SampleArrayHotWater = new double[]{0.101, 1.121, 0.5, 0.8, 1.22, 1.53};
  2096. SampleArrayCalorie = new double[]{0, 0.3, 0.55, 1.0, 2.333};
  2097. SampleCountElec = 0;
  2098. SampleCountWater = 0;
  2099. SampleCountGas = 0;
  2100. SampleCountHotWater = 0;
  2101. SampleCountCalorie = 0;
  2102. if (mSampleHandler != null) mSampleHandler.sendEmptyMessage(0);
  2103. ShowUsedDataGraph();
  2104. }
  2105. /**
  2106. * (영업샘플모드) 실시간검침기 데이터를 변경을 중지한다.
  2107. */
  2108. private void Sample_End() {
  2109. if (OPERATION_MODE != Common.MODE_BUSINESS_SAMPLE) return;
  2110. if (mSampleHandler != null) mSampleHandler.removeMessages(0);
  2111. }
  2112. // =================================================================================================
  2113. // [[ Device ]] region
  2114. // =================================================================================================
  2115. /**
  2116. * 디바이스 API 를 Load 한다.
  2117. *
  2118. * @param wpapi - 생성시 전달받은 WallPadAPI
  2119. * @return (int) - >=0 : 성공, <0 : 실패
  2120. */
  2121. private int Device_ApiLoad(WallPadAPI wpapi) {
  2122. // 1. Mode Check
  2123. if (OPERATION_MODE != Common.MODE_NOMAL) return -1;
  2124. DebugLogOutput("[Device_ApiLoad] - Start");
  2125. // 2. wpapi Check
  2126. if (wpapi == null) {
  2127. Log.e(TAG, "[Device_ApiLoad] - wpapi is null");
  2128. return -2;
  2129. }
  2130. // 3. Load API
  2131. DebugLogOutput("[Device_ApiLoad] - Step1 : RemoteMeter API Load...");
  2132. try {
  2133. realTimeMeterAPI = wpapi.Get_RealTimeMeterController();
  2134. } catch (RuntimeException re) {
  2135. Log.e(TAG, "exception : " + re);
  2136. return -100;
  2137. } catch (Exception e) {
  2138. Log.e(TAG, "[Device_ApiLoad] - [Exception Error] wpapi.Get_RealTimeMeterController");
  2139. //e.printStackTrace();
  2140. LogUtil.errorLogInfo("", TAG, e);
  2141. return -100;
  2142. }
  2143. if (realTimeMeterAPI == null) {
  2144. Log.e(TAG, "[Device_ApiLoad] - realTimeMeterAPI is null");
  2145. return -4;
  2146. }
  2147. DebugLogOutput("[Device_ApiLoad] - OK");
  2148. return 0;
  2149. }
  2150. /**
  2151. * 제어기 상태를 가져온다.
  2152. *
  2153. * @param real - (boolean) true : 실시간 , false : 가장최근
  2154. * @return (int) - >=0 : 성공, <0 : 실패
  2155. */
  2156. @SuppressWarnings("unused")
  2157. private int Device_Update(boolean real) {
  2158. //DebugLogOutput("[Device_Update] - Start (real : " + real + ")");
  2159. // 1. Api Load Check
  2160. if (realTimeMeterAPI == null) {
  2161. Log.e(TAG, "[Device_Update] - remoteMeterApi unload !!!");
  2162. return -1;
  2163. }
  2164. // 2. reflash
  2165. try {
  2166. int ret = realTimeMeterAPI.Refresh(real);
  2167. if (ret < 0) {
  2168. Log.e(TAG, "[Device_Update] - realTimeMeterAPI.Refresh - ret (" + ret + ")" + realTimeMeterAPI.ErrorCode.ErrStr());
  2169. return -2;
  2170. }
  2171. } catch (RuntimeException re) {
  2172. Log.e(TAG, "exception : " + re);
  2173. return -100;
  2174. } catch (Exception e) {
  2175. Log.e(TAG, "[Device_Update] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
  2176. //e.printStackTrace();
  2177. LogUtil.errorLogInfo("", TAG, e);
  2178. return -100;
  2179. }
  2180. // 3. Range Check
  2181. if (realTimeMeterAPI.data == null) {
  2182. Log.e(TAG, "[Device_Update] - realTimeMeterAPI.data is null !!!");
  2183. return -9;
  2184. }
  2185. if (realTimeMeterAPI.data.Elec.Now >= 1000000) {
  2186. Log.e(TAG, "[Device_Update] - ElecNow data Out of range !!! (" + realTimeMeterAPI.data.Elec.Now + ")");
  2187. return -10;
  2188. }
  2189. if (realTimeMeterAPI.data.Water.Now >= 1000) {
  2190. Log.e(TAG, "[Device_Update] - WaterNow data Out of range !!! (" + realTimeMeterAPI.data.Water.Now + ")");
  2191. return -11;
  2192. }
  2193. if (realTimeMeterAPI.data.HotWater.Now >= 1000) {
  2194. Log.e(TAG, "[Device_Update] - HotWaterNow data Out of range !!! (" + realTimeMeterAPI.data.HotWater.Now + ")");
  2195. return -12;
  2196. }
  2197. if (realTimeMeterAPI.data.Gas.Now >= 1000) {
  2198. Log.e(TAG, "[Device_Update] - GasNow data Out of range !!! (" + realTimeMeterAPI.data.Gas.Now + ")");
  2199. return -13;
  2200. }
  2201. if (realTimeMeterAPI.data.Calorie.Now >= 1000) {
  2202. Log.e(TAG, "[Device_Update] - CaloryNow data Out of range !!! (" + realTimeMeterAPI.data.Calorie.Now + ")");
  2203. return -14;
  2204. }
  2205. // 4. Data Copy
  2206. data = realTimeMeterAPI.data;
  2207. // 5. Debug msg
  2208. if (DEBUG_REALMETER_DATA_LOG_ON == true) {
  2209. DebugLogOutput(data.ToDebugString());
  2210. DebugLogOutput("[Device_Update] - OK");
  2211. }
  2212. return 0;
  2213. }
  2214. /*
  2215. private boolean getCurrentDisplayEnergyScreen()
  2216. {
  2217. return ((MainActivity)(super.getContext())).CheckCurrentEnergyScreen();
  2218. }
  2219. */
  2220. /**
  2221. * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
  2222. * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
  2223. * 본 딜레이 코드를 임시로 적용한다.
  2224. */
  2225. @SuppressLint("HandlerLeak")
  2226. protected Handler mIntDriverCheckHandler = new Handler() {
  2227. @SuppressLint("HandlerLeak")
  2228. @Override
  2229. public void handleMessage(Message msg) {
  2230. if (msg.what == 0) {
  2231. //Log.d(TAG, "-------------- " + getCurrentDisplayEnergyScreen() );
  2232. if (Device_ApiLoad(m_wpapi) >= 0) {
  2233. if (Device_Update(false) == 0) {
  2234. mIntDriverCheckHandler.sendEmptyMessageDelayed(1, 10);
  2235. } else {
  2236. mIntDriverCheckHandler.sendEmptyMessageDelayed(0, 10000);
  2237. }
  2238. } else {
  2239. DebugLogOutput("mInitDriverCheckHandler --> m_InitRealMeterCtrl == null");
  2240. mIntDriverCheckHandler.sendEmptyMessageDelayed(0, 10000);
  2241. }
  2242. } else if (msg.what == 1) {
  2243. DebugLogOutput("mIntDriverCheckHandler == succes addBrActionName");
  2244. if (realTimeMeterAPI != null) {
  2245. Device_BrRegistration(true);
  2246. WallpadDeviceSet devset = new WallpadDeviceSet(getContext());
  2247. int[] setdata = devset.Get_RealTimeMetor_Info();
  2248. devset.closeDB();
  2249. if ((mThread_saveRealMeterData == null) && (setdata[0] == 1)) {
  2250. mThread_saveRealMeterData = new SaveRealMeterData();
  2251. mThread_saveRealMeterData.start();
  2252. }
  2253. RemoveUsedData();
  2254. ShowUsedDataGraph();
  2255. }
  2256. }
  2257. }
  2258. };
  2259. /**
  2260. * 디바이스에 알림 BR 을 등록한다. (에너지미터)
  2261. *
  2262. * @return (int) - >=0 : 성공, <0 : 실패
  2263. */
  2264. private int Device_BrRegistration(boolean OnOff) {
  2265. DebugLogOutput("[Device_BrRegistration] - Start (OnOff:" + OnOff + ")");
  2266. String BR_NAME = ID.IcEnergyMgrID.BR_REALMETER;
  2267. // 1. Api Load Check
  2268. if (realTimeMeterAPI == null) {
  2269. Log.e(TAG, "[Device_BrRegistration] - remoteMeterApi unload !!!");
  2270. return -1;
  2271. }
  2272. if (OnOff) {
  2273. try {
  2274. //DebugLogOutput("[Device_BrRegistration] - regChangedBR START");
  2275. realTimeMeterAPI.regChangedBR(BR_NAME);
  2276. //DebugLogOutput("[Device_BrRegistration] - regChangedBR END");
  2277. } catch (RuntimeException re) {
  2278. Log.e(TAG, "exception : " + re);
  2279. return -101;
  2280. } catch (Exception e) {
  2281. Log.e(TAG, "[Device_BrRegistration] - [Exception Error] realTimeMeterAPI.regChangedBR");
  2282. Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
  2283. //e.printStackTrace();
  2284. LogUtil.errorLogInfo("", TAG, e);
  2285. return -101;
  2286. }
  2287. super.addBrActionFilter(BR_NAME);
  2288. } else {
  2289. try {
  2290. //DebugLogOutput("[Device_BrRegistration] - unregChangedBR START");
  2291. realTimeMeterAPI.unregChangedBR(BR_NAME);
  2292. //DebugLogOutput("[Device_BrRegistration] - unregChangedBR END");
  2293. } catch (RuntimeException re) {
  2294. Log.e(TAG, "exception : " + re);
  2295. return -102;
  2296. } catch (Exception e) {
  2297. Log.e(TAG, "[Device_BrRegistration] - [Exception Error] realTimeMeterAPI.unregChangedBR");
  2298. Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
  2299. //e.printStackTrace();
  2300. LogUtil.errorLogInfo("", TAG, e);
  2301. return -102;
  2302. }
  2303. super.removeBrActionFilter(BR_NAME);
  2304. }
  2305. return 0;
  2306. }
  2307. // =================================================================================================
  2308. // [[ Thread ]] region
  2309. // =================================================================================================
  2310. /**
  2311. * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
  2312. * 10분에 한번씩 저장
  2313. */
  2314. @SuppressLint("UseValueOf")
  2315. class SaveRealMeterData extends Thread {
  2316. @Override
  2317. public void run() {
  2318. super.run();
  2319. DebugLogOutput("SaveRealMeterData extends Thread is started");
  2320. int ret;
  2321. wallpaddbmgr WallpadDBMGRforThread = null;
  2322. while (true) {
  2323. try {
  2324. Thread.sleep(1000 * 60 * 3); //3분마다
  2325. if (realTimeMeterAPI != null) {
  2326. ret = realTimeMeterAPI.Refresh(false);
  2327. if (ret == 0) {
  2328. DebugLogOutput("remoteMeterAPI.Refresh is success");
  2329. DebugLogOutput("remoteMeterAPI.ElecAccrued :" + realTimeMeterAPI.data.Elec.Acc);
  2330. WallpadDBMGRforThread = new wallpaddbmgr(getContext());
  2331. WallpadDBMGRforThread.InsertRealTimeMeterData(
  2332. new Double(realTimeMeterAPI.data.Elec.Now).toString(),
  2333. new Double(realTimeMeterAPI.data.Elec.Acc).toString(),
  2334. new Double(realTimeMeterAPI.data.Water.Now).toString(),
  2335. new Double(realTimeMeterAPI.data.Water.Acc).toString(),
  2336. new Double(realTimeMeterAPI.data.Gas.Now).toString(),
  2337. new Double(realTimeMeterAPI.data.Gas.Acc).toString(),
  2338. new Double(realTimeMeterAPI.data.HotWater.Now).toString(),
  2339. new Double(realTimeMeterAPI.data.HotWater.Acc).toString(),
  2340. new Double(realTimeMeterAPI.data.Calorie.Now).toString(),
  2341. new Double(realTimeMeterAPI.data.Calorie.Acc).toString()
  2342. );
  2343. int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
  2344. DebugLogOutput("WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
  2345. if (tempInt > 6000) {
  2346. WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
  2347. }
  2348. WallpadDBMGRforThread.closeDB();
  2349. } else {
  2350. DebugLogOutput("remoteMeterAPI.Refresh is fail");
  2351. }
  2352. } else {
  2353. DebugLogOutput("remoteMeterApi is null");
  2354. }
  2355. } catch (InterruptedException e1) {
  2356. // TODO Auto-generated catch block
  2357. if (WallpadDBMGRforThread != null) {
  2358. WallpadDBMGRforThread.closeDB();
  2359. }
  2360. DebugLogOutput("SaveRealMeterData extends Thread occurs exception Error");
  2361. e1.printStackTrace();
  2362. }
  2363. }
  2364. }
  2365. }
  2366. iMAPRemotemeter imapRemotemeter;
  2367. boolean isResponseArrive = false;
  2368. boolean mEMS_Enable;
  2369. int mNumberOfEnergy;
  2370. int CalendarYear;
  2371. int CalendarMonth;
  2372. int CalendarDay;
  2373. int ShowNowEnergyIndex = 0;
  2374. MonthTableClass monthTableClass[] = new MonthTableClass[3];
  2375. class MonthTableClass {
  2376. private String Use;
  2377. public MonthTableClass(String Use) {
  2378. this.Use = Use;
  2379. }
  2380. public String getUse() {
  2381. return Use;
  2382. }
  2383. }
  2384. private int CalcGraphWidth(String use, String Goal) {
  2385. try {
  2386. if (use.equals("") == true) {
  2387. return 0;
  2388. }
  2389. int x = (int) (Float.valueOf(use) * 260 / Float.valueOf(Goal)); //275:216 = 332:260 이전버전과 신버전 비율비교로 260계산
  2390. if (x > 332) {
  2391. return 332; //그래프 최대 길이
  2392. }
  2393. return x;
  2394. } catch (RuntimeException re) {
  2395. Log.e(TAG, "exception : " + re);
  2396. return 0;
  2397. } catch (Exception e) {
  2398. ////e.printStackTrace();
  2399. LogUtil.errorLogInfo("", TAG, e);
  2400. return 0;
  2401. }
  2402. }
  2403. private String NumberToKoreanWon(String Input) {
  2404. String tempString = "요금 정보 없음";
  2405. int tempInt = 0;
  2406. if (Input == null) {
  2407. return tempString;
  2408. }
  2409. if (Input.equals("") == true) {
  2410. return tempString;
  2411. }
  2412. if (Input.length() == 0) {
  2413. return tempString;
  2414. }
  2415. try {
  2416. tempInt = Integer.parseInt(Input);
  2417. } catch (RuntimeException re) {
  2418. Log.e(TAG, "exception : " + re);
  2419. return tempString;
  2420. } catch (Exception e) {
  2421. //e.printStackTrace();
  2422. LogUtil.errorLogInfo("", TAG, e);
  2423. return tempString;
  2424. }
  2425. tempString = String.format("%,d", tempInt);
  2426. return (tempString + "원");
  2427. }
  2428. private void DrawGraph_andValues(int EnergyCount) {
  2429. DebugLogOutput("DrawGraph_andValues");
  2430. try {
  2431. if (TempEnergyCount != EnergyCount) {
  2432. if (TempEnergyCount == 3) {
  2433. if (getLayout() != null) getLayout().removeView(Background_03);
  2434. Background_03 = new WpadImageView(getContext(), TOUCH_KIND.NONE, getPos.Get(R.drawable.man_energy_bgr_accumulate_graph_3).width, getPos.Get(R.drawable.man_energy_bgr_accumulate_graph_3).height, R.drawable.man_energy_bgr_accumulate_graph_3, 0, ID.IcEnergyMgrID.image.BACKGROUND);
  2435. ViewRegistration(getLayout(), Background_03, getPos.Get(R.drawable.man_energy_bgr_accumulate_graph_3).x, getPos.Get(R.drawable.man_energy_bgr_accumulate_graph_3).y);
  2436. //한전
  2437. if (getLayout() != null) getLayout().removeView(Kepco_HomeUse);
  2438. if (getLayout() != null) getLayout().removeView(drawRect[1]);
  2439. if (getLayout() != null) getLayout().removeView(drawRect[2]);
  2440. Kepco_HomeUse = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE).width, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE).height, Gravity.LEFT, Color.parseColor("#549da6"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE);
  2441. ViewRegistration(getLayout(), Kepco_HomeUse, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE).x, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE).y);
  2442. Kepco_HomeUse.setVisibility(View.GONE);
  2443. if (getLayout() != null) getLayout().addView(drawRect[1]);
  2444. if (getLayout() != null) getLayout().addView(drawRect[2]);
  2445. //연료전지
  2446. if (getLayout() != null) getLayout().removeView(Fuel_HomeUse);
  2447. if (getLayout() != null) getLayout().removeView(drawRect[9]);
  2448. if (getLayout() != null) getLayout().removeView(drawRect[10]);
  2449. Fuel_HomeUse = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE).width, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE).height, Gravity.LEFT, Color.parseColor("#7cac64"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE);
  2450. ViewRegistration(getLayout(), Fuel_HomeUse, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE).x, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE).y);
  2451. if (getLayout() != null) getLayout().addView(drawRect[9]);
  2452. if (getLayout() != null) getLayout().addView(drawRect[10]);
  2453. //태양광
  2454. if (getLayout() != null) getLayout().removeView(Photovoltaics_HomeUse);
  2455. if (getLayout() != null) getLayout().removeView(drawRect[7]);
  2456. if (getLayout() != null) getLayout().removeView(drawRect[8]);
  2457. Photovoltaics_HomeUse = new WpadTextView(getContext(), false, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE).width, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE).height, Gravity.LEFT, Color.parseColor("#c885a4"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE);
  2458. ViewRegistration(getLayout(), Photovoltaics_HomeUse, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE).x, getPos.Get(ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE).y);
  2459. if (getLayout() != null) getLayout().addView(drawRect[7]);
  2460. if (getLayout() != null) getLayout().addView(drawRect[8]);
  2461. }
  2462. TempEnergyCount = EnergyCount;
  2463. }
  2464. if (OPERATION_MODE == Common.MODE_NOMAL) {
  2465. //WallpadMain으로 검침 및 목표량 정보 intent로 보내기
  2466. Intent intent = new Intent();
  2467. intent.setAction("WALLPAD_NOTIFY");
  2468. intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
  2469. intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, EnergyCount);
  2470. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
  2471. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH) + 1));
  2472. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
  2473. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
  2474. intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
  2475. if (monthTableClass[0] != null) {
  2476. intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, monthTableClass[0].Use); //한전
  2477. }
  2478. if (monthTableClass[1] != null) {
  2479. intent.putExtra(Common.ENERGY_INTENT_USE_WATER, monthTableClass[1].Use); //태양광
  2480. }
  2481. if (monthTableClass[2] != null) {
  2482. intent.putExtra(Common.ENERGY_INTENT_USE_GAS, monthTableClass[2].Use); //연료전지
  2483. }
  2484. Log.i("HIGH", "ENERGY_INTENT_ BR Send " + define.NOTIFY_ENERGY_DATA);
  2485. getContext().sendBroadcast(intent);
  2486. }
  2487. DebugLogOutput("Draw Month Graph");
  2488. //Kepco_HomeUse.setText(monthTableClass[0].Use);
  2489. //목표량이 없으므로, Goal 값은 USE 값을 이용해서 구한다.
  2490. double goal = (double) (Double.valueOf(monthTableClass[1].Use)) + (Double.valueOf(monthTableClass[2].Use));
  2491. //drawRect[1].ReDraw(CalcGraphWidth(monthTableClass[0].Use, goal + ""), mNumberOfEnergy);
  2492. Photovoltaics_HomeUse.setText(monthTableClass[1].Use);
  2493. //goal = (double) (Double.valueOf(monthTableClass[1].Use) * 1.5);
  2494. drawRect[9].ReDraw(CalcGraphWidth(monthTableClass[1].Use, goal + ""), mNumberOfEnergy);
  2495. Fuel_HomeUse.setText(monthTableClass[2].Use);
  2496. //goal = (double) (Double.valueOf(monthTableClass[2].Use) * 1.2);
  2497. drawRect[7].ReDraw(CalcGraphWidth(monthTableClass[2].Use, goal + ""), mNumberOfEnergy);
  2498. //if (RealtimeMeterUse == false) {
  2499. // 실시간 검침 사용하지 않음
  2500. //ShowUsedDataGraph_DayVersion();
  2501. //}
  2502. } catch (RuntimeException re) {
  2503. Log.e(TAG, "exception : " + re);
  2504. } catch (Exception e) {
  2505. //e.printStackTrace();
  2506. LogUtil.errorLogInfo("", TAG, e);
  2507. }
  2508. }
  2509. /**
  2510. * @param InputType 0 당월, 1 일별<br>
  2511. * @param //year - 연도<br>
  2512. * @param //month - 월<br>
  2513. * @param //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
  2514. * @description 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
  2515. */
  2516. private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy) {
  2517. final int inputType = InputType;
  2518. final int year = Year;
  2519. final int month = (Month + 1);
  2520. try {
  2521. DebugLogOutput("LoadRemotemeterDataFromServer - " + year + " " + month);
  2522. isResponseArrive = false;
  2523. imapRemotemeter = new iMAPRemotemeter(getContext());
  2524. switch (inputType) {
  2525. case 0: //당월
  2526. //imapRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
  2527. imapRemotemeter.DoWorkVIP(true, true, false, true, true,true, year, month);
  2528. break;
  2529. case 1: //일별
  2530. //imapRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  2531. imapRemotemeter.DoWorkVIP(false, true, true, true, true, true, year, month);
  2532. break;
  2533. case 2: //Real Time
  2534. //imapRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
  2535. imapRemotemeter.DoWDoWorkVIP_RealTime(false, false, false, true, true);
  2536. break;
  2537. default:
  2538. break;
  2539. }
  2540. imapRemotemeter.SetRetCtr(new RetProci() {
  2541. @Override
  2542. public void ProcSuccess() {
  2543. String TempString = null;
  2544. isResponseArrive = true;
  2545. // DB
  2546. WallpadStatusData StatusDBMGR = null;
  2547. try {
  2548. StatusDBMGR = new WallpadStatusData(getContext());
  2549. DebugLogOutput("Load Data From Server - ProcSuccess");
  2550. DebugLogOutput("inputType " + Integer.toString(inputType));
  2551. boolean result = false;
  2552. switch (inputType) {
  2553. case 0: // 당월
  2554. EnergyDataGetCal = Calendar.getInstance();
  2555. int NumberOfValuelist = imapRemotemeter.SetItem("valuelist");
  2556. if (NumberOfValuelist != 0) {
  2557. for (int i = 0; i < NumberOfValuelist; i++) {
  2558. if ((Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
  2559. result = true;
  2560. int Temp_mNumberOfEnergy = mNumberOfEnergy;
  2561. if (Temp_mNumberOfEnergy == 2) {
  2562. Temp_mNumberOfEnergy = 3;
  2563. }
  2564. for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
  2565. switch (j) {
  2566. case 0:
  2567. monthTableClass[j] = new MonthTableClass("");
  2568. if (imapRemotemeter.GetAttributeVal(i, "kepco_used") != null) {
  2569. if (imapRemotemeter.GetAttributeVal(i, "kepco_used").equals("1000000") == true) {
  2570. monthTableClass[j].Use = "0";
  2571. } else {
  2572. monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "kepco_used");
  2573. }
  2574. }
  2575. break;
  2576. case 1:
  2577. monthTableClass[j] = new MonthTableClass("");
  2578. if (imapRemotemeter.GetAttributeVal(i, "photovoltaics_used") != null) {
  2579. if (imapRemotemeter.GetAttributeVal(i, "photovoltaics_used").equals("1000000") == true) {
  2580. monthTableClass[j].Use = "0";
  2581. } else {
  2582. monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "photovoltaics_used");
  2583. }
  2584. }
  2585. break;
  2586. case 2:
  2587. monthTableClass[j] = new MonthTableClass("");
  2588. if (imapRemotemeter.GetAttributeVal(i, "fuelcell_used") != null) {
  2589. if (imapRemotemeter.GetAttributeVal(i, "fuelcell_used").equals("1000000") == true) {
  2590. monthTableClass[j].Use = "0";
  2591. } else {
  2592. monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "fuelcell_used");
  2593. }
  2594. }
  2595. break;
  2596. default:
  2597. break;
  2598. }
  2599. }
  2600. }
  2601. }
  2602. if (result == true) {
  2603. switch (mNumberOfEnergy) {
  2604. case 2:
  2605. case 3:
  2606. case 5:
  2607. case 6:
  2608. DrawGraph_andValues(mNumberOfEnergy);
  2609. Intent intent = new Intent();
  2610. intent.setAction(define.NOTIFY_ACNAME);
  2611. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
  2612. intent.putExtra("FromWhere", "IcEnergyMgrScreen");
  2613. if ((mNumberOfEnergy == 2) || (mNumberOfEnergy == 3)) {
  2614. intent.putExtra("kepco_used", monthTableClass[0].Use);
  2615. intent.putExtra("photovoltaics_used", monthTableClass[1].Use);
  2616. intent.putExtra("fuelcell_used", monthTableClass[2].Use);
  2617. }
  2618. getContext().sendBroadcast(intent);
  2619. break;
  2620. default:
  2621. break;
  2622. }
  2623. }
  2624. }
  2625. break;
  2626. case 1: // 일별
  2627. int NumberOfValuelist1 = imapRemotemeter.SetItem("valuelist");
  2628. if (NumberOfValuelist1 != 0) {
  2629. DebugLogOutput("nowCal.get(Calendar.DATE):" + nowCal.get(Calendar.DATE));
  2630. if ((NumberOfValuelist1 + 1) == nowCal.get(Calendar.DATE)) {
  2631. isStartSaveData = true;
  2632. RecentDay = -1;
  2633. DebugLogOutput("if ((NumberOfValuelist1 + 1) == nowCal.get(Calendar.DATE))");
  2634. }
  2635. for (int i = 0; i < NumberOfValuelist1; i++) {
  2636. if ((Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "month")) == (month)) && (Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "year")) == (year))) {
  2637. int TempDay = Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "day"));
  2638. //DebugLogOutput("day " + TempDay);
  2639. float TempKepco = 0;
  2640. float TempSolar = 0;
  2641. float TempFuel = 0;
  2642. try {
  2643. // 한전
  2644. //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
  2645. //DebugLogOutput("TempString elect " + TempString);
  2646. //if (TempString!=null&&TempString.equals("1000000") == false) {
  2647. // TempKepco = Float.parseFloat(TempString);
  2648. //}
  2649. //DebugLogOutput("TempElect " + TempElect);
  2650. // 태양광
  2651. TempString = imapRemotemeter.GetAttributeVal(i, "photovoltaics_used");
  2652. //DebugLogOutput("TempString water " + TempString);
  2653. if (TempString.equals("1000000") == false) {
  2654. TempSolar = Float.parseFloat(TempString);
  2655. }
  2656. //DebugLogOutput("TempWater " + TempWater);
  2657. // 연료전지
  2658. TempString = imapRemotemeter.GetAttributeVal(i, "fuelcell_used");
  2659. //DebugLogOutput("TempString gas " + TempString);
  2660. if (TempString.equals("1000000") == false) {
  2661. TempFuel = Float.parseFloat(TempString);
  2662. }
  2663. } catch (RuntimeException re) {
  2664. Log.e(TAG, "exception : " + re);
  2665. } catch (Exception e) {
  2666. //e.printStackTrace();
  2667. LogUtil.errorLogInfo("", TAG, e);
  2668. }
  2669. arrayListDayEnergyData.add(new DayEnergyDataClass(CalendarYear, CalendarMonth + 1, TempDay, TempKepco, TempSolar, TempFuel));
  2670. }
  2671. }
  2672. TotalServerInquiryCount++;
  2673. if ((arrayListDayEnergyData.size() < 9)) {
  2674. // 데이터 요청 한번 더..
  2675. Calendar LastMonth = getMinusMonth(-1); // 전달 년도 월
  2676. // 가져오기.
  2677. int nYear = LastMonth.get(Calendar.YEAR);
  2678. int nMonth = LastMonth.get(Calendar.MONTH);
  2679. //DebugLogOutput("Inquiry to Server: " + nYear + " " + nMonth);
  2680. try {
  2681. Thread.sleep(1000);
  2682. } catch (InterruptedException e) {
  2683. // TODO Auto-generated catch block
  2684. //e.printStackTrace();
  2685. LogUtil.errorLogInfo("", TAG, e);
  2686. }
  2687. if (TotalServerInquiryCount < 2) {
  2688. LoadRemotemeterDataFromServer(1, nYear, nMonth, ShowNowEnergyIndex);
  2689. }
  2690. } else if (arrayListDayEnergyData.size() >= 9) {
  2691. // 관련 변수 초기화
  2692. RecentDay = 0;
  2693. isStartSaveData = false;
  2694. TotalServerInquiryCount = 0;
  2695. // show data
  2696. ShowDayGraph();
  2697. ReDraw();
  2698. }
  2699. }
  2700. break;
  2701. case 2: // realtime
  2702. float TempKepco = 0;
  2703. float TempSolar = 0;
  2704. float TempFuel = 0;
  2705. int photovoltaicsValue = imapRemotemeter.SetItem("photovoltaics");
  2706. if (photovoltaicsValue != 0) {
  2707. try {
  2708. // 한전
  2709. //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
  2710. //DebugLogOutput("TempString elect " + TempString);
  2711. //if (TempString!=null&&TempString.equals("1000000") == false) {
  2712. // TempKepco = Float.parseFloat(TempString);
  2713. //}
  2714. //DebugLogOutput("TempElect " + TempElect);
  2715. // 태양광
  2716. TempString = imapRemotemeter.GetItemVal(0);
  2717. TempSolar = Float.parseFloat(TempString);
  2718. } catch (RuntimeException re) {
  2719. Log.e(TAG, "exception : " + re);
  2720. } catch (Exception e) {
  2721. //e.printStackTrace();
  2722. LogUtil.errorLogInfo("", TAG, e);
  2723. }
  2724. }
  2725. int fuelcellValue = imapRemotemeter.SetItem("fuelcell");
  2726. if (fuelcellValue != 0) {
  2727. try {
  2728. // 한전
  2729. //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
  2730. //DebugLogOutput("TempString elect " + TempString);
  2731. //if (TempString!=null&&TempString.equals("1000000") == false) {
  2732. // TempKepco = Float.parseFloat(TempString);
  2733. //}
  2734. //DebugLogOutput("TempElect " + TempElect);
  2735. // 태양광
  2736. TempString = imapRemotemeter.GetItemVal(0);
  2737. TempFuel = Float.parseFloat(TempString);
  2738. } catch (RuntimeException re) {
  2739. Log.e(TAG, "exception : " + re);
  2740. } catch (Exception e) {
  2741. //e.printStackTrace();
  2742. LogUtil.errorLogInfo("", TAG, e);
  2743. }
  2744. }
  2745. realTimeEnergyData = new DayEnergyDataClass(0, 0, 0, 0, TempSolar, TempFuel);
  2746. Draw_Update();
  2747. break;
  2748. default:
  2749. break;
  2750. }
  2751. StatusDBMGR.closeDB();
  2752. } catch (
  2753. RuntimeException re) {
  2754. if (StatusDBMGR != null) {
  2755. StatusDBMGR.closeDB();
  2756. }
  2757. Log.e(TAG, "exception : " + re);
  2758. } catch (
  2759. Exception e) {
  2760. if (StatusDBMGR != null) {
  2761. StatusDBMGR.closeDB();
  2762. }
  2763. //e.printStackTrace();
  2764. LogUtil.errorLogInfo("", TAG, e);
  2765. }
  2766. }
  2767. @Override
  2768. public void ProcError() {
  2769. DebugLogOutput("Load Data From Server - ProcError");
  2770. isResponseArrive = true;
  2771. RecentDay = 0;
  2772. isStartSaveData = false;
  2773. TotalServerInquiryCount = 0;
  2774. }
  2775. @Override
  2776. public void ProcDoing() {
  2777. DebugLogOutput("Load Data From Server - ProcDoing");
  2778. }
  2779. });
  2780. } catch (
  2781. RuntimeException re) {
  2782. Log.e(TAG, "exception : " + re);
  2783. } catch (
  2784. Exception e) {
  2785. //e.printStackTrace();
  2786. LogUtil.errorLogInfo("", TAG, e);
  2787. }
  2788. }
  2789. public Calendar getMinusDate(int iDay) {
  2790. Calendar temp = Calendar.getInstance();
  2791. temp.add(Calendar.DAY_OF_MONTH, iDay);
  2792. return temp;
  2793. }
  2794. public Calendar getMinusMonth(int iMonth) {
  2795. Calendar temp = Calendar.getInstance();
  2796. temp.add(Calendar.MONTH, iMonth);
  2797. return temp;
  2798. }
  2799. public void SampleDatainsert_MonthTableData() {
  2800. WallpadStatusData StatusDBMGR = null;
  2801. StatusDBMGR = new WallpadStatusData(getContext());
  2802. monthTableClass[0] = new MonthTableClass("");
  2803. monthTableClass[0].Use = "280";
  2804. monthTableClass[1] = new MonthTableClass("");
  2805. monthTableClass[1].Use = "24";
  2806. monthTableClass[2] = new MonthTableClass("");
  2807. monthTableClass[2].Use = "6";
  2808. StatusDBMGR.closeDB();
  2809. DrawGraph_andValues(mNumberOfEnergy);
  2810. }
  2811. public void GetMeteringCount() {
  2812. WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
  2813. String[] MetringDB = devSet.GetSettingData("원격검침");
  2814. devSet.closeDB();
  2815. //for test
  2816. MetringDB = null;
  2817. //end test
  2818. if (MetringDB != null) {
  2819. try {
  2820. String devInfo = MetringDB[1];
  2821. devInfo = devInfo.replace('(', '_');
  2822. devInfo = devInfo.replace(':', '_');
  2823. devInfo = devInfo.replace(')', '_');
  2824. String[] MetringInfo = devInfo.split("_");
  2825. // MetringInfo[1] -> 회로수
  2826. // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
  2827. if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6)) {
  2828. mNumberOfEnergy = Integer.parseInt(MetringInfo[1]);
  2829. } else {
  2830. mNumberOfEnergy = 3;
  2831. }
  2832. if (MetringInfo[5].equals("사용함")) {
  2833. mEMS_Enable = true;
  2834. } else {
  2835. mEMS_Enable = false;
  2836. }
  2837. if (MetringInfo[7].equals("사용함")) {
  2838. mCostInfo_Enable = true;
  2839. } else {
  2840. mCostInfo_Enable = false;
  2841. }
  2842. } catch (RuntimeException re) {
  2843. Log.e(TAG, "exception : " + re);
  2844. mNumberOfEnergy = 5;
  2845. mEMS_Enable = true;
  2846. } catch (Exception e) {
  2847. //e.printStackTrace();
  2848. LogUtil.errorLogInfo("", TAG, e);
  2849. mNumberOfEnergy = 5;
  2850. mEMS_Enable = true;
  2851. }
  2852. } else {
  2853. mNumberOfEnergy = 3;
  2854. mEMS_Enable = true;
  2855. }
  2856. }
  2857. /***
  2858. * @description 서버연동 에너지 팝업 화면 시험을 위한 함수
  2859. */
  2860. public void TestEnergyAlarmPopup() {
  2861. DebugLogOutput("TestEnergyAlarmPopup()");
  2862. Intent intent = new Intent();
  2863. intent.setAction(define.NOTIFY_ACNAME);
  2864. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
  2865. intent.putExtra("elect_target", "300");
  2866. intent.putExtra("elect_used", "400");
  2867. intent.putExtra("elect_info", "over");
  2868. intent.putExtra("water_target", "300");
  2869. intent.putExtra("water_used", "150");
  2870. intent.putExtra("water_info", "reach");
  2871. intent.putExtra("gas_target", "300");
  2872. intent.putExtra("gas_used", "100");
  2873. intent.putExtra("gas_info", "reach");
  2874. intent.putExtra("heating_target", "300");
  2875. intent.putExtra("heating_used", "200");
  2876. intent.putExtra("heating_info", "reach");
  2877. intent.putExtra("hotwater_target", "300");
  2878. intent.putExtra("hotwater_used", "300");
  2879. intent.putExtra("hotwater_info", "reach");
  2880. this.getContext().sendBroadcast(intent);
  2881. }
  2882. }