12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491 |
- package kr.co.icontrols.wallpadenergyctrl.screen;
- import android.annotation.SuppressLint;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Canvas;
- import android.graphics.Color;
- import android.graphics.Matrix;
- import android.graphics.Paint;
- import android.graphics.Path;
- import android.os.Build;
- import android.os.Handler;
- import android.os.Message;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.RelativeLayout;
- import com.artncore.WallPadDataMgr.WallpadDeviceSet;
- import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.WallPadDataMgr.wallpaddbmgr;
- import com.artncore.commons.DataClasses;
- import com.artncore.commons.define;
- import com.artncore.wallpadapi.RealTimeMeterAPI;
- import com.artncore.wallpadapi.WallPadAPI;
- import com.artncore.wallpadimap.RetProci;
- import com.util.LogUtil;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- import kr.co.icontrols.wallpadenergyctrl.R;
- import kr.co.icontrols.wallpadenergyctrl.declare.Common;
- import kr.co.icontrols.wallpadenergyctrl.declare.ID;
- import kr.co.icontrols.wallpadenergyctrl.declare.LayoutDevice_hems;
- import kr.co.icontrols.wallpadenergyctrl.imap.iMAPRemotemeter;
- import kr.co.icontrols.wallpadsupport.WpadImageView;
- import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
- import kr.co.icontrols.wallpadsupport.WpadScale;
- import kr.co.icontrols.wallpadsupport.WpadScreen;
- import kr.co.icontrols.wallpadsupport.WpadSound;
- import kr.co.icontrols.wallpadsupport.WpadTextView;
- import static kr.co.icontrols.wallpadenergyctrl.declare.Common.SKIN_01;
- /**
- * Created by julia on 2018-01-08.
- */
- @SuppressLint("RtlHardcoded")
- public class VIPIcEnergyMgrScreen extends WpadScreen {
- String TAG = "VIPIcEnergyMgrScreen";
- private final boolean DEBUG_LOG_ON = true;
- private final boolean DEBUG_REALMETER_DATA_LOG_ON = false;
- private void DebugLogOutput(String s) {
- if (DEBUG_LOG_ON) Log.d(TAG, s);
- }
- //2015.03.24 Support API 변경으로 인한 폰트사이즈 재조정
- private final int ContentsFontSize = 16;
- private final int TitleFontSize = 18;
- // =================================================================================================
- // [[ Declaration ]] region
- // =================================================================================================
- // [API]
- private WallPadAPI m_wpapi = null;
- private RealTimeMeterAPI realTimeMeterAPI;
- // [View]
- WpadImageView Background;
- WpadImageView Background_02; //실시간 사용량
- WpadImageView Background_03; //그래프
- WpadImageView Background_04; //당월누적사용량
- WpadImageView Background_Title;
- WpadImageView Background_Title_Comment;
- WpadImageView m_ViewBottomMoveLeft, m_ViewBottomMoveHome, m_ViewBottomMoveRight;
- WpadImageView Btn_DetailView;
- WpadImageView Btn_Kepco, Btn_Solar, Btn_Fuel;
- WpadImageView m_LOGO = null;
- //WpadTextView Info_text;
- private String m_MainSkin = SKIN_01;
- // [공통 변수]
- private int OPERATION_MODE = -1;
- private boolean TempbSupportKind = true;
- private boolean APIInit = false;
- private boolean mCostInfo_Enable = false;
- // [Sample Data]
- //1. 전기
- private String[] SampleUsedData1 = new String[]{"15.1", "22.1", "33.1", "57", "76.2", "83.2", "95.6", "133.3", "212.2"};
- private String[] SampleUsedData2 = new String[]{"215.2", "223.2", "241.3", "260.6", "290.1", "330.3", "370.1", "400.4", "410.2"};
- //2. 난방 0 ~ 2.4
- private String[] SampleUsedData3 = new String[]{"3.1", "5.5", "14.2", "16.7", "20.2", "21.2", "22.6", "30.3", "36.2"};
- private String[] SampleUsedData4 = new String[]{"36.2", "44.2", "45.3", "48.6", "55.1", "56.3", "58.1", "62.4", "68.2"};
- //3. 온수 0 ~ 2.4
- private String[] SampleUsedData5 = new String[]{"5.1", "6.1", "8.1", "15.1", "18.2", "20.2", "20.6", "25.3", "28.2"};
- private String[] SampleUsedData6 = new String[]{"30.2", "30.3", "35.3", "36.6", "37.1", "38.3", "40.1", "46.4", "54.2"};
- //4. 수도 0 ~ 1.2
- private String[] SampleUsedData7 = new String[]{"1.1", "2.1", "5.1", "6.1", "7", "8.2", "10.6", "13.3", "13.6"};
- private String[] SampleUsedData8 = new String[]{"14.2", "15.2", "18.3", "20.6", "21.1", "22.3", "22.4", "26.4", "30.2"};
- //5. 가스 0 ~ 3.0
- private String[] SampleUsedData9 = new String[]{"7.1", "10.1", "20.1", "22", "23.2", "23.2", "25.6", "33.3", "35.2"};
- private String[] SampleUsedData10 = new String[]{"36.2", "37.2", "40.3", "41.6", "44.1", "45.3", "50.1", "55.4", "60.2"};
- //계기판 배경
- private int[] CircleGraph_bg = new int[]{
- R.drawable.bg_graph_power,
- R.drawable.bg_graph_heating,
- R.drawable.bg_graph_hot_water,
- R.drawable.bg_graph_gas,
- R.drawable.bg_graph_water,
- R.drawable.bg_graph_carbon
- };
- // [Thread]
- public Thread mThread_saveRealMeterData = null;
- private int[] setdata;
- private boolean RealtimeMeterUse;
- private int RealtimeMeterCountFromDB;
- // [Time]
- private Calendar nowCal, HourCal, DateCal, MonthCal, YearCal, EnergyDataGetCal;
- // [실시간 검침 관련 View 변수]
- WpadImageView RealTimeData_image;
- WpadImageView RealTimeData_bg2;
- WpadTextView RealTimeData; //실시간 사용량 데이터
- double RealTimeData_Double = 0;
- double EnergyMax_Double = 20;
- WpadTextView CalorieUnit1, CalorieUnit2; //난방 단위
- // WpadTextView RealtimeMeter_Marking1, RealtimeMeter_Marking2, RealtimeMeter_Marking3,
- // RealtimeMeter_Marking4, RealtimeMeter_Marking5, RealtimeMeter_Marking6, RealtimeMeter_Marking7;
- int NowShowEnergyKind = 0;
- private DataClasses.RealTimeMeter data = null;
- // [원 관련 변수]
- WpadImageView Energy_half_circle, CircleGraph, CircleGraph_backside;
- int Energy_half_circle_x = Common.ImgPosion.GetX(300);
- int Energy_half_circle_y = Common.ImgPosion.GetY(359);
- // [바늘 그리기]
- private float mScrewDegree = 0.0f;
- DrawScrew drawScrew[] = new DrawScrew[1];
- // [실시간 그래프 그리기]
- private float mGraphDegree = 0.0f;
- DrawGraph drawgraph[] = new DrawGraph[1];
- // [사용량 추이 그래프 관련 변수]
- WpadImageView Dot_img_Yesterday[] = new WpadImageView[9];
- private int ArrayDot_Yesterday[][] = new int[2][9];
- WpadImageView Dot_img_Today[] = new WpadImageView[9];
- private int ArrayDot_Today[][] = new int[2][9];
- // [사용량 추이 그래프 - 실시간 검침 지원하지 않을 시]
- WpadImageView Background_DayEnergy;
- WpadTextView DayMarking[] = new WpadTextView[9]; //아랫쪽 날짜
- WpadTextView DayEnergyMarking[] = new WpadTextView[9];
- private int RecentDay = 0;
- private boolean isStartSaveData = false;
- private int TotalServerInquiryCount = 0;
- ArrayList<DayEnergyDataClass> arrayListDayEnergyData = new ArrayList<DayEnergyDataClass>();
- DayEnergyDataClass realTimeEnergyData;
- class DayEnergyDataClass {
- private int Year;
- private int Month;
- private int Day;
- private float kepco_used;
- private float solar_used;
- private float fuel_used;
- public DayEnergyDataClass(int Year, int Month, int Day, float kepco_used, float solar_used, float fuel_used) {
- this.Year = Year;
- this.Month = Month;
- this.Day = Day;
- this.kepco_used = kepco_used;
- this.solar_used = solar_used;
- this.fuel_used = fuel_used;
- }
- public int getYear() {
- return Year;
- }
- public int getMonth() {
- return Month;
- }
- public int getDay() {
- return Day;
- }
- public float getKepco_used() {
- return kepco_used;
- }
- public float getSolar_used() {
- return solar_used;
- }
- public float getFuel_used() {
- return fuel_used;
- }
- }
- //6:전기 누적 사용량, 7:수도 누적 사용량, 8:가스 누적 사용량, 9:온수 누적 사용량, 10:열량 누적 사용량
- private final static int DB_ELECTRIC = 6;
- private final static int DB_WATER = 7;
- private final static int DB_GAS = 8;
- private final static int DB_HOTWATER = 9;
- private final static int DB_HEATING = 10;
- private final static int DB_KEPCO = 11;
- private final static int DB_SOLAR = 12;
- private final static int DB_FUEL = 13;
- private float UsedData_Today[] = new float[9];
- private float UsedData_Yesterday[] = new float[9];
- private float UsedData_Today_AfterCalc[] = new float[9];
- private float UsedData_Yesterday_AfterCalc[] = new float[9];
- private float UsedData_MaxData[] = new float[4];
- WpadTextView UsedData_MaxData_textView[] = new WpadTextView[4];
- WpadTextView UsedData_Unit;
- WpadTextView TotalUsedData_Today_textView, TotalUsedData_Yesterday_textView;
- DrawLine[] drawLines = new DrawLine[2];
- private float TotalUsedData_Today;
- private float TotalUsedData_Yesterday;
- // [당월 누적 사용량 그래프 그리기]
- int TempEnergyCount;
- DrawRect[] drawRect = new DrawRect[13];
- WpadTextView Kepco_HomeUse;
- WpadTextView Fuel_HomeUse;
- WpadTextView Photovoltaics_HomeUse;
- // [메뉴 리스트 처리 및 서브 스크린 호출]
- //private CallSubMenuScreen m_CallSubMenuScreen = null;
- // [좌표값 관련 변수]
- private LayoutDevice_hems getPos = new LayoutDevice_hems();
- public VIPIcEnergyMgrScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode) {
- super(context, layout);
- Log.d(TAG, "[START - Screen] --------------------------------------------" + Build.MODEL);
- //m_CallSubMenuScreen = callAPK;
- m_wpapi = wpapi;
- // @ AutoScale 설정 - 2. 에너지관리화면을 위한 구분자 설정
- if ((WpadScale.getWidthPixels() == 1024) && (WpadScale.getHeightPixels() == 600))
- Common.SCREEN_TYPE = Common.SCREEN_TYPE_1024x600;
- else Common.SCREEN_TYPE = Common.SCREEN_TYPE_1280x800;
- // 1. Data Create
- DebugLogOutput("[Create] - Step1 : Data Create");
- data = new DataClasses.RealTimeMeter();
- TempbSupportKind = false; //true면 5종
- // initInfo();
- RegisterMainEventBr();
- NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.SOLAR;
- nowCal = Calendar.getInstance();
- // 2. Device API Load & Update
- DebugLogOutput("[Create] - Step2 : Device API Load & Update");
- //시간정보 저장
- HourCal = Calendar.getInstance();
- DateCal = Calendar.getInstance();
- MonthCal = Calendar.getInstance();
- YearCal = Calendar.getInstance();
- // 2.1 실시간 검침기 사용유무 판단
- // 고급주택은 실시간 검침 데이터도 단지서버로 부터 받아온다.
- /*
- WallpadDeviceSet devset = new WallpadDeviceSet(getContext());
- setdata = devset.Get_RealTimeMetor_Info();
- devset.closeDB();
- if (setdata[0] == 0) {
- // 실시간 검침 사용하지 않음
- RealtimeMeterUse = false;
- DebugLogOutput("RealtimeMeterUse = false");
- } else {
- // 실시간 검침사용함
- RealtimeMeterUse = true;
- RealtimeMeterCountFromDB = setdata[1];
- if (RealtimeMeterCountFromDB == 3) {
- TempbSupportKind = false;
- }
- DebugLogOutput("RealtimeMeterUse = true, RealtimeMeterCountFromDB + " + RealtimeMeterCountFromDB);
- }
- */
- RealtimeMeterUse = false;
- // 2.2 영업샘플 모드 판단
- if (Common.GetDeviceSampleMode(context) == true) {
- //영업샘플 모드임!
- //OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
- DebugLogOutput("OPERATION_MODE = MODE_BUSINESS_SAMPLE");
- } else {
- // 정상 모드!
- OPERATION_MODE = Common.MODE_NOMAL;
- DebugLogOutput("OPERATION_MODE = MODE_NOMAL");
- if (RealtimeMeterUse == true) {
- mIntDriverCheckHandler.sendEmptyMessage(0);
- }
- }
- //테스트 위함
- TempbSupportKind = false;
- //OPERATION_MODE = Common.MODE_BUSINESS_SAMPLE;
- //테스트 끝
- // 3. Image & Text Create
- DebugLogOutput("[Create] - Step3 : Image & Text Create");
- Background = new WpadImageView(context, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, 0, ID.RemoteMeterMainScreenID.image.BACKGROUND);
- ViewRegistration(layout, Background, Common.ImgPosion.GetX(0), Common.ImgPosion.GetY(110));
- //계기판 배경
- CircleGraph = new WpadImageView(context, TOUCH_KIND.NONE, 340, 170, R.drawable.bg_graph_gray_3, 0, ID.IcEnergyMgrID.image.MOMENT_GRAPH);
- ViewRegistration(layout, CircleGraph, Common.ImgPosion.GetX(300), Common.ImgPosion.GetY(190));
- drawgraph[0] = new DrawGraph(getContext(), 0);
- if (getLayout() != null) getLayout().addView(drawgraph[0]);
- //실시간 사용량 배경 + 사용량추이 그래프 배경
- Background_02 = new WpadImageView(context, TOUCH_KIND.NONE, 670, 576, R.drawable.box_1_2, 0, ID.IcEnergyMgrID.image.BACKGROUND);
- ViewRegistration(layout, Background_02, Common.ImgPosion.GetX(49), Common.ImgPosion.GetY(135));
- drawScrew[0] = new DrawScrew(getContext(), mScrewDegree);
- if (getLayout() != null) getLayout().addView(drawScrew[0]);
- Energy_half_circle_x = getPos.Get(R.drawable.man_energy_half_circle_graph_focus_circle).x;
- Energy_half_circle_y = getPos.Get(R.drawable.man_energy_half_circle_graph_focus_circle).y;
- 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);
- ViewRegistration(layout, Energy_half_circle, Common.ImgPosion.GetX(433), Common.ImgPosion.GetY(322));
- //실시간사용량
- 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);
- ViewRegistration(layout, RealTimeData, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).x, getPos.Get(ID.IcEnergyMgrID.text.REALTIMEMETER_DATA).y);
- // 4. Draw_Update
- DebugLogOutput("[Create] - Step4 : Draw_Update");
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- Sample_Start();
- mEMS_Enable = true;
- mNumberOfEnergy = 3; //수정필요
- } else {
- GetMeteringCount();
- }
- TempEnergyCount = mNumberOfEnergy;
- DebugLogOutput("[Create] - Step5 : mNumberOfEnergy : " + mNumberOfEnergy);
- if (mNumberOfEnergy == 3) {
- Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
- Btn_Kepco.setVisibility(View.GONE);
- Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- 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);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- Background_04 = new WpadImageView(context, TOUCH_KIND.NONE, 499, 576, R.drawable.vip_box_3_2_metercheckdate, 0, ID.IcEnergyMgrID.image.BACKGROUND);
- ViewRegistration(layout, Background_04, Common.ImgPosion.GetX(731), Common.ImgPosion.GetY(135));
- Kepco_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.ELECTRIC_HOMEUSE);
- ViewRegistration(layout, Kepco_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(343));
- Kepco_HomeUse.setVisibility(View.GONE);
- Photovoltaics_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.WATER_HOMEUSE);
- ViewRegistration(layout, Photovoltaics_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(343));
- Fuel_HomeUse = new WpadTextView(context, false, 50, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text_energy_num_3.GAS_HOMEUSE);
- ViewRegistration(layout, Fuel_HomeUse, Common.ImgPosion.GetX(1166), Common.ImgPosion.GetY(515));
- }
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- Background_DayEnergy = new WpadImageView(getContext(), TOUCH_KIND.NONE, 670, 282, R.drawable.box_2_2, 0, ID.IcEnergyMgrID.image.BACKGROUND); //그래프 변경
- ViewRegistration(getLayout(), Background_DayEnergy, Common.ImgPosion.GetX(49), Common.ImgPosion.GetY(429));
- for (int i = 0; i < 9; i++) {
- // 아랫쪽
- DayMarking[i] = new WpadTextView(context, false, getPos.Get(ID.IcEnergyMgrID.text_day_marking.DAY_MARKING_1, i).width,
- 30,
- Gravity.CENTER, Color.parseColor("#969696"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
- if (i < 2) {
- 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);
- } else if (i == 2) {
- 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);
- } else {
- 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);
- }
- }
- for (int i = 0; i < 4; i++) {
- // 왼쪽 기준
- 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);
- if (i == 0) {
- 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);
- } else {
- 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);
- }
- UsedData_MaxData_textView[i].setText(String.valueOf(i * 4));
- }
- 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);
- ViewRegistration(getLayout(), UsedData_Unit, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).y);
- } else {
- if (RealtimeMeterCountFromDB == 3) {
- // 실시간 검침 DB값 3종일 경우
- Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.ELECTRIC);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
- Btn_Kepco.setVisibility(View.GONE);
- 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);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- 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);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- }
- }
- for (int i = 1; i <= 12; i++) {
- drawRect[i] = new DrawRect(context, i, 0, mNumberOfEnergy);
- layout.addView(drawRect[i]);
- }
- String str;
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- str = "0";
- str += " kWh";
- } else {
- str = "0";
- str += " W";
- }
- RealTimeData.setText(str);
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- SampleDatainsert_MonthTableData();
- } else {
- ShowMonthGraph();
- if (RealtimeMeterUse == true) {
- RemoveUsedData();
- ShowUsedDataGraph();
- } else {
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- ShowUsedDataGraph_DayVersion();
- }
- }, 300);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- ShowRealTimeDataGraph_DayVersion();
- }
- }, 700);
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- ShowDayGraph();
- }
- }, 800);
- }
- }
- Log.d(TAG, "[End - Screen] -------------------------------------------- ");
- }
- private void ShowRealTimeDataGraph_DayVersion() {
- // 사용량추이
- nowCal = Calendar.getInstance();
- CalendarYear = nowCal.get(Calendar.YEAR);
- CalendarMonth = nowCal.get(Calendar.MONTH);
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- if (arrayListDayEnergyData.size() == 0) {
- arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 2, 3, 22, 34));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 1, 4, 23, 35));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 28, 5, 24, 36));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 27, 6, 25, 37));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 26, 7, 26, 38));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 25, 8, 27, 39));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 24, 9, 28, 40));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 23, 9, 29, 41));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 22, 6, 30, 42));
- }
- ShowDayGraph();
- } else {
- LoadRemotemeterDataFromServer(2, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
- }
- }
- private void ShowUsedDataGraph_DayVersion() {
- // 사용량추이
- nowCal = Calendar.getInstance();
- CalendarYear = nowCal.get(Calendar.YEAR);
- CalendarMonth = nowCal.get(Calendar.MONTH);
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- if (arrayListDayEnergyData.size() == 0) {
- arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 2, 3, 22, 34));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 3, 1, 4, 23, 35));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 28, 5, 24, 36));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 27, 6, 25, 37));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 26, 7, 26, 38));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 25, 8, 27, 39));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 24, 9, 28, 40));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 23, 9, 29, 41));
- //arrayListDayEnergyData.add(new DayEnergyDataClass(2015, 2, 22, 6, 30, 42));
- }
- ShowDayGraph();
- } else {
- RecentDay = 0;
- isStartSaveData = false;
- TotalServerInquiryCount = 0;
- arrayListDayEnergyData.clear();
- LoadRemotemeterDataFromServer(1, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
- }
- }
- private void ShowMonthGraph() {
- /* if(Flag_SendMSG_RandomCheckHandler == true)
- {
- return;
- }*/
- nowCal = Calendar.getInstance();
- CalendarYear = nowCal.get(Calendar.YEAR);
- CalendarMonth = nowCal.get(Calendar.MONTH);
- LoadRemotemeterDataFromServer(0, CalendarYear, CalendarMonth, ShowNowEnergyIndex);
- }
- private void RemoveUsedData() {
- DebugLogOutput("[RemoveUsedData] is called");
- int NowHourint;
- long now = System.currentTimeMillis();
- Date date_Now = new Date(now);
- SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
- String strCurHour = CurHourFormat.format(date_Now);
- NowHourint = Integer.parseInt(strCurHour) / 3;
- for (int i = 0; i < 4; i++) {
- if (getLayout() != null) getLayout().removeView(UsedData_MaxData_textView[i]);
- }
- if (getLayout() != null) getLayout().removeView(UsedData_Unit);
- if (getLayout() != null) getLayout().removeView(drawLines[0]);
- for (int i = 0; i < 9; i++) {
- if (getLayout() != null) getLayout().removeView(Dot_img_Yesterday[i]);
- }
- if (getLayout() != null) getLayout().removeView(drawLines[1]);
- for (int i = 0; i < 9; i++) {
- if (Dot_img_Today[i] != null) {
- if (getLayout() != null) getLayout().removeView(Dot_img_Today[i]);
- }
- }
- if (getLayout() != null) getLayout().removeView(TotalUsedData_Today_textView);
- if (getLayout() != null) getLayout().removeView(TotalUsedData_Yesterday_textView);
- }
- public static float[] reverseArrayfloat(float[] array) {
- float temp;
- for (int i = 0; i < array.length / 2; i++) {
- temp = array[i];
- array[i] = array[(array.length - 1) - i];
- array[(array.length - 1) - i] = temp;
- }
- return array;
- }
- public static int[] reverseArrayint(int[] array) {
- int temp;
- for (int i = 0; i < array.length / 2; i++) {
- temp = array[i];
- array[i] = array[(array.length - 1) - i];
- array[(array.length - 1) - i] = temp;
- }
- return array;
- }
- /**
- * 사용량 추이 데이터 그리는 함수 - 실시간 검침 지원하지 않을 시 최근 8일 사용량 출력
- **/
- private void ShowDayGraph() {
- DebugLogOutput("ShowDayGraph");
- //실시간 사용량 배경 + 사용량추이 그래프 배경
- if (arrayListDayEnergyData.size() < 1) {
- DebugLogOutput("arrayListDayEnergyData.size() != 9. Return!!!");
- DebugLogOutput("arrayListDayEnergyData.size(): " + arrayListDayEnergyData.size());
- return;
- }
- //기존에 있던 그래프 삭제
- if (drawLines[0] != null) {
- if (getLayout() != null) getLayout().removeView(drawLines[0]);
- }
- for (int i = 0; i < 9; i++) {
- if (Dot_img_Yesterday[i] != null) {
- if (getLayout() != null) getLayout().removeView(Dot_img_Yesterday[i]);
- }
- if (DayEnergyMarking[i] != null) {
- if (getLayout() != null) getLayout().removeView(DayEnergyMarking[i]);
- }
- }
- int size = arrayListDayEnergyData.size() > 9 ? 9 : arrayListDayEnergyData.size();
- //그리기
- float[] tempFloatArray = new float[size];
- int[] tempintArray = new int[size];
- int j = 1;
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- for (int i = (size - 1); i >= 0; i--) {
- tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getKepco_used();
- j++;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- for (int i = (size - 1); i >= 0; i--) {
- tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getSolar_used();
- j++;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- for (int i = (size - 1); i >= 0; i--) {
- tempFloatArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - j).getFuel_used();
- j++;
- }
- break;
- default:
- break;
- }
- UsedData_MaxData[3] = CalcMaxValue_float(tempFloatArray);
- if (UsedData_MaxData[3] <= (float) 0.3) {
- UsedData_MaxData[3] = (float) 0.3;
- }
- for (int i = 0; i < 4; i++) {
- // 왼쪽 에너지 기준 데이터 표시
- UsedData_MaxData[i] = UsedData_MaxData[3] / 3 * i;
- if (UsedData_MaxData[i] == 0) {
- UsedData_MaxData[i] = i * 2;
- }
- if (NowShowEnergyKind == ID.IcEnergyMgrID.DataKind.HEATING) {
- UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint2(UsedData_MaxData[i]));
- } else {
- UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint2(UsedData_MaxData[i]));
- }
- }
- switch (NowShowEnergyKind) {
- // 왼쪽 에너지 기준 데이터의 단위 표시
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- case ID.IcEnergyMgrID.DataKind.FUEL:
- UsedData_Unit.setText("kWh"); // ㎥, ㎥/MWh, kWh;
- break;
- default:
- break;
- }
- //하단 날짜 출력, 에너지 데이터 삽입
- for (int i = 0; i < size; i++) {
- //if(i>=arrayListDayEnergyData.size()-1) break;
- tempintArray[i] = arrayListDayEnergyData.get(arrayListDayEnergyData.size() - size + i).getDay();
- }
- //int배열을 역순으로
- //tempintArray = reverseArrayint(tempintArray);
- for (int i = size - 1; i >= 0; i--) {
- DayMarking[i].setText(String.valueOf(tempintArray[i]) + "일");
- }
- //float배열 역순으로
- //tempFloatArray = reverseArrayfloat(tempFloatArray);
- UsedData_Yesterday_AfterCalc = tempFloatArray;
- //Yesterday 그래프그리기
- for (int i = 0; i < size; i++) {
- if (i < 2) {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
- } else if (i == 2) {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
- } else {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
- }
- int index = UsedData_Yesterday_AfterCalc.length - size + i;
- 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])))) {
- ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- } else {
- 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좌표
- if (ArrayDot_Yesterday[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
- ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- }
- }
- // DebugLogOutput("ArrayDot_Yesterday["+i+"] = "+ArrayDot_Yesterday[0][i]+", "+ArrayDot_Yesterday[1][i]);
- }
- drawLines[0] = new DrawLine(getContext(), ArrayDot_Yesterday, size - 1, 0);
- if (getLayout() != null) getLayout().addView(drawLines[0]);
- for (int i = 0; i < size; i++) {
- 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);
- ViewRegistration(getLayout(), Dot_img_Yesterday[i], ArrayDot_Yesterday[0][i], ArrayDot_Yesterday[1][i]);
- DayEnergyMarking[i] = new WpadTextView(getContext(), false, (60), 20, Gravity.CENTER, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.text.REALTIMEMETER_DATA);
- if (i == 0) {
- ViewRegistration(getLayout(), DayEnergyMarking[i], ArrayDot_Yesterday[0][i] - (38 / 2) + 15, ArrayDot_Yesterday[1][i] - 19);
- } else {
- ViewRegistration(getLayout(), DayEnergyMarking[i], ArrayDot_Yesterday[0][i] - (38 / 2) + 4, ArrayDot_Yesterday[1][i] - 19);
- }
- int index = UsedData_Yesterday_AfterCalc.length - size + i;
- DayEnergyMarking[i].setText(Convter2_DoubleTOStr_CutPoint2((double) UsedData_Yesterday_AfterCalc[index]));
- }
- //arrayListDayEnergyData.clear();
- Draw_Update();
- }
- /**
- * 사용량 추이 데이터 그리는 함수 - 실시간 검침 지원 시
- **/
- private void ShowUsedDataGraph() {
- DebugLogOutput("[ShowUsedDataGraph] is called");
- String tempstr;
- int NowHourint;
- //DB
- wallpaddbmgr WallpadDBMGR = null;
- WallpadDBMGR = new wallpaddbmgr(getContext());
- // 현재 시간을 msec으로 구한다.
- long now = System.currentTimeMillis();
- // 현재 시간을 저장 한다.
- Date date_Now = new Date(now);
- Date date_Yesterday;
- // 어제 날짜 구하기
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date(now));
- cal.add(Calendar.DATE, -1);
- date_Yesterday = new Date(cal.getTimeInMillis());
- // 시간 포맷 지정
- //SimpleDateFormat CurDateFormat = new SimpleDateFormat("yyyy년 MM월 dd일");
- //SimpleDateFormat CurTimeFormat = new SimpleDateFormat("HH시 mm분");
- SimpleDateFormat CurYearFormat = new SimpleDateFormat("yyyy");
- SimpleDateFormat CurMonthFormat = new SimpleDateFormat("MM");
- SimpleDateFormat CurDayFormat = new SimpleDateFormat("dd");
- SimpleDateFormat CurHourFormat = new SimpleDateFormat("HH");
- SimpleDateFormat CurMinuteFormat = new SimpleDateFormat("mm");
- // 지정된 포맷으로 String 타입 리턴
- //String strCurDate = CurDateFormat.format(date);
- //String strCurTime = CurTimeFormat.format(date);
- String strCurYear = CurYearFormat.format(date_Now);
- String strCurMonth = CurMonthFormat.format(date_Now);
- String strCurDay = CurDayFormat.format(date_Now);
- String strCurHour = CurHourFormat.format(date_Now);
- NowHourint = Integer.parseInt(strCurHour) / 3;
- String strYesterYear = CurYearFormat.format(date_Yesterday);
- String strYesterMonth = CurMonthFormat.format(date_Yesterday);
- String strYesterDay = CurDayFormat.format(date_Yesterday);
- //DebugLogOutput("now :"+ strCurYear+"-"+strCurMonth+'-'+strCurDay+" "+strCurHour);
- int NowShowEnergy = DB_KEPCO;
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- NowShowEnergy = DB_KEPCO;
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- NowShowEnergy = DB_SOLAR;
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- NowShowEnergy = DB_FUEL;
- break;
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- NowShowEnergy = DB_ELECTRIC;
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- NowShowEnergy = DB_HEATING;
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- NowShowEnergy = DB_GAS;
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- NowShowEnergy = DB_HOTWATER;
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- NowShowEnergy = DB_WATER;
- break;
- default:
- break;
- }
- try {
- Arrays.fill(UsedData_Yesterday, 0);
- Arrays.fill(UsedData_Today, 0);
- for (int i = 0; i < 9; i++) {
- if ((i * 3) < 12) {
- tempstr = "0";
- } else {
- tempstr = "";
- }
- String tempString;
- if (i == 8) {
- tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strCurYear, strCurMonth, strCurDay, "00");
- } else {
- tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strYesterYear, strYesterMonth, strYesterDay, tempstr + (String.valueOf(i * 3)));
- }
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- tempString = SampleUsedData1[i];
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- tempString = SampleUsedData3[i];
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- case ID.IcEnergyMgrID.DataKind.FUEL:
- tempString = SampleUsedData5[i];
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- tempString = SampleUsedData7[i];
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- tempString = SampleUsedData9[i];
- break;
- default:
- break;
- }
- }
- if (tempString == null) {
- UsedData_Yesterday[i] = 0;
- } else {
- UsedData_Yesterday[i] = Float.parseFloat(tempString);
- }
- DebugLogOutput(strYesterYear + "-" + strYesterMonth + '-' + strYesterDay + " hour:" + String.valueOf(i * 3) + " - Data:" + UsedData_Yesterday[i]);
- if (UsedData_Yesterday[i] < 0) {
- UsedData_Yesterday[i] = 0;
- }
- }
- for (int i = 0; i <= NowHourint; i++) {
- if ((i * 3) < 12) {
- tempstr = "0";
- } else {
- tempstr = "";
- }
- String tempString = WallpadDBMGR.SearchRealTimeMeterData(NowShowEnergy, strCurYear, strCurMonth, strCurDay, tempstr + (String.valueOf(i * 3)));
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- tempString = SampleUsedData2[i];
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- tempString = SampleUsedData4[i];
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- case ID.IcEnergyMgrID.DataKind.FUEL:
- tempString = SampleUsedData6[i];
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- tempString = SampleUsedData8[i];
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- tempString = SampleUsedData10[i];
- break;
- default:
- break;
- }
- }
- if (tempString == null) {
- UsedData_Today[i] = 0;
- } else {
- UsedData_Today[i] = Float.parseFloat(tempString);
- }
- DebugLogOutput(strCurYear + "-" + strCurMonth + '-' + strCurDay + " hour:" + String.valueOf(i * 3) + " - Data:" + UsedData_Today[i]);
- if (UsedData_Today[i] < 0) {
- UsedData_Today[i] = 0;
- }
- }
- } catch (RuntimeException re) {
- if (WallpadDBMGR != null) {
- WallpadDBMGR.closeDB();
- }
- Log.e(TAG, "exception : " + re);
- } catch (Exception e) {
- if (WallpadDBMGR != null) {
- WallpadDBMGR.closeDB();
- }
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- //DB
- WallpadDBMGR.closeDB();
- Arrays.fill(UsedData_Yesterday_AfterCalc, 0);
- Arrays.fill(UsedData_Today_AfterCalc, 0);
- for (int i = 0; i < 9; i++) {
- if (i == 8) {
- UsedData_Yesterday_AfterCalc[i] = UsedData_Today[0] - UsedData_Yesterday[i];
- } else {
- UsedData_Yesterday_AfterCalc[i + 1] = UsedData_Yesterday[i + 1] - UsedData_Yesterday[i];
- if (UsedData_Yesterday[i] == 0) {
- UsedData_Yesterday_AfterCalc[i + 1] = 0;
- } else {
- UsedData_Yesterday_AfterCalc[i + 1] = UsedData_Yesterday[i + 1] - UsedData_Yesterday[i];
- }
- }
- if (UsedData_Yesterday_AfterCalc[i] < 0) {
- UsedData_Yesterday_AfterCalc[i] = 0;
- }
- DebugLogOutput("UsedData_Yesterday_AfterCalc[" + i + "] = " + UsedData_Yesterday_AfterCalc[i]);
- }
- for (int i = 0; i <= NowHourint; i++) {
- UsedData_Today_AfterCalc[i + 1] = UsedData_Today[i + 1] - UsedData_Today[i];
- if (UsedData_Today[i] == 0) {
- UsedData_Today_AfterCalc[i + 1] = 0;
- } else {
- UsedData_Today_AfterCalc[i + 1] = UsedData_Today[i + 1] - UsedData_Today[i];
- }
- if (UsedData_Today_AfterCalc[i] < 0) {
- UsedData_Today_AfterCalc[i] = 0;
- }
- if (UsedData_Today_AfterCalc[i + 1] < 0) {
- UsedData_Today_AfterCalc[i + 1] = 0;
- }
- DebugLogOutput("UsedData_Today_AfterCalc[" + i + "] = " + UsedData_Today_AfterCalc[i]);
- }
- //어제 사용량, 오늘 사용량 구하기
- float TempTotalUsedData_Yesterday = 0;
- float TempTotalUsedData_today = 0;
- for (int i = 0; i < 9; i++) {
- if (UsedData_Yesterday_AfterCalc[i] >= 0) {
- TempTotalUsedData_Yesterday = TempTotalUsedData_Yesterday + UsedData_Yesterday_AfterCalc[i];
- }
- DebugLogOutput("TotalUsedData_Yesterday[" + i + "] = " + TempTotalUsedData_Yesterday);
- }
- for (int i = 0; i <= NowHourint; i++) {
- if (UsedData_Today_AfterCalc[i] >= 0) {
- TempTotalUsedData_today = TempTotalUsedData_today + UsedData_Today_AfterCalc[i];
- }
- DebugLogOutput("TotalUsedData_Today[" + i + "] = " + TempTotalUsedData_today);
- }
- TotalUsedData_Yesterday = TempTotalUsedData_Yesterday;
- TotalUsedData_Today = TempTotalUsedData_today;
- //어제사용량
- TotalUsedData_Yesterday_textView = new WpadTextView(getContext(), false, 70, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.UsedData_MaxData_textView.TotalUsedData_Yesterday_textView);
- ViewRegistration(getLayout(), TotalUsedData_Yesterday_textView, Common.ImgPosion.GetX(556), Common.ImgPosion.GetY(456));
- TotalUsedData_Yesterday_textView.setText(Convter2_DoubleTOStr_CutPoint1(TotalUsedData_Yesterday));
- //오늘 사용량
- TotalUsedData_Today_textView = new WpadTextView(getContext(), false, 70, 20, Gravity.LEFT, Color.parseColor("#ffffff"), ContentsFontSize, false, ID.IcEnergyMgrID.UsedData_MaxData_textView.TotalUsedData_Today_textView);
- ViewRegistration(getLayout(), TotalUsedData_Today_textView, Common.ImgPosion.GetX(556), Common.ImgPosion.GetY(481));
- TotalUsedData_Today_textView.setText(Convter2_DoubleTOStr_CutPoint1(TotalUsedData_Today));
- //어제 사용량, 오늘 사용량 구하기
- if (CalcMaxValue_float(UsedData_Yesterday_AfterCalc) >= CalcMaxValue_float(UsedData_Today_AfterCalc)) {
- UsedData_MaxData[3] = CalcMaxValue_float(UsedData_Yesterday_AfterCalc);
- } else {
- UsedData_MaxData[3] = CalcMaxValue_float(UsedData_Today_AfterCalc);
- }
- if (UsedData_MaxData[3] <= (float) 0.3) {
- UsedData_MaxData[3] = (float) 0.3;
- }
- for (int i = 0; i < 4; i++) {
- UsedData_MaxData[i] = UsedData_MaxData[3] / 3 * i;
- if (UsedData_MaxData[i] == 0) {
- UsedData_MaxData[i] = i * 2;
- }
- 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);
- 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);
- UsedData_MaxData_textView[i].setText(Convter2_DoubleTOStr_CutPoint1(UsedData_MaxData[i]));
- }
- 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);
- ViewRegistration(getLayout(), UsedData_Unit, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).x, getPos.Get(ID.IcEnergyMgrID.UsedData_MaxData_textView.UsedData_Unit).y);
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- UsedData_Unit.setText("kWh"); // ㎥, ㎥/MWh, kWh;
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- UsedData_Unit.setText("㎥/MWh"); // ㎥, ㎥/MWh, kWh;
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- UsedData_Unit.setText("㎥"); // ㎥, ㎥/MWh, kWh;
- break;
- default:
- break;
- }
- //Yesterday 그래프그리기
- for (int i = 0; i < 9; i++) {
- if (i < 2) {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
- } else if (i == 2) {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
- } else {
- ArrayDot_Yesterday[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
- }
- 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])))) {
- ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- } else {
- 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좌표
- if (ArrayDot_Yesterday[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
- ArrayDot_Yesterday[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- }
- }
- /*
- DebugLogOutput("UsedData_MaxData[3]" + UsedData_MaxData[3]);
- DebugLogOutput("UsedData_Yesterday_AfterCalc[i]" + UsedData_Yesterday_AfterCalc[i]);
- DebugLogOutput("Calc value " + (506-(69*(UsedData_Yesterday_AfterCalc[i])/UsedData_MaxData[3])));
- */
- //DebugLogOutput("ArrayDot_Yesterday["+i+"] = "+ArrayDot_Yesterday[0][i]+", "+ArrayDot_Yesterday[1][i]);
- }
- drawLines[0] = new DrawLine(getContext(), ArrayDot_Yesterday, 9, 0);
- if (getLayout() != null) getLayout().addView(drawLines[0]);
- for (int i = 0; i < 9; i++) {
- 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);
- ViewRegistration(getLayout(), Dot_img_Yesterday[i], ArrayDot_Yesterday[0][i], ArrayDot_Yesterday[1][i]);
- }
- //Today 그래프그리기
- for (int i = 0; i <= NowHourint; i++) {
- if (i < 2) {
- ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_1, i).x; // x좌표
- } else if (i == 2) {
- ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_2, i).x; // x좌표
- } else {
- ArrayDot_Today[0][i] = getPos.Get(ID.IcEnergyMgrID.Graph.x_3, i).x; // x좌표
- }
- 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])))) {
- ArrayDot_Today[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- } else {
- 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좌표
- if (ArrayDot_Today[1][i] > getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y) {
- ArrayDot_Today[1][i] = getPos.Get(ID.IcEnergyMgrID.Graph.y_MAX, i).y;
- }
- }
- //DebugLogOutput("ArrayDot_Today["+i+"+] = "+ArrayDot_Today[0][i]+", "+ArrayDot_Today[1][i]);
- }
- drawLines[1] = new DrawLine(getContext(), ArrayDot_Today, NowHourint, 1);
- if (getLayout() != null) getLayout().addView(drawLines[1]);
- for (int i = 0; i <= NowHourint; i++) {
- 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);
- ViewRegistration(getLayout(), Dot_img_Today[i], ArrayDot_Today[0][i], ArrayDot_Today[1][i]);
- }
- }
- /**
- * 배열의 최대값 구하는 함수
- *
- * @param ArrayFloat float[]
- * @return flaot (최대값)
- **/
- public float CalcMaxValue_float(float[] ArrayFloat) {
- float max = ArrayFloat[0];
- for (int i = 1; i < ArrayFloat.length; i++) {
- if (ArrayFloat[i] >= max) {
- max = ArrayFloat[i];
- }
- }
- return max;
- }
- @Override
- protected void onClose() {
- super.onClose();
- UnRegisterMainEventBr();
- if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) Sample_End();
- if (realTimeMeterAPI != null) {
- Device_BrRegistration(false);
- }
- Log.i(TAG, "[END - Screen] ********************************************");
- }
- @Override
- public void Close() {
- Log.i(TAG, "[END - Screen] ********************************************");
- super.Close();
- }
- @Override
- protected void onTouchEvent(View v, MotionEvent event) {
- super.onTouchEvent(v, event);
- int TargetId = v.getId();
- int MoveEvent = event.getAction();
- if (MoveEvent == MotionEvent.ACTION_DOWN) {
- } else if (MoveEvent == MotionEvent.ACTION_UP) {
- if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_LEFT) {
- } else if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_HOME) {
- } else if (TargetId == ID.IcEnergyMgrID.button.BOTTOM_MOVE_RIGHT) {
- } else if (TargetId == ID.IcEnergyMgrID.button.DETAIL_VIEW) {
- // 확대버튼 누를경우 Energy관리 app 실행되야 함!
- DebugLogOutput("callStartEnergyAPK");
- Sound().Play(WpadSound.SND.effect.TOUCH_LATCHED);
- //m_CallSubMenuScreen.callStartEnergyAPK();
- } else if ((TargetId >= ID.IcEnergyMgrID.button.KEPCO) && (TargetId <= ID.IcEnergyMgrID.button.FUEL)) {
- Sound().Play(WpadSound.SND.effect.TOUCH_LATCHED);
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- if (getLayout() != null) getLayout().removeView(Btn_Kepco);
- 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);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- if (getLayout() != null) getLayout().removeView(Btn_Solar);
- 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);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- if (getLayout() != null) getLayout().removeView(Btn_Fuel);
- 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);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- break;
- }
- switch (TargetId) {
- case ID.IcEnergyMgrID.button.KEPCO:
- //계기판 배경
- CircleGraph.setImageResource(CircleGraph_bg[0]);
- NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.KEPCO;
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- EnergyMax_Double = 20;
- if (RealTimeData != null) RealTimeData.setText("0 kWh");
- } else {
- EnergyMax_Double = 3000;
- if (RealTimeData != null) RealTimeData.setText("0 W");
- }
- if (getLayout() != null) getLayout().removeView(Btn_Kepco);
- Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
- Btn_Kepco.setVisibility(View.GONE);
- break;
- case ID.IcEnergyMgrID.button.SOLAR:
- CircleGraph.setImageResource(CircleGraph_bg[0]);
- NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.SOLAR;
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- EnergyMax_Double = 20;
- if (RealTimeData != null) RealTimeData.setText("0 kWh");
- } else {
- EnergyMax_Double = 3000;
- if (RealTimeData != null) RealTimeData.setText("0 W");
- }
- if (getLayout() != null) getLayout().removeView(Btn_Solar);
- Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_pressed).x, getPos.Get(R.drawable.btn_3_solar_e_pressed).y);
- break;
- case ID.IcEnergyMgrID.button.FUEL:
- CircleGraph.setImageResource(CircleGraph_bg[2]);
- NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.FUEL;
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- EnergyMax_Double = 1.2;
- if (RealTimeData != null) RealTimeData.setText("0 kWh");
- } else {
- EnergyMax_Double = 3000;
- if (RealTimeData != null) RealTimeData.setText("0 W");
- }
- if (getLayout() != null) getLayout().removeView(Btn_Fuel);
- Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.BUTTON, 160, 74, R.drawable.btn_3_fuel_cell_selected, 0, ID.IcEnergyMgrID.button.FUEL);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_pressed).x, getPos.Get(R.drawable.btn_3_fuel_cell_pressed).y);
- break;
- default:
- break;
- }
- //Draw_Update();
- if (RealtimeMeterUse == true) {
- RemoveUsedData();
- ShowUsedDataGraph();
- } else {
- ShowRealTimeDataGraph_DayVersion();
- //ShowUsedDataGraph_DayVersion();
- ShowDayGraph();
- }
- }
- }
- }
- @Override
- public void ViewRegistration(RelativeLayout ParentsLayout, WpadImageView nImageView, int MarginLeft, int MarginTop) {
- // TODO Auto-generated method stub
- super.ViewRegistration(ParentsLayout, nImageView, MarginLeft, MarginTop);
- }
- @Override
- public void ViewRegistration(RelativeLayout ParentsLayout, WpadTextView nTextView, int MarginLeft, int MarginTop) {
- // TODO Auto-generated method stub
- super.ViewRegistration(ParentsLayout, nTextView, MarginLeft, MarginTop);
- }
- private void RegisterMainEventBr() {
- IntentFilter filter = new IntentFilter();
- filter.addAction(Common.MAIN_EVENT_TIMER);
- filter.addAction(Common.MAIN_SCREEN_NOW_UPDATE);
- filter.addAction(ID.IcEnergyMgrID.BR_REALMETER);
- this.getContext().registerReceiver(m_MainEventBR, filter);
- }
- private void UnRegisterMainEventBr() {
- this.getContext().unregisterReceiver(m_MainEventBR);
- }
- BroadcastReceiver m_MainEventBR = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String acname = intent.getAction();
- /* if( acname.equals(Common.MAIN_SCREEN_NOW_UPDATE) )
- {
- if( Background != null )
- {
- GetDBMainSkinBg();
- Background.setImageResource(getResourceIdMainSkin());
- }
- }*/
- if (acname.equals(ID.IcEnergyMgrID.BR_REALMETER)) {
- //DebugLogOutput("onBrReceive - BR_REALMETER");
- int bRet = Device_Update(false);
- if ((bRet == 0) && (APIInit == false)) {
- DebugLogOutput("APIInit = true;");
- APIInit = true;
- }
- Draw_Update();
- }
- }
- };
- // =================================================================================================
- // [[ Draw ]] region
- // =================================================================================================
- protected void Draw_Update() {
- if ((data.GetAllSupport() != TempbSupportKind) && (RealtimeMeterUse == true) && (APIInit == true)) {
- DebugLogOutput("if((data.GetAllSupport() != TempbSupportKind) && (RealtimeMeterUse == true))");
- TempbSupportKind = data.GetAllSupport();
- //NowShowEnergyKind = ID.IcEnergyMgrID.DataKind.KEPCO;
- if (data.GetAllSupport() == false && getLayout() != null) {
- // 종 버튼 등록.
- //버튼 해제
- if (getLayout() != null) getLayout().removeView(Btn_Kepco);
- if (getLayout() != null) getLayout().removeView(Btn_Solar);
- if (getLayout() != null) getLayout().removeView(Btn_Fuel);
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_pressed).x, getPos.Get(R.drawable.btn_3_kepco_pressed).y);
- Btn_Kepco.setVisibility(View.GONE);
- 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);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- 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);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- 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);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_solar_e_selected, 0, ID.IcEnergyMgrID.button.SOLAR);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- 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);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- 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);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- 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);
- ViewRegistration(getLayout(), Btn_Solar, getPos.Get(R.drawable.btn_3_solar_e_normal).x, getPos.Get(R.drawable.btn_3_solar_e_normal).y);
- Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_fuel_cell_selected, 0, ID.IcEnergyMgrID.button.FUEL);
- ViewRegistration(getLayout(), Btn_Fuel, getPos.Get(R.drawable.btn_3_fuel_cell_normal).x, getPos.Get(R.drawable.btn_3_fuel_cell_normal).y);
- break;
- }
- } else {
- if (getLayout() != null) getLayout().removeView(Btn_Kepco);
- if (getLayout() != null) getLayout().removeView(Btn_Solar);
- if (getLayout() != null) getLayout().removeView(Btn_Fuel);
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- Btn_Kepco = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.btn_3_kepco_selected, 0, ID.IcEnergyMgrID.button.KEPCO);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- 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);
- 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);
- 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);
- 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);
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- 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);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- Btn_Solar = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.man_energy_btn_water_3set_pressed, 0, ID.IcEnergyMgrID.button.SOLAR);
- 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);
- 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);
- 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);
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- 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);
- ViewRegistration(getLayout(), Btn_Kepco, getPos.Get(R.drawable.btn_3_kepco_normal).x, getPos.Get(R.drawable.btn_3_kepco_normal).y);
- Btn_Kepco.setVisibility(View.GONE);
- 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);
- 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);
- Btn_Fuel = new WpadImageView(getContext(), TOUCH_KIND.NONE, 160, 74, R.drawable.man_energy_btn_gas_3set_pressed, 0, ID.IcEnergyMgrID.button.FUEL);
- 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);
- break;
- }
- }
- }
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- if ((arrayListDayEnergyData.size() != 0) && (arrayListDayEnergyData.isEmpty() != true)) {
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getKepco_used());
- if(realTimeEnergyData!=null)
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getKepco_used());
- break;
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.SOLAR, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getSolar_used());
- if(realTimeEnergyData!=null)
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getSolar_used());
- CircleGraph.setImageResource(CircleGraph_bg[0]);
- break;
- case ID.IcEnergyMgrID.DataKind.FUEL:
- //Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.FUEL, arrayListDayEnergyData.get(arrayListDayEnergyData.size() - 1).getFuel_used());
- if(realTimeEnergyData!=null)
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.KEPCO, realTimeEnergyData.getFuel_used());
- break;
- default:
- break;
- }
- }
- } else {
- // 실시간 검침 지원함
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.ELECTRIC, data.Elec.Now);
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.WATER, data.Water.Now);
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.GAS, data.Gas.Now);
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HOTWATER, data.HotWater.Now);
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HEATING, data.Calorie.Now);
- break;
- default:
- break;
- }
- }
- ReDraw();
- }
- /**
- * 바늘 그리기
- */
- public class DrawScrew extends View {
- private float Degree;
- Path mScrewPath;
- Paint mScrewPaint, mGraphPaint;
- Bitmap resizedBitmap;
- private boolean init_flag = false;
- Matrix matrix;
- public DrawScrew(Context context, float degree) {
- super(context);
- Degree = degree;
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (init_flag == false) {
- init_flag = true;
- //그래프 그리기
- resizedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg_graph_holder_2);
- // AutoScale 설정시에만 bitmapOrg 을 Scaled 한다.
- if (WpadScale.getAutoScale()) {
- //resizedBitmap = Bitmap.createScaledBitmap(resizedBitmap,74,37,true);
- resizedBitmap = Bitmap.createScaledBitmap(resizedBitmap, WpadScale.getWidth(resizedBitmap.getWidth()), WpadScale.getHeight(resizedBitmap.getHeight()), true);
- }
- matrix = new Matrix();
- mScrewPaint = new Paint();
- mScrewPaint.setAntiAlias(true);
- }
- // rotate the Bitmap
- matrix.reset();
- matrix.setRotate(Degree, resizedBitmap.getWidth() / 2, 0);
- canvas.translate(getPos.Get(R.drawable.bg_graph_holder_2).x, getPos.Get(R.drawable.bg_graph_holder_2).y); //201, 131
- //canvas.translate(Common.ImgPosion.GetX(470-37),Common.ImgPosion.GetY(359)); //37: 반지름
- canvas.drawBitmap(resizedBitmap, matrix, mScrewPaint);
- }
- public void Rotate_ReDraw(float degree) {
- Degree = degree;
- invalidate();
- }
- }
- /**
- * 실시간 생산량 계기판 그리는 함수
- **/
- public void ReDraw() {
- if (EnergyMax_Double <= RealTimeData_Double) {
- RealTimeData_Double = EnergyMax_Double;
- }
- mScrewDegree = (float) (180 / (EnergyMax_Double / RealTimeData_Double) - 270);
- drawScrew[0].Rotate_ReDraw(mScrewDegree);
- mGraphDegree = (float) (180 / (EnergyMax_Double / RealTimeData_Double) - 180);
- drawgraph[0].Rotate_ReDraw(mGraphDegree);
- }
- /**
- * 실시간 생산량 계기판 그리는 클래스
- **/
- public class DrawGraph extends View {
- private float Degree;
- Paint mGraphPaint;
- Matrix matrix;
- Bitmap resizedBitmap;
- Bitmap bitmapOrg;
- private boolean init_flag = false;
- public DrawGraph(Context context, float degree) {
- super(context);
- Degree = degree;
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (init_flag == false) {
- init_flag = true;
- //그래프 그리기
- bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.man_energy_moment_graph2);
- // AutoScale 설정시에만 bitmapOrg 을 Scaled 한다.
- if (WpadScale.getAutoScale()) {
- //bitmapOrg= Bitmap.createScaledBitmap(bitmapOrg,356,186,true);
- bitmapOrg = Bitmap.createScaledBitmap(bitmapOrg, WpadScale.getWidth(bitmapOrg.getWidth()), WpadScale.getHeight(bitmapOrg.getHeight()), true);
- }
- matrix = new Matrix();
- mGraphPaint = new Paint();
- mGraphPaint.setAntiAlias(true);
- }
- // rotate the Bitmap
- matrix.reset();
- matrix.setRotate(Degree, bitmapOrg.getWidth() / 2, 0);
- //canvas.translate(Common.ImgPosion.GetX(292),Common.ImgPosion.GetY(360));
- canvas.translate(getPos.Get(R.drawable.man_energy_moment_graph2).x, getPos.Get(R.drawable.man_energy_moment_graph2).y); //201, 131
- canvas.drawBitmap(bitmapOrg, matrix, mGraphPaint);
- }
- public void Rotate_ReDraw(float degree) {
- Degree = degree;
- invalidate();
- }
- }
- /**
- * 실시간 사용량 추이 그래프 그리기
- **/
- public class DrawLine extends View {
- private float[] linePoint;
- private int[][] InputLinePoint;
- Paint mLinePaint;
- boolean init_flag = false;
- private int SEGS;
- private int count;
- private int colorKind; //0이면 어제, 1이면 오늘
- private static final int X = 0;
- private static final int Y = 1;
- public DrawLine(Context context, int[][] arrayDot_Yesterday, int Count, int ColorKind) {
- super(context);
- InputLinePoint = arrayDot_Yesterday;
- count = Count;
- colorKind = ColorKind;
- buildPoints();
- }
- private void buildPoints() {
- SEGS = count;
- final int ptCount = (SEGS + 1) * 2;
- linePoint = new float[ptCount * 2];
- for (int i = 0; i < SEGS; i++) {
- linePoint[i * 4 + X] = WpadScale.getWidth((float) InputLinePoint[0][i] + 4.5f);
- linePoint[i * 4 + Y] = WpadScale.getHeight((float) InputLinePoint[1][i] + 4.5f);
- if (i == 8) {
- linePoint[i * 4 + X + 2] = linePoint[i * 4 + X];
- linePoint[i * 4 + Y + 2] = linePoint[i * 4 + Y];
- } else {
- linePoint[i * 4 + X + 2] = WpadScale.getWidth((float) InputLinePoint[0][i + 1] + 4.5f);
- linePoint[i * 4 + Y + 2] = WpadScale.getHeight((float) InputLinePoint[1][i + 1] + 4.5f);
- }
- /*
- DebugLogOutput("linePoint[i*4 + X]: "+linePoint[i*4 + X]);
- DebugLogOutput("linePoint[i*4 + Y]: "+linePoint[i*4 + Y]);
- DebugLogOutput("linePoint[i*4 + X + 2]: "+linePoint[i*4 + X + 2]);
- DebugLogOutput("linePoint[i*4 + Y + 2]: "+linePoint[i*4 + Y + 2]);
- */
- }
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (init_flag == false) {
- init_flag = true;
- mLinePaint = new Paint();
- mLinePaint.setAntiAlias(true);
- if (colorKind == 0) {
- mLinePaint.setColor(Color.parseColor("#99d300"));
- } else {
- mLinePaint.setColor(Color.parseColor("#3588d5"));
- }
- mLinePaint.setStrokeWidth(3);
- }
- canvas.drawLines(linePoint, mLinePaint);
- }
- public void ReDraw(int[][] LinePoint, int Count, int ColorKind) {
- int[][] temp_LinePort = LinePoint;
- if (temp_LinePort != null) {
- InputLinePoint = new int[temp_LinePort.length][InputLinePoint[0].length];
- for (int i = 0; i < temp_LinePort.length; i++) {
- InputLinePoint[i] = temp_LinePort[i].clone();
- }
- }
- count = Count;
- colorKind = ColorKind;
- buildPoints();
- invalidate();
- }
- }
- /**
- * 누적사용량 그래프 그리기
- **/
- public class DrawRect extends View {
- Paint mLinePaint;
- boolean init_flag = false;
- //1280*800 : x: 829,y: 257
- private int X_Base = 650 + 13;
- private int Y_Base = 184 + 36;
- int Y_Coordinate;
- int RectHeight; //그래프의 높이
- int Index;
- int Size;
- int EnergyCount;
- /**
- * @param index <br>
- * 1-전기의 우리집 사용량, 2-전기의 동평형 사용량 <br>
- * 3-난방의 우리집 사용량, 4-난방의 동평형 사용량 <br>
- * 5-온수의 우리집 사용량, 6-온수의 동평형 사용량 <br>
- * 7-가스의 우리집 사용량, 8-가스의 동평형 사용량 <br>
- * 9-수도의 우리집 사용량, 10-수도의 동평형 사용량 <br>
- * 11-탄소의 우리집 사용량, 12-탄소의 동평형 사용량 <br>
- * @param size 막대 그래프의 가로 길이
- **/
- public DrawRect(Context context, int index, int size, int energyCount) {
- super(context);
- Index = index;
- Size = size;
- EnergyCount = energyCount;
- if (Common.SCREEN_TYPE == Common.SCREEN_TYPE_1280x800) {
- X_Base = 829;
- Y_Base = 257;
- }
- }
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- if (init_flag == false) {
- init_flag = true;
- mLinePaint = new Paint(); //Paint: 붓
- mLinePaint.setAntiAlias(true); //경계면을 부드럽게 처리
- /*
- *
- 99d300(전기)
- 26b6b4(난방)
- 3588d5(온수)
- 6c44a3(가스)
- a55f7f(수도)
- d4b96f(탄소)
- 동평형(#4b4b4b)
- *
- * */
- mLinePaint.setStyle(Paint.Style.FILL); //FILL: 색상이 채워지고 테두리는 그려지지 않음
- }
- switch (Index) {
- case 1://전기
- mLinePaint.setColor(Color.parseColor("#99d300"));
- if (EnergyCount >= 5) {
- Y_Coordinate = 0;
- } else if (EnergyCount == 3) {
- Y_Coordinate = 86;
- }
- RectHeight = 26;
- if (EnergyCount == 6) {
- RectHeight = RectHeight;
- }
- break;
- case 2:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- if (EnergyCount >= 5) {
- Y_Coordinate = 28;
- } else if (EnergyCount == 3) {
- Y_Coordinate = 28 + (86);
- }
- RectHeight = 12;
- if (EnergyCount == 6) {
- RectHeight = RectHeight;
- }
- break;
- case 3://난방
- mLinePaint.setColor(Color.parseColor("#26b6b4"));
- //5개 or 6개 일때만
- if (EnergyCount == 6) {
- Y_Coordinate = (71);
- } else {
- // EnergyCount == 5
- Y_Coordinate = (86);
- }
- RectHeight = 26;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 4:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- if (EnergyCount == 6) {
- Y_Coordinate = (71 + 28);
- } else {
- Y_Coordinate = (86 + 28);
- }
- RectHeight = 12;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 5://온수
- mLinePaint.setColor(Color.parseColor("#3588d5"));
- if (EnergyCount == 5) {
- Y_Coordinate = (86 * 2);
- } else if (EnergyCount == 3) {
- Y_Coordinate = (332 - Y_Base);
- } else if (EnergyCount == 6) {
- Y_Coordinate = (71 * 2);
- }
- RectHeight = 26;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 6:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- if (EnergyCount == 5) {
- Y_Coordinate = ((86 * 2) + (28));
- } else if (EnergyCount == 3) {
- Y_Coordinate = (332 - Y_Base) + 26;
- } else if (EnergyCount == 6) {
- Y_Coordinate = ((71 * 2) + (28));
- }
- RectHeight = 12;
- if (EnergyCount == 6) {
- // Y_Coordinate = Y_Coordinate + 2;
- }
- break;
- case 7://연료전지
- mLinePaint.setColor(Color.parseColor("#3588d5"));
- if (EnergyCount == 6) {
- Y_Coordinate = (71 * 3);
- } else if (EnergyCount == 3) {
- Y_Coordinate = (258);
- } else {
- Y_Coordinate = (86 * 3);
- }
- RectHeight = 26;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 8:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- if (EnergyCount == 6) {
- Y_Coordinate = ((71 * 3) + (28));
- } else if (EnergyCount == 3) {
- Y_Coordinate = ((258) + (28));
- } else {
- Y_Coordinate = ((86 * 3) + (28));
- }
- RectHeight = 12;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- // Y_Coordinate = Y_Coordinate + 1;
- }
- break;
- case 9://연료전지
- mLinePaint.setColor(Color.parseColor("#99d300"));
- if (EnergyCount == 5) {
- Y_Coordinate = (86 * 4);
- } else if (EnergyCount == 3) {
- Y_Coordinate = (107);
- } else if (EnergyCount == 6) {
- Y_Coordinate = (71 * 4);
- }
- RectHeight = 26;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 10:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- if (EnergyCount == 5) {
- Y_Coordinate = ((86 * 4) + (28));
- } else if (EnergyCount == 3) {
- Y_Coordinate = (172) + 28;
- } else if (EnergyCount == 6) {
- Y_Coordinate = ((71 * 4) + (28));
- }
- RectHeight = 12;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 11://탄소
- mLinePaint.setColor(Color.parseColor("#d4b96f"));
- Y_Coordinate = (71 * 5);
- RectHeight = 26;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- case 12:
- mLinePaint.setColor(Color.parseColor("#4b4b4b"));
- Y_Coordinate = ((71 * 5) + (28));
- RectHeight = 12;
- if (EnergyCount == 6) {
- // RectHeight = RectHeight - 1;
- }
- break;
- default:
- break;
- }
- /*
- DebugLogOutput("===============================");
- DebugLogOutput("[drawRect] - X_Base :" +X_Base);
- DebugLogOutput("[drawRect] - Y_Base :" +Y_Base);
- DebugLogOutput("[drawRect] - Y_Coordinate :" +(Y_Coordinate));
- DebugLogOutput("[drawRect] - Size :" +Size);
- DebugLogOutput("[drawRect] - RectHeight :" +RectHeight);
- DebugLogOutput("===============================");
- */
- int x_1280 = 0;
- int y_800 = 0;
- canvas = getPos.GetScaleCanvas(canvas);
- y_800 = getPos.GetGraph_y_1280(EnergyCount, Index);
- canvas.translate(Common.ImgPosion.GetX(X_Base + x_1280), Common.ImgPosion.GetY(Y_Base + (Y_Coordinate) + y_800));
- //canvas.translate(WpadScale.getWidth(X_Base+x_1280), WpadScale.getHeight(Y_Base+(Y_Coordinate) + y_800));
- canvas.drawRect(0, 0, (float) WpadScale.getWidth(Size), (float) WpadScale.getHeight(RectHeight), mLinePaint);
- }
- /**
- * @param size
- * @param energyCount
- */
- public void ReDraw(int size, int energyCount) {
- Size = size;
- EnergyCount = energyCount;
- invalidate();
- }
- }
- /**
- * 검침기의 사용량을 표시한다.
- *
- * @param TextId - 변경할 대상 ID 를 입력한다. ( ID.realMain.text.ELEC ~ ID.realMain.text.CALORIE [ELEC or WATER or GAS or HOTWATER or CALORIE] )
- * @param value - 변경할 값을 입력한다.
- */
- @SuppressLint("DefaultLocale")
- private void Draw_TextValueWrite(int TextId, double value) {
- String str = new String();
- RealTimeData_Double = value;
- if (RealTimeData == null) return;
- switch (TextId) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- case ID.IcEnergyMgrID.DataKind.KEPCO:
- case ID.IcEnergyMgrID.DataKind.SOLAR:
- case ID.IcEnergyMgrID.DataKind.FUEL:
- if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- str = Convter2_DoubleTOStr(value);
- str += " kWh";
- } else {
- str = Convter1_DoubleTOStr(value);
- str += " W";
- }
- RealTimeData.setText(str);
- //DebugLogOutput("[Draw_TextValueWrite] - ELEC str = (" + str + ") " + "value = " + value);
- break;
- default:
- Log.e(TAG, "[Draw_TextValueWrite] - TextId Out of range !!! (" + TextId + ")");
- break;
- }
- }
- /**
- * 실시간 검침값 1가지 (ELEC) 에 대하여 <br>
- * 소수점을 제거한다.
- *
- * @param value - 현재검침값
- * @return (String) 포멧변환된 스트링
- */
- private String Convter1_DoubleTOStr(double value) {
- if (value <= 0) return "0";
- String str = new String();
- try {
- str = String.format("%.0f", value);
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return "0";
- } catch (Exception e) {
- Log.e(TAG, "[Convter1_DoubleTOStr] - [Exception Error] ");
- Log.e(TAG, "[Convter1_DoubleTOStr] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "0";
- }
- return str;
- }
- /**
- * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
- * 소수점 3자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
- *
- * @param value - 현재검침값
- * @return (String) 포멧변환된 스트링
- */
- private String Convter2_DoubleTOStr(double value) {
- if (value <= 0) return "0";
- String str = new String();
- try {
- str = String.format("%.3f", value);
- // 끝자리 0 자르기
- byte[] strArray = str.getBytes();
- for (int i = str.length() - 1; i >= 0; i--) {
- if (strArray[i] == '0') {
- str = str.substring(0, i);
- } else break;
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return "0";
- } catch (Exception e) {
- Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
- Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "0";
- }
- str.trim();
- if (str.endsWith(".") == true) {
- return str.substring(0, str.length() - 1);
- }
- return str;
- }
- /**
- * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
- * 소수점 1자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
- *
- * @param value - 현재검침값
- * @return (String) 포멧변환된 스트링
- */
- private String Convter2_DoubleTOStr_CutPoint1(double value) {
- if (value <= 0) return "0";
- String str = new String();
- try {
- str = String.format("%.1f", value);
- // 끝자리 0 자르기
- byte[] strArray = str.getBytes();
- for (int i = str.length() - 1; i >= 0; i--) {
- if (strArray[i] == '0') {
- str = str.substring(0, i);
- } else break;
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return "0";
- } catch (Exception e) {
- Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
- Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "0";
- }
- str.trim();
- if (str.endsWith(".") == true) {
- return str.substring(0, str.length() - 1);
- }
- return str;
- }
- /**
- * 실시간 검침값 4가지 (WATER, GAS, HOTWATER, CALORIE) 에 대하여 <br>
- * 소수점 2자리까지만 String 으로 변환을 하며, 끝자리가 0인경우 삭제한다.
- *
- * @param value - 현재검침값
- * @return (String) 포멧변환된 스트링
- */
- private String Convter2_DoubleTOStr_CutPoint2(double value) {
- if (value <= 0) return "0";
- String str = new String();
- try {
- str = String.format("%.2f", value);
- // 끝자리 0 자르기
- byte[] strArray = str.getBytes();
- for (int i = str.length() - 1; i >= 0; i--) {
- if (strArray[i] == '0') {
- str = str.substring(0, i);
- } else break;
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return "0";
- } catch (Exception e) {
- Log.e(TAG, "[Convter2_DoubleTOStr] - [Exception Error] ");
- Log.e(TAG, "[Convter2_DoubleTOStr] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return "0";
- }
- str.trim();
- if (str.endsWith(".") == true) {
- return str.substring(0, str.length() - 1);
- }
- return str;
- }
- /* // =================================================================================================
- // [[ TimeCheck ]] region
- // =================================================================================================
- @SuppressLint("HandlerLeak")
- private Handler mTimeCheckHandler = new Handler()
- {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg)
- {
- if(msg.what == 0)
- {
- mTimeCheckHandler.sendEmptyMessageDelayed(0, 1000*10); //10초 마다
- nowCal = Calendar.getInstance();
- *//*
- DebugLogOutput("[TimeCheck] time is tick");
- DebugLogOutput("[TimeCheck] nowCal.get(Calendar.DATE) :" + nowCal.get(Calendar.DATE) );
- DebugLogOutput("[TimeCheck] DateCal.get(Calendar.DATE) :" + DateCal.get(Calendar.DATE) );
- DebugLogOutput("[TimeCheck] Year.get(Calendar.DATE) :" + YearCal.get(Calendar.YEAR) );
- DebugLogOutput("[TimeCheck] DateCal.get(Calendar.DATE) :" + DateCal.get(Calendar.DATE) );
- *//*
- if(nowCal.get(Calendar.DATE) != DateCal.get(Calendar.DATE))
- {
- DebugLogOutput("[TimeCheck] Date is changed");
- Draw_Update();
- if(RealtimeMeterUse == true)
- {
- RemoveUsedData();
- ShowUsedDataGraph();
- }
- else
- {
- }
- SendMSG_RandomCheckHandler();
- DateCal = Calendar.getInstance();
- HourCal = Calendar.getInstance();
- MonthCal = Calendar.getInstance();
- YearCal = Calendar.getInstance();
- }
- if(nowCal.get(Calendar.HOUR_OF_DAY) != HourCal.get(Calendar.HOUR_OF_DAY))
- {
- DebugLogOutput("[TimeCheck] Hour is changed");
- Draw_Update();
- if(RealtimeMeterUse == true)
- {
- RemoveUsedData();
- ShowUsedDataGraph();
- }
- else
- {
- //ShowUsedDataGraph_DayVersion();
- SendMSG_RandomCheckHandler_forDayData(); //현장에서 동시 다발적으로 메시지를 요청해서 수신 못하는 세대 있음
- }
- HourCal = Calendar.getInstance();
- }
- if(nowCal.get(Calendar.MONTH) != MonthCal.get(Calendar.MONTH))
- {
- DebugLogOutput("[TimeCheck] Month is changed");
- MonthCal = Calendar.getInstance();
- SendMSG_RandomCheckHandler();
- }
- if(nowCal.get(Calendar.YEAR) != YearCal.get(Calendar.YEAR))
- {
- DebugLogOutput("[TimeCheck] Year is changed");
- YearCal = Calendar.getInstance();
- SendMSG_RandomCheckHandler();
- }
- //수정필요
- // 목표량값이 달라진 경우 갱신
- if (OPERATION_MODE == Common.MODE_NOMAL)
- {
- WallpadStatusData StatusDBMGR = null;
- try
- {
- StatusDBMGR = new WallpadStatusData(getContext());
- boolean TargetValueChanged = false;
- for (int i = 0; i < mNumberOfEnergy; i++)
- {
- if (monthTableClass[i] != null)
- {
- if (monthTableClass[i].Goal.equalsIgnoreCase(StatusDBMGR.GetRemoteMeteringTargetValue(i)) == false)
- {
- DebugLogOutput("[TimeCheck] GetRemoteMeteringTargetValue is changed");
- DebugLogOutput("[TimeCheck] monthTableClass[" + i + "].Goal :" + monthTableClass[i].Goal);
- DebugLogOutput("[TimeCheck] StatusDBMGR.GetRemoteMeteringTargetValue(" + i + ") :"
- + StatusDBMGR.GetRemoteMeteringTargetValue(i));
- TargetValueChanged = true;
- monthTableClass[i].Goal = StatusDBMGR.GetRemoteMeteringTargetValue(i);
- }
- }
- }
- StatusDBMGR.closeDB();
- if (TargetValueChanged == true)
- {
- DebugLogOutput("[TimeCheck] ShowMonthGraph() is called");
- ShowMonthGraph();
- }
- }
- catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re );
- }
- catch (Exception e)
- {
- if (StatusDBMGR != null)
- {
- StatusDBMGR.closeDB();
- }
- e.printStackTrace();
- }
- }
- }
- }
- };
- boolean Flag_SendMSG_RandomCheckHandler = false;
- private void SendMSG_RandomCheckHandler()
- {
- try
- {
- int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
- if(DelayTime < 1)
- {
- return;
- }
- DebugLogOutput("[SendMSG_RandomCheckHandler] DelayTime : "+ DelayTime);
- mRandomCheckHandler.sendEmptyMessageDelayed(0, 1000 * DelayTime);
- Flag_SendMSG_RandomCheckHandler = true;
- }
- catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re );
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return;
- }
- }
- @SuppressLint("HandlerLeak")
- private Handler mRandomCheckHandler = new Handler()
- {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg)
- {
- if(msg.what == 0)
- {
- Flag_SendMSG_RandomCheckHandler = false;
- DebugLogOutput("[mRandomCheckHandler] ShowMonthGraph() will be called");
- ShowMonthGraph();
- }
- }
- };
- */
- /**
- * ==================================================
- **//*
- boolean Flag_SendMSG_RandomCheckHandler_forDayData = false;
- private void SendMSG_RandomCheckHandler_forDayData()
- {
- try
- {
- int DelayTime = StringUtil.GetDelayTimeBaseIP(getContext());
- if(DelayTime < 1)
- {
- return;
- }
- DebugLogOutput("[SendMSG_RandomCheckHandler_forDayData] DelayTime : "+ DelayTime);
- mRandomCheckHandler_forDayData.sendEmptyMessageDelayed(0, 1000 * DelayTime);
- Flag_SendMSG_RandomCheckHandler_forDayData = true;
- }
- catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re );
- }
- catch (Exception e)
- {
- e.printStackTrace();
- return;
- }
- }
- @SuppressLint("HandlerLeak")
- private Handler mRandomCheckHandler_forDayData = new Handler()
- {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg)
- {
- if(msg.what == 0)
- {
- Flag_SendMSG_RandomCheckHandler_forDayData = false;
- DebugLogOutput("[mRandomCheckHandler_forDayData] ShowUsedDataGraph_DayVersion() will be called");
- ShowUsedDataGraph_DayVersion();
- }
- }
- };*/
- // =================================================================================================
- // [[ Sample ]] region
- // =================================================================================================
- private double[] SampleArrayElec;
- private double[] SampleArrayWater;
- private double[] SampleArrayGas;
- private double[] SampleArrayHotWater;
- private double[] SampleArrayCalorie;
- private int SampleCountElec;
- private int SampleCountWater;
- private int SampleCountGas;
- private int SampleCountHotWater;
- private int SampleCountCalorie;
- /**
- * (영업샘플모드) 실시간검침기 데이터를 변경한다.
- */
- @SuppressLint("HandlerLeak")
- private Handler mSampleHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- switch (NowShowEnergyKind) {
- case ID.IcEnergyMgrID.DataKind.ELECTRIC:
- if (SampleArrayElec != null) {
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.ELECTRIC, SampleArrayElec[SampleCountElec]);
- if (++SampleCountElec >= SampleArrayElec.length) SampleCountElec = 0;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.WATER:
- if (SampleArrayWater != null) {
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.WATER, SampleArrayWater[SampleCountWater]);
- if (++SampleCountWater >= SampleArrayWater.length) SampleCountWater = 0;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.GAS:
- if (SampleArrayGas != null) {
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.GAS, SampleArrayGas[SampleCountGas]);
- if (++SampleCountGas >= SampleArrayGas.length) SampleCountGas = 0;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.HOTWATER:
- if (SampleArrayHotWater != null) {
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HOTWATER, SampleArrayHotWater[SampleCountHotWater]);
- if (++SampleCountHotWater >= SampleArrayHotWater.length)
- SampleCountHotWater = 0;
- }
- break;
- case ID.IcEnergyMgrID.DataKind.HEATING:
- if (SampleArrayCalorie != null) {
- Draw_TextValueWrite(ID.IcEnergyMgrID.DataKind.HEATING, SampleArrayCalorie[SampleCountCalorie]);
- if (++SampleCountCalorie >= SampleArrayCalorie.length)
- SampleCountCalorie = 0;
- }
- break;
- default:
- break;
- }
- ReDraw();
- mSampleHandler.sendEmptyMessageDelayed(0, 5000);
- }
- }
- };
- /**
- * (영업샘플모드) 실시간검침기 데이터를 변경을 시작한다.
- */
- private void Sample_Start() {
- if (OPERATION_MODE != Common.MODE_BUSINESS_SAMPLE) return;
- SampleArrayElec = new double[]{1320.23, 2405.867, 3090, 1560, 101, 90.98};
- SampleArrayWater = new double[]{0.101, 1.121, 0.5, 0.8, 1.22, 1.53};
- SampleArrayGas = new double[]{2.2, 0.7, 1.4, 3.0, 1.1, 2.6};
- SampleArrayHotWater = new double[]{0.101, 1.121, 0.5, 0.8, 1.22, 1.53};
- SampleArrayCalorie = new double[]{0, 0.3, 0.55, 1.0, 2.333};
- SampleCountElec = 0;
- SampleCountWater = 0;
- SampleCountGas = 0;
- SampleCountHotWater = 0;
- SampleCountCalorie = 0;
- if (mSampleHandler != null) mSampleHandler.sendEmptyMessage(0);
- ShowUsedDataGraph();
- }
- /**
- * (영업샘플모드) 실시간검침기 데이터를 변경을 중지한다.
- */
- private void Sample_End() {
- if (OPERATION_MODE != Common.MODE_BUSINESS_SAMPLE) return;
- if (mSampleHandler != null) mSampleHandler.removeMessages(0);
- }
- // =================================================================================================
- // [[ Device ]] region
- // =================================================================================================
- /**
- * 디바이스 API 를 Load 한다.
- *
- * @param wpapi - 생성시 전달받은 WallPadAPI
- * @return (int) - >=0 : 성공, <0 : 실패
- */
- private int Device_ApiLoad(WallPadAPI wpapi) {
- // 1. Mode Check
- if (OPERATION_MODE != Common.MODE_NOMAL) return -1;
- DebugLogOutput("[Device_ApiLoad] - Start");
- // 2. wpapi Check
- if (wpapi == null) {
- Log.e(TAG, "[Device_ApiLoad] - wpapi is null");
- return -2;
- }
- // 3. Load API
- DebugLogOutput("[Device_ApiLoad] - Step1 : RemoteMeter API Load...");
- try {
- realTimeMeterAPI = wpapi.Get_RealTimeMeterController();
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return -100;
- } catch (Exception e) {
- Log.e(TAG, "[Device_ApiLoad] - [Exception Error] wpapi.Get_RealTimeMeterController");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -100;
- }
- if (realTimeMeterAPI == null) {
- Log.e(TAG, "[Device_ApiLoad] - realTimeMeterAPI is null");
- return -4;
- }
- DebugLogOutput("[Device_ApiLoad] - OK");
- return 0;
- }
- /**
- * 제어기 상태를 가져온다.
- *
- * @param real - (boolean) true : 실시간 , false : 가장최근
- * @return (int) - >=0 : 성공, <0 : 실패
- */
- @SuppressWarnings("unused")
- private int Device_Update(boolean real) {
- //DebugLogOutput("[Device_Update] - Start (real : " + real + ")");
- // 1. Api Load Check
- if (realTimeMeterAPI == null) {
- Log.e(TAG, "[Device_Update] - remoteMeterApi unload !!!");
- return -1;
- }
- // 2. reflash
- try {
- int ret = realTimeMeterAPI.Refresh(real);
- if (ret < 0) {
- Log.e(TAG, "[Device_Update] - realTimeMeterAPI.Refresh - ret (" + ret + ")" + realTimeMeterAPI.ErrorCode.ErrStr());
- return -2;
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return -100;
- } catch (Exception e) {
- Log.e(TAG, "[Device_Update] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -100;
- }
- // 3. Range Check
- if (realTimeMeterAPI.data == null) {
- Log.e(TAG, "[Device_Update] - realTimeMeterAPI.data is null !!!");
- return -9;
- }
- if (realTimeMeterAPI.data.Elec.Now >= 1000000) {
- Log.e(TAG, "[Device_Update] - ElecNow data Out of range !!! (" + realTimeMeterAPI.data.Elec.Now + ")");
- return -10;
- }
- if (realTimeMeterAPI.data.Water.Now >= 1000) {
- Log.e(TAG, "[Device_Update] - WaterNow data Out of range !!! (" + realTimeMeterAPI.data.Water.Now + ")");
- return -11;
- }
- if (realTimeMeterAPI.data.HotWater.Now >= 1000) {
- Log.e(TAG, "[Device_Update] - HotWaterNow data Out of range !!! (" + realTimeMeterAPI.data.HotWater.Now + ")");
- return -12;
- }
- if (realTimeMeterAPI.data.Gas.Now >= 1000) {
- Log.e(TAG, "[Device_Update] - GasNow data Out of range !!! (" + realTimeMeterAPI.data.Gas.Now + ")");
- return -13;
- }
- if (realTimeMeterAPI.data.Calorie.Now >= 1000) {
- Log.e(TAG, "[Device_Update] - CaloryNow data Out of range !!! (" + realTimeMeterAPI.data.Calorie.Now + ")");
- return -14;
- }
- // 4. Data Copy
- data = realTimeMeterAPI.data;
- // 5. Debug msg
- if (DEBUG_REALMETER_DATA_LOG_ON == true) {
- DebugLogOutput(data.ToDebugString());
- DebugLogOutput("[Device_Update] - OK");
- }
- return 0;
- }
- /*
- private boolean getCurrentDisplayEnergyScreen()
- {
- return ((MainActivity)(super.getContext())).CheckCurrentEnergyScreen();
- }
- */
- /**
- * (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
- * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
- * 본 딜레이 코드를 임시로 적용한다.
- */
- @SuppressLint("HandlerLeak")
- protected Handler mIntDriverCheckHandler = new Handler() {
- @SuppressLint("HandlerLeak")
- @Override
- public void handleMessage(Message msg) {
- if (msg.what == 0) {
- //Log.d(TAG, "-------------- " + getCurrentDisplayEnergyScreen() );
- if (Device_ApiLoad(m_wpapi) >= 0) {
- if (Device_Update(false) == 0) {
- mIntDriverCheckHandler.sendEmptyMessageDelayed(1, 10);
- } else {
- mIntDriverCheckHandler.sendEmptyMessageDelayed(0, 10000);
- }
- } else {
- DebugLogOutput("mInitDriverCheckHandler --> m_InitRealMeterCtrl == null");
- mIntDriverCheckHandler.sendEmptyMessageDelayed(0, 10000);
- }
- } else if (msg.what == 1) {
- DebugLogOutput("mIntDriverCheckHandler == succes addBrActionName");
- if (realTimeMeterAPI != null) {
- Device_BrRegistration(true);
- WallpadDeviceSet devset = new WallpadDeviceSet(getContext());
- int[] setdata = devset.Get_RealTimeMetor_Info();
- devset.closeDB();
- if ((mThread_saveRealMeterData == null) && (setdata[0] == 1)) {
- mThread_saveRealMeterData = new SaveRealMeterData();
- mThread_saveRealMeterData.start();
- }
- RemoveUsedData();
- ShowUsedDataGraph();
- }
- }
- }
- };
- /**
- * 디바이스에 알림 BR 을 등록한다. (에너지미터)
- *
- * @return (int) - >=0 : 성공, <0 : 실패
- */
- private int Device_BrRegistration(boolean OnOff) {
- DebugLogOutput("[Device_BrRegistration] - Start (OnOff:" + OnOff + ")");
- String BR_NAME = ID.IcEnergyMgrID.BR_REALMETER;
- // 1. Api Load Check
- if (realTimeMeterAPI == null) {
- Log.e(TAG, "[Device_BrRegistration] - remoteMeterApi unload !!!");
- return -1;
- }
- if (OnOff) {
- try {
- //DebugLogOutput("[Device_BrRegistration] - regChangedBR START");
- realTimeMeterAPI.regChangedBR(BR_NAME);
- //DebugLogOutput("[Device_BrRegistration] - regChangedBR END");
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return -101;
- } catch (Exception e) {
- Log.e(TAG, "[Device_BrRegistration] - [Exception Error] realTimeMeterAPI.regChangedBR");
- Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -101;
- }
- super.addBrActionFilter(BR_NAME);
- } else {
- try {
- //DebugLogOutput("[Device_BrRegistration] - unregChangedBR START");
- realTimeMeterAPI.unregChangedBR(BR_NAME);
- //DebugLogOutput("[Device_BrRegistration] - unregChangedBR END");
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return -102;
- } catch (Exception e) {
- Log.e(TAG, "[Device_BrRegistration] - [Exception Error] realTimeMeterAPI.unregChangedBR");
- Log.e(TAG, "[Device_BrRegistration] - " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return -102;
- }
- super.removeBrActionFilter(BR_NAME);
- }
- return 0;
- }
- // =================================================================================================
- // [[ Thread ]] region
- // =================================================================================================
- /**
- * 실시간검침 데이터를 DB에 저장하는 쓰레드. <br>
- * 10분에 한번씩 저장
- */
- @SuppressLint("UseValueOf")
- class SaveRealMeterData extends Thread {
- @Override
- public void run() {
- super.run();
- DebugLogOutput("SaveRealMeterData extends Thread is started");
- int ret;
- wallpaddbmgr WallpadDBMGRforThread = null;
- while (true) {
- try {
- Thread.sleep(1000 * 60 * 3); //3분마다
- if (realTimeMeterAPI != null) {
- ret = realTimeMeterAPI.Refresh(false);
- if (ret == 0) {
- DebugLogOutput("remoteMeterAPI.Refresh is success");
- DebugLogOutput("remoteMeterAPI.ElecAccrued :" + realTimeMeterAPI.data.Elec.Acc);
- WallpadDBMGRforThread = new wallpaddbmgr(getContext());
- WallpadDBMGRforThread.InsertRealTimeMeterData(
- new Double(realTimeMeterAPI.data.Elec.Now).toString(),
- new Double(realTimeMeterAPI.data.Elec.Acc).toString(),
- new Double(realTimeMeterAPI.data.Water.Now).toString(),
- new Double(realTimeMeterAPI.data.Water.Acc).toString(),
- new Double(realTimeMeterAPI.data.Gas.Now).toString(),
- new Double(realTimeMeterAPI.data.Gas.Acc).toString(),
- new Double(realTimeMeterAPI.data.HotWater.Now).toString(),
- new Double(realTimeMeterAPI.data.HotWater.Acc).toString(),
- new Double(realTimeMeterAPI.data.Calorie.Now).toString(),
- new Double(realTimeMeterAPI.data.Calorie.Acc).toString()
- );
- int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
- DebugLogOutput("WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
- if (tempInt > 6000) {
- WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
- }
- WallpadDBMGRforThread.closeDB();
- } else {
- DebugLogOutput("remoteMeterAPI.Refresh is fail");
- }
- } else {
- DebugLogOutput("remoteMeterApi is null");
- }
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- if (WallpadDBMGRforThread != null) {
- WallpadDBMGRforThread.closeDB();
- }
- DebugLogOutput("SaveRealMeterData extends Thread occurs exception Error");
- e1.printStackTrace();
- }
- }
- }
- }
- iMAPRemotemeter imapRemotemeter;
- boolean isResponseArrive = false;
- boolean mEMS_Enable;
- int mNumberOfEnergy;
- int CalendarYear;
- int CalendarMonth;
- int CalendarDay;
- int ShowNowEnergyIndex = 0;
- MonthTableClass monthTableClass[] = new MonthTableClass[3];
- class MonthTableClass {
- private String Use;
- public MonthTableClass(String Use) {
- this.Use = Use;
- }
- public String getUse() {
- return Use;
- }
- }
- private int CalcGraphWidth(String use, String Goal) {
- try {
- if (use.equals("") == true) {
- return 0;
- }
- int x = (int) (Float.valueOf(use) * 260 / Float.valueOf(Goal)); //275:216 = 332:260 이전버전과 신버전 비율비교로 260계산
- if (x > 332) {
- return 332; //그래프 최대 길이
- }
- return x;
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return 0;
- } catch (Exception e) {
- ////e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return 0;
- }
- }
- private String NumberToKoreanWon(String Input) {
- String tempString = "요금 정보 없음";
- int tempInt = 0;
- if (Input == null) {
- return tempString;
- }
- if (Input.equals("") == true) {
- return tempString;
- }
- if (Input.length() == 0) {
- return tempString;
- }
- try {
- tempInt = Integer.parseInt(Input);
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- return tempString;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return tempString;
- }
- tempString = String.format("%,d", tempInt);
- return (tempString + "원");
- }
- private void DrawGraph_andValues(int EnergyCount) {
- DebugLogOutput("DrawGraph_andValues");
- try {
- if (TempEnergyCount != EnergyCount) {
- if (TempEnergyCount == 3) {
- if (getLayout() != null) getLayout().removeView(Background_03);
- 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);
- 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);
- //한전
- if (getLayout() != null) getLayout().removeView(Kepco_HomeUse);
- if (getLayout() != null) getLayout().removeView(drawRect[1]);
- if (getLayout() != null) getLayout().removeView(drawRect[2]);
- 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);
- 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);
- Kepco_HomeUse.setVisibility(View.GONE);
- if (getLayout() != null) getLayout().addView(drawRect[1]);
- if (getLayout() != null) getLayout().addView(drawRect[2]);
- //연료전지
- if (getLayout() != null) getLayout().removeView(Fuel_HomeUse);
- if (getLayout() != null) getLayout().removeView(drawRect[9]);
- if (getLayout() != null) getLayout().removeView(drawRect[10]);
- 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);
- 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);
- if (getLayout() != null) getLayout().addView(drawRect[9]);
- if (getLayout() != null) getLayout().addView(drawRect[10]);
- //태양광
- if (getLayout() != null) getLayout().removeView(Photovoltaics_HomeUse);
- if (getLayout() != null) getLayout().removeView(drawRect[7]);
- if (getLayout() != null) getLayout().removeView(drawRect[8]);
- 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);
- 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);
- if (getLayout() != null) getLayout().addView(drawRect[7]);
- if (getLayout() != null) getLayout().addView(drawRect[8]);
- }
- TempEnergyCount = EnergyCount;
- }
- if (OPERATION_MODE == Common.MODE_NOMAL) {
- //WallpadMain으로 검침 및 목표량 정보 intent로 보내기
- Intent intent = new Intent();
- intent.setAction("WALLPAD_NOTIFY");
- intent.putExtra("KIND", define.NOTIFY_ENERGY_DATA);
- intent.putExtra(Common.ENERGY_INTENT_ENERGY_COUNT, EnergyCount);
- intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_YEAR, EnergyDataGetCal.get(Calendar.YEAR));
- intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MONTH, (EnergyDataGetCal.get(Calendar.MONTH) + 1));
- intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_DAY, EnergyDataGetCal.get(Calendar.DATE));
- intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_HOUR, EnergyDataGetCal.get(Calendar.HOUR_OF_DAY));
- intent.putExtra(Common.ENERGY_INTENT_GETDATA_TIME_MINUTE, EnergyDataGetCal.get(Calendar.MINUTE));
- if (monthTableClass[0] != null) {
- intent.putExtra(Common.ENERGY_INTENT_USE_ELECTRIC, monthTableClass[0].Use); //한전
- }
- if (monthTableClass[1] != null) {
- intent.putExtra(Common.ENERGY_INTENT_USE_WATER, monthTableClass[1].Use); //태양광
- }
- if (monthTableClass[2] != null) {
- intent.putExtra(Common.ENERGY_INTENT_USE_GAS, monthTableClass[2].Use); //연료전지
- }
- Log.i("HIGH", "ENERGY_INTENT_ BR Send " + define.NOTIFY_ENERGY_DATA);
- getContext().sendBroadcast(intent);
- }
- DebugLogOutput("Draw Month Graph");
- //Kepco_HomeUse.setText(monthTableClass[0].Use);
- //목표량이 없으므로, Goal 값은 USE 값을 이용해서 구한다.
- double goal = (double) (Double.valueOf(monthTableClass[1].Use)) + (Double.valueOf(monthTableClass[2].Use));
- //drawRect[1].ReDraw(CalcGraphWidth(monthTableClass[0].Use, goal + ""), mNumberOfEnergy);
- Photovoltaics_HomeUse.setText(monthTableClass[1].Use);
- //goal = (double) (Double.valueOf(monthTableClass[1].Use) * 1.5);
- drawRect[9].ReDraw(CalcGraphWidth(monthTableClass[1].Use, goal + ""), mNumberOfEnergy);
- Fuel_HomeUse.setText(monthTableClass[2].Use);
- //goal = (double) (Double.valueOf(monthTableClass[2].Use) * 1.2);
- drawRect[7].ReDraw(CalcGraphWidth(monthTableClass[2].Use, goal + ""), mNumberOfEnergy);
- //if (RealtimeMeterUse == false) {
- // 실시간 검침 사용하지 않음
- //ShowUsedDataGraph_DayVersion();
- //}
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * @param InputType 0 당월, 1 일별<br>
- * @param //year - 연도<br>
- * @param //month - 월<br>
- * @param //energy - 0 전기, 1 수도, 2 가스, 3 온수, 4 열량, 5 탄소<br>
- * @description 서버로 부터 데이터를 받아와 분석하고 표현하는 함수<br>
- */
- private void LoadRemotemeterDataFromServer(int InputType, int Year, int Month, int Energy) {
- final int inputType = InputType;
- final int year = Year;
- final int month = (Month + 1);
- try {
- DebugLogOutput("LoadRemotemeterDataFromServer - " + year + " " + month);
- isResponseArrive = false;
- imapRemotemeter = new iMAPRemotemeter(getContext());
- switch (inputType) {
- case 0: //당월
- //imapRemotemeter.DoWork(true, true, true, true, true, true, true, mEMS_Enable, year, month);
- imapRemotemeter.DoWorkVIP(true, true, false, true, true,true, year, month);
- break;
- case 1: //일별
- //imapRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
- imapRemotemeter.DoWorkVIP(false, true, true, true, true, true, year, month);
- break;
- case 2: //Real Time
- //imapRemotemeter.DoWork(false, true, true, true, true, true, false, false, year, month);
- imapRemotemeter.DoWDoWorkVIP_RealTime(false, false, false, true, true);
- break;
- default:
- break;
- }
- imapRemotemeter.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- String TempString = null;
- isResponseArrive = true;
- // DB
- WallpadStatusData StatusDBMGR = null;
- try {
- StatusDBMGR = new WallpadStatusData(getContext());
- DebugLogOutput("Load Data From Server - ProcSuccess");
- DebugLogOutput("inputType " + Integer.toString(inputType));
- boolean result = false;
- switch (inputType) {
- case 0: // 당월
- EnergyDataGetCal = Calendar.getInstance();
- int NumberOfValuelist = imapRemotemeter.SetItem("valuelist");
- if (NumberOfValuelist != 0) {
- for (int i = 0; i < NumberOfValuelist; i++) {
- if ((Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "month")) == (CalendarMonth + 1)) && (Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "year")) == (CalendarYear))) {
- result = true;
- int Temp_mNumberOfEnergy = mNumberOfEnergy;
- if (Temp_mNumberOfEnergy == 2) {
- Temp_mNumberOfEnergy = 3;
- }
- for (int j = 0; j < Temp_mNumberOfEnergy; j++) {
- switch (j) {
- case 0:
- monthTableClass[j] = new MonthTableClass("");
- if (imapRemotemeter.GetAttributeVal(i, "kepco_used") != null) {
- if (imapRemotemeter.GetAttributeVal(i, "kepco_used").equals("1000000") == true) {
- monthTableClass[j].Use = "0";
- } else {
- monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "kepco_used");
- }
- }
- break;
- case 1:
- monthTableClass[j] = new MonthTableClass("");
- if (imapRemotemeter.GetAttributeVal(i, "photovoltaics_used") != null) {
- if (imapRemotemeter.GetAttributeVal(i, "photovoltaics_used").equals("1000000") == true) {
- monthTableClass[j].Use = "0";
- } else {
- monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "photovoltaics_used");
- }
- }
- break;
- case 2:
- monthTableClass[j] = new MonthTableClass("");
- if (imapRemotemeter.GetAttributeVal(i, "fuelcell_used") != null) {
- if (imapRemotemeter.GetAttributeVal(i, "fuelcell_used").equals("1000000") == true) {
- monthTableClass[j].Use = "0";
- } else {
- monthTableClass[j].Use = imapRemotemeter.GetAttributeVal(i, "fuelcell_used");
- }
- }
- break;
- default:
- break;
- }
- }
- }
- }
- if (result == true) {
- switch (mNumberOfEnergy) {
- case 2:
- case 3:
- case 5:
- case 6:
- DrawGraph_andValues(mNumberOfEnergy);
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
- intent.putExtra("FromWhere", "IcEnergyMgrScreen");
- if ((mNumberOfEnergy == 2) || (mNumberOfEnergy == 3)) {
- intent.putExtra("kepco_used", monthTableClass[0].Use);
- intent.putExtra("photovoltaics_used", monthTableClass[1].Use);
- intent.putExtra("fuelcell_used", monthTableClass[2].Use);
- }
- getContext().sendBroadcast(intent);
- break;
- default:
- break;
- }
- }
- }
- break;
- case 1: // 일별
- int NumberOfValuelist1 = imapRemotemeter.SetItem("valuelist");
- if (NumberOfValuelist1 != 0) {
- DebugLogOutput("nowCal.get(Calendar.DATE):" + nowCal.get(Calendar.DATE));
- if ((NumberOfValuelist1 + 1) == nowCal.get(Calendar.DATE)) {
- isStartSaveData = true;
- RecentDay = -1;
- DebugLogOutput("if ((NumberOfValuelist1 + 1) == nowCal.get(Calendar.DATE))");
- }
- for (int i = 0; i < NumberOfValuelist1; i++) {
- if ((Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "month")) == (month)) && (Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "year")) == (year))) {
- int TempDay = Integer.parseInt(imapRemotemeter.GetAttributeVal(i, "day"));
- //DebugLogOutput("day " + TempDay);
- float TempKepco = 0;
- float TempSolar = 0;
- float TempFuel = 0;
- try {
- // 한전
- //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
- //DebugLogOutput("TempString elect " + TempString);
- //if (TempString!=null&&TempString.equals("1000000") == false) {
- // TempKepco = Float.parseFloat(TempString);
- //}
- //DebugLogOutput("TempElect " + TempElect);
- // 태양광
- TempString = imapRemotemeter.GetAttributeVal(i, "photovoltaics_used");
- //DebugLogOutput("TempString water " + TempString);
- if (TempString.equals("1000000") == false) {
- TempSolar = Float.parseFloat(TempString);
- }
- //DebugLogOutput("TempWater " + TempWater);
- // 연료전지
- TempString = imapRemotemeter.GetAttributeVal(i, "fuelcell_used");
- //DebugLogOutput("TempString gas " + TempString);
- if (TempString.equals("1000000") == false) {
- TempFuel = Float.parseFloat(TempString);
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- arrayListDayEnergyData.add(new DayEnergyDataClass(CalendarYear, CalendarMonth + 1, TempDay, TempKepco, TempSolar, TempFuel));
- }
- }
- TotalServerInquiryCount++;
- if ((arrayListDayEnergyData.size() < 9)) {
- // 데이터 요청 한번 더..
- Calendar LastMonth = getMinusMonth(-1); // 전달 년도 월
- // 가져오기.
- int nYear = LastMonth.get(Calendar.YEAR);
- int nMonth = LastMonth.get(Calendar.MONTH);
- //DebugLogOutput("Inquiry to Server: " + nYear + " " + nMonth);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- if (TotalServerInquiryCount < 2) {
- LoadRemotemeterDataFromServer(1, nYear, nMonth, ShowNowEnergyIndex);
- }
- } else if (arrayListDayEnergyData.size() >= 9) {
- // 관련 변수 초기화
- RecentDay = 0;
- isStartSaveData = false;
- TotalServerInquiryCount = 0;
- // show data
- ShowDayGraph();
- ReDraw();
- }
- }
- break;
- case 2: // realtime
- float TempKepco = 0;
- float TempSolar = 0;
- float TempFuel = 0;
- int photovoltaicsValue = imapRemotemeter.SetItem("photovoltaics");
- if (photovoltaicsValue != 0) {
- try {
- // 한전
- //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
- //DebugLogOutput("TempString elect " + TempString);
- //if (TempString!=null&&TempString.equals("1000000") == false) {
- // TempKepco = Float.parseFloat(TempString);
- //}
- //DebugLogOutput("TempElect " + TempElect);
- // 태양광
- TempString = imapRemotemeter.GetItemVal(0);
- TempSolar = Float.parseFloat(TempString);
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- int fuelcellValue = imapRemotemeter.SetItem("fuelcell");
- if (fuelcellValue != 0) {
- try {
- // 한전
- //TempString = imapRemotemeter.GetAttributeVal(i, "kepco_used");
- //DebugLogOutput("TempString elect " + TempString);
- //if (TempString!=null&&TempString.equals("1000000") == false) {
- // TempKepco = Float.parseFloat(TempString);
- //}
- //DebugLogOutput("TempElect " + TempElect);
- // 태양광
- TempString = imapRemotemeter.GetItemVal(0);
- TempFuel = Float.parseFloat(TempString);
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- realTimeEnergyData = new DayEnergyDataClass(0, 0, 0, 0, TempSolar, TempFuel);
- Draw_Update();
- break;
- default:
- break;
- }
- StatusDBMGR.closeDB();
- } catch (
- RuntimeException re) {
- if (StatusDBMGR != null) {
- StatusDBMGR.closeDB();
- }
- Log.e(TAG, "exception : " + re);
- } catch (
- Exception e) {
- if (StatusDBMGR != null) {
- StatusDBMGR.closeDB();
- }
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- @Override
- public void ProcError() {
- DebugLogOutput("Load Data From Server - ProcError");
- isResponseArrive = true;
- RecentDay = 0;
- isStartSaveData = false;
- TotalServerInquiryCount = 0;
- }
- @Override
- public void ProcDoing() {
- DebugLogOutput("Load Data From Server - ProcDoing");
- }
- });
- } catch (
- RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- } catch (
- Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public Calendar getMinusDate(int iDay) {
- Calendar temp = Calendar.getInstance();
- temp.add(Calendar.DAY_OF_MONTH, iDay);
- return temp;
- }
- public Calendar getMinusMonth(int iMonth) {
- Calendar temp = Calendar.getInstance();
- temp.add(Calendar.MONTH, iMonth);
- return temp;
- }
- public void SampleDatainsert_MonthTableData() {
- WallpadStatusData StatusDBMGR = null;
- StatusDBMGR = new WallpadStatusData(getContext());
- monthTableClass[0] = new MonthTableClass("");
- monthTableClass[0].Use = "280";
- monthTableClass[1] = new MonthTableClass("");
- monthTableClass[1].Use = "24";
- monthTableClass[2] = new MonthTableClass("");
- monthTableClass[2].Use = "6";
- StatusDBMGR.closeDB();
- DrawGraph_andValues(mNumberOfEnergy);
- }
- public void GetMeteringCount() {
- WallpadDeviceSet devSet = new WallpadDeviceSet(getContext());
- String[] MetringDB = devSet.GetSettingData("원격검침");
- devSet.closeDB();
- //for test
- MetringDB = null;
- //end test
- if (MetringDB != null) {
- try {
- String devInfo = MetringDB[1];
- devInfo = devInfo.replace('(', '_');
- devInfo = devInfo.replace(':', '_');
- devInfo = devInfo.replace(')', '_');
- String[] MetringInfo = devInfo.split("_");
- // MetringInfo[1] -> 회로수
- // MetringInfo[5] -> EMS 사용여부 사용함 or 사용안함
- if ((Integer.parseInt(MetringInfo[1]) == 2) || (Integer.parseInt(MetringInfo[1]) == 3) || (Integer.parseInt(MetringInfo[1]) == 5) || (Integer.parseInt(MetringInfo[1]) == 6)) {
- mNumberOfEnergy = Integer.parseInt(MetringInfo[1]);
- } else {
- mNumberOfEnergy = 3;
- }
- if (MetringInfo[5].equals("사용함")) {
- mEMS_Enable = true;
- } else {
- mEMS_Enable = false;
- }
- if (MetringInfo[7].equals("사용함")) {
- mCostInfo_Enable = true;
- } else {
- mCostInfo_Enable = false;
- }
- } catch (RuntimeException re) {
- Log.e(TAG, "exception : " + re);
- mNumberOfEnergy = 5;
- mEMS_Enable = true;
- } catch (Exception e) {
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mNumberOfEnergy = 5;
- mEMS_Enable = true;
- }
- } else {
- mNumberOfEnergy = 3;
- mEMS_Enable = true;
- }
- }
- /***
- * @description 서버연동 에너지 팝업 화면 시험을 위한 함수
- */
- public void TestEnergyAlarmPopup() {
- DebugLogOutput("TestEnergyAlarmPopup()");
- Intent intent = new Intent();
- intent.setAction(define.NOTIFY_ACNAME);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_MAIN_ACTIVIVY);
- intent.putExtra("elect_target", "300");
- intent.putExtra("elect_used", "400");
- intent.putExtra("elect_info", "over");
- intent.putExtra("water_target", "300");
- intent.putExtra("water_used", "150");
- intent.putExtra("water_info", "reach");
- intent.putExtra("gas_target", "300");
- intent.putExtra("gas_used", "100");
- intent.putExtra("gas_info", "reach");
- intent.putExtra("heating_target", "300");
- intent.putExtra("heating_used", "200");
- intent.putExtra("heating_info", "reach");
- intent.putExtra("hotwater_target", "300");
- intent.putExtra("hotwater_used", "300");
- intent.putExtra("hotwater_info", "reach");
- this.getContext().sendBroadcast(intent);
- }
- }
|