|
@@ -2149,10 +2149,10 @@ public class DataSenderService extends Service {
|
|
|
strResult += " <devinfo name=\"sysaircon\" value=\"" + 0 + "\" order=\"" + strAircon + "\" floor=\"" + index + "\"/>\r\n";
|
|
|
}
|
|
|
}
|
|
|
- //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
|
|
|
- strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + index + "\"/>\r\n";
|
|
|
- strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + index + "\"/>\r\n";
|
|
|
}
|
|
|
+ //방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
|
|
|
+ strResult += " <devinfo name=\"mode\" value=\"" + 0 + "\" floor=\"" + index + "\"/>\r\n";
|
|
|
+ strResult += " <devinfo name=\"sensor\" value=\"" + 0 + "\" floor=\"" + index + "\"/>\r\n";
|
|
|
devSet.closeDB();
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -2262,10 +2262,10 @@ public class DataSenderService extends Service {
|
|
|
private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
|
|
|
|
|
|
public void deviceApiLoad() {
|
|
|
- WallpadDeviceSet wds = new WallpadDeviceSet(mContext);
|
|
|
- int nDPType = wds.Get_DistributionPannelType_Info();
|
|
|
- wds.closeDB();
|
|
|
try {
|
|
|
+ WallpadDeviceSet wds = new WallpadDeviceSet(mContext);
|
|
|
+ int nDPType = wds.Get_DistributionPannelType_Info();
|
|
|
+ wds.closeDB();
|
|
|
if (mWallPadAPI.Check_Connect()) {
|
|
|
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|
|
|
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|
|
@@ -2351,8 +2351,6 @@ public class DataSenderService extends Service {
|
|
|
mAirconData.systemAircon = mSystemAirconAPI.data;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- startRealtimemeterInfo(); // 실시간 검침기 전송 스타트
|
|
|
// 각각의 디바이스 컨트롤러를 가져온다음에 맨 마직막에 디바이스쪽에 BR을 등록 시킨다.
|
|
|
registerDeviceBR();
|
|
|
}
|
|
@@ -3032,175 +3030,6 @@ public class DataSenderService extends Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 실시간검침 데이터를 서버에 전송하는 쓰레드. <br>
|
|
|
- * 10분에 한번씩 저장
|
|
|
- */
|
|
|
- @SuppressLint("UseValueOf")
|
|
|
- class saveRealmeterData extends Thread {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- super.run();
|
|
|
- Log.i(TAG, "[saveRealmeterData] ========== START ==========");
|
|
|
-
|
|
|
- int ret;
|
|
|
- wallpaddbmgr WallpadDBMGRforThread = null;
|
|
|
-
|
|
|
- while (true) {
|
|
|
- try {
|
|
|
- Thread.sleep(1000 * 60); //1분마다, 이 시간 설정은 같이 논의 할 필요가 있음.
|
|
|
-
|
|
|
- if (mRealTimeMeterAPI != null) {
|
|
|
-
|
|
|
- ret = mRealTimeMeterAPI.Refresh(false);
|
|
|
- if (ret == 0) {
|
|
|
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
|
|
|
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
|
|
|
-
|
|
|
- double electricNow = mRealTimeMeterAPI.data.Elec.Now;
|
|
|
- double electricAcc = mRealTimeMeterAPI.data.Elec.Acc;
|
|
|
-
|
|
|
- double waterNow = mRealTimeMeterAPI.data.Water.Now;
|
|
|
- double waterAcc = mRealTimeMeterAPI.data.Water.Acc;
|
|
|
-
|
|
|
- double gasNow = mRealTimeMeterAPI.data.Gas.Now;
|
|
|
- double gasAcc = mRealTimeMeterAPI.data.Gas.Acc;
|
|
|
-
|
|
|
- double hotwaterNow = mRealTimeMeterAPI.data.HotWater.Now;
|
|
|
- double hotwaterAcc = mRealTimeMeterAPI.data.HotWater.Acc;
|
|
|
-
|
|
|
- double heatNow = mRealTimeMeterAPI.data.Calorie.Now;
|
|
|
- double heatAcc = mRealTimeMeterAPI.data.Calorie.Acc;
|
|
|
-
|
|
|
- JSONArray errorArray = new JSONArray();
|
|
|
-
|
|
|
- if (mRealTimeMeterAPI.data.nElecErrorCnt > 0) {
|
|
|
- errorArray.put("electric");
|
|
|
- }
|
|
|
- if (mRealTimeMeterAPI.data.nGasErrorCnt > 0) {
|
|
|
- errorArray.put("gas");
|
|
|
- }
|
|
|
- if (mRealTimeMeterAPI.data.nHeatingErrorCnt > 0) {
|
|
|
- errorArray.put("heat");
|
|
|
- }
|
|
|
- if (mRealTimeMeterAPI.data.nHotWaterErrorCnt > 0) {
|
|
|
- errorArray.put("hotwater");
|
|
|
- }
|
|
|
- if (mRealTimeMeterAPI.data.nWaterErrorCnt > 0) {
|
|
|
- errorArray.put("water");
|
|
|
- }
|
|
|
-
|
|
|
- JSONArray electricArray = new JSONArray();
|
|
|
- JSONArray gasArray = new JSONArray();
|
|
|
- JSONArray heatArray = new JSONArray();
|
|
|
- JSONArray hotwaterArray = new JSONArray();
|
|
|
- JSONArray waterArray = new JSONArray();
|
|
|
- try {
|
|
|
- electricArray.put(electricNow);
|
|
|
- electricArray.put(electricAcc);
|
|
|
- gasArray.put(gasNow);
|
|
|
- gasArray.put(gasAcc);
|
|
|
- heatArray.put(heatNow);
|
|
|
- heatArray.put(heatAcc);
|
|
|
- hotwaterArray.put(hotwaterNow);
|
|
|
- hotwaterArray.put(hotwaterAcc);
|
|
|
- waterArray.put(waterNow);
|
|
|
- waterArray.put(waterAcc);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- try {
|
|
|
- jsonObject.accumulate("error", errorArray);
|
|
|
- jsonObject.accumulate("electric", electricArray);
|
|
|
- jsonObject.accumulate("water", waterArray);
|
|
|
- jsonObject.accumulate("hotwater", hotwaterArray);
|
|
|
- jsonObject.accumulate("gas", gasArray);
|
|
|
- jsonObject.accumulate("heating", heatArray);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- SendData("icon", "meter", "amr", "metering", jsonObject, 2);
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
|
|
|
- }
|
|
|
- } else {
|
|
|
- Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
|
|
|
- }
|
|
|
-
|
|
|
- //난방 현재 온도도 같이 보내준다.
|
|
|
- if (bSending && mHeatingV2API != null) {
|
|
|
-
|
|
|
- int roomCount = mHeatingV2API.data.Device.info.RoomCount;
|
|
|
- JSONObject jsonTempObject = new JSONObject();
|
|
|
- for (int ii = 0; ii < roomCount; ii++) {
|
|
|
- // build jsonObject
|
|
|
- try {
|
|
|
- jsonTempObject.accumulate("room" + (ii + 1), mHeatingV2API.data.Device.Room[ii].NowTemp);
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- SendData("icon", "controller", "heating", "current_temperture", jsonTempObject, 2);
|
|
|
- } else {
|
|
|
- mHeatingV2API = mWallPadAPI.Get_HeatingV2Controller();
|
|
|
- }
|
|
|
- //주기적으로 에너지 미터 체크
|
|
|
- checkChangedSdb(true);
|
|
|
- } catch (InterruptedException e1) {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- if (WallpadDBMGRforThread != null) {
|
|
|
- WallpadDBMGRforThread.closeDB();
|
|
|
- }
|
|
|
- Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
|
|
|
- e1.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며, <br>
|
|
|
- * 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에, <br>
|
|
|
- * 본 딜레이 코드를 임시로 적용한다.
|
|
|
- */
|
|
|
- @SuppressLint("HandlerLeak")
|
|
|
- protected Handler initRealtimemeterFunctionHandler = new Handler() {
|
|
|
- @SuppressLint("HandlerLeak")
|
|
|
- @Override
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
|
|
|
- if (msg.what == 0) {
|
|
|
- if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
|
|
|
- if (updateRealtimemeterData(false) == 0) {
|
|
|
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
|
|
|
- } else {
|
|
|
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 30000);
|
|
|
- }
|
|
|
- } else {
|
|
|
- Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
|
|
|
- initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
|
|
|
- }
|
|
|
- } else if (msg.what == 1) {
|
|
|
- Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
|
|
|
- if (mRealTimeMeterAPI != null) {
|
|
|
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
|
|
|
- int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
|
|
|
- mWallpadDeviceSet.closeDB();
|
|
|
-
|
|
|
- if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
|
|
|
- saveRealmeterDataThread = new saveRealmeterData();
|
|
|
- saveRealmeterDataThread.start();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
/*
|
|
|
실시간 검침기 정보 전송 관리
|
|
|
*/
|
|
@@ -3209,34 +3038,6 @@ public class DataSenderService extends Service {
|
|
|
private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
|
|
|
public Thread saveRealmeterDataThread = null;
|
|
|
|
|
|
- private void startRealtimemeterInfo() {
|
|
|
- try {
|
|
|
- Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
|
|
|
- // 실시간 검침기 사용유무 판단
|
|
|
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
|
|
|
- int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
|
|
|
- mWallpadDeviceSet.closeDB();
|
|
|
-
|
|
|
- boolean bRealtimemeterUsage = false;
|
|
|
- int nRealtimemeterCntDB = -99;
|
|
|
-
|
|
|
- if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
|
|
|
- // 실시간 검침 사용함
|
|
|
- bRealtimemeterUsage = true;
|
|
|
- nRealtimemeterCntDB = naRealtimemtInfo[1];
|
|
|
- initRealtimemeterFunctionHandler.sendEmptyMessage(0);
|
|
|
- } else {
|
|
|
- // 실시간 검침 사용하지 않음
|
|
|
- bRealtimemeterUsage = false;
|
|
|
- }
|
|
|
- Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- Log.e(TAG, "[Exception] startRealtimemeterInfo()");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
BroadcastReceiver mSendDataEventBR = new BroadcastReceiver() {
|
|
|
@Override
|
|
|
public void onReceive(Context context, Intent intent) {
|