package kr.co.icontrols.wallpadmain.util;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import com.artncore.WallPadDataMgr.WallpadCarEventInfo;
import com.artncore.WallPadDataMgr.WallpadDevStatus;
import com.artncore.WallPadDataMgr.WallpadDeviceSet;
import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
import com.artncore.WallPadDataMgr.WallpadSalesSampleData;
import com.artncore.WallPadDataMgr.WallpadScheduleData;
import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData;
import com.artncore.WallPadDataMgr.WallpadSmartKeyRegData.SmartKeyDataClass;
import com.artncore.WallPadDataMgr.WallpadStatusData;
import com.artncore.WallPadDataMgr.WallpadStatusData.WeatherTable;
import com.artncore.WallPadDataMgr.wallpaddbmgr;
import com.artncore.WallPadDataMgr.wallpaddbmgr.AddressSet;
import com.artncore.WallPadKNXSystem.WallPadKNX;
import com.artncore.WallPadSmartLightSystem.WallPadSmartLight;
import com.artncore.commons.APIErrorCode;
import com.artncore.commons.API_Menu;
import com.artncore.commons.DataClasses;
import com.artncore.commons.DataClasses.HeatingV1;
import com.artncore.commons.DataClasses.HeatingV2;
import com.artncore.commons.DataClasses.MultiSwitch;
import com.artncore.commons.KNX_DataClasses;
import com.artncore.commons.define;
import com.artncore.deviceinterface.WallPadInterface;
import com.artncore.wallpadapi.AirQualitySensorAPI;
import com.artncore.wallpadapi.CooktopAPI;
import com.artncore.wallpadapi.DLockAPI;
import com.artncore.wallpadapi.EnergyMeterAPI;
import com.artncore.wallpadapi.GasAPI;
import com.artncore.wallpadapi.HeatingV1API;
import com.artncore.wallpadapi.HeatingV2API;
import com.artncore.wallpadapi.IGW200dAPI;
import com.artncore.wallpadapi.IGW300API;
import com.artncore.wallpadapi.IntLightAPI;
import com.artncore.wallpadapi.KnxAPI;
import com.artncore.wallpadapi.KnxSystemAirconAPI;
import com.artncore.wallpadapi.Knx_LivingRoomLightAPI;
import com.artncore.wallpadapi.LightAPI;
import com.artncore.wallpadapi.MultiSwitchAPI;
import com.artncore.wallpadapi.PhonNRemocon;
import com.artncore.wallpadapi.RealTimeMeterAPI;
import com.artncore.wallpadapi.SdbAPI;
import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
import com.artncore.wallpadapi.SmartKeyRfDoorAPI;
import com.artncore.wallpadapi.SmartSwitchPolAPI;
import com.artncore.wallpadapi.VentiAPI;
import com.artncore.wallpadapi.WallPadAPI;
import com.artncore.wallpadimap.RetProci;
import com.artncore.wallpadimap.WallPadFTPUploader;
import com.artncore.wallpadimap.WallPadiMAPNotifyAPI;
import com.artncore.wallpadimap.WallpadiCMDParser;
import com.util.LogUtil;
import org.apache.commons.net.ftp.FTP;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import javax.net.ssl.SSLServerSocket;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import de.re.easymodbus.exceptions.ModbusException;
import de.re.easymodbus.modbusclient.ModbusClient;
import kr.co.icontrols.gledeviceinterface.jni;
import kr.co.icontrols.hdcftp.HDCFTPManager;
import kr.co.icontrols.sslapi.SSLClient;
import kr.co.icontrols.sslapi.SSLServer;
import kr.co.icontrols.wallpadmain.IOInterface;
import kr.co.icontrols.wallpadmain.MainActivity;
import kr.co.icontrols.wallpadmain.R;
import kr.co.icontrols.wallpadmain.declare.Common;
import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_LIVE_CHECKER;
import kr.co.icontrols.wallpadmain.declare.Common.BR_MAIN_NOTI;
import kr.co.icontrols.wallpadmain.declare.Common.ELEV_STATUS;
import kr.co.icontrols.wallpadmain.imap.iMAPEmptyMessage;
import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceEvent;
import kr.co.icontrols.wallpadmain.imap.iMAPKNXDeviceInfo;
import kr.co.icontrols.wallpadmain.imap.iMAPLobbyOnePass;
import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightEvent;
import kr.co.icontrols.wallpadmain.imap.iMAPSmartLightInfo;
import kr.co.icontrols.wallpadmain.imap.iMAP_hn_config_read;
import kr.co.icontrols.wallpadsupport.Version;
import kr.co.icontrols.wallpadsupport.Version.MODEL_TYPE;
import kr.co.icontrols.wallpadsupport.WpadSound;
import kr.co.icontrols.wallpadsupport.WpadSound.SND;
import kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete;
import static com.artncore.wallpadapi.SdbAPI.EM_INDEX_LIVING;
public class iMapServer extends Service {
private String TAG = "iMapServer";
//
static final int EVENTTIMELIMITE = 2000;
iMapSverSocket SvrSock;
int port = 10000;
String StrAddr = "";
String IPaddr;
String AddrDong;
String AddrHo;
boolean m_CallAppRunDelay = false; //add KSJ
int ho;
boolean log_sw = true;
String SVRIP = "";
static WallPadAPI mWallPadAPI;
private SdbAPI mSdbAPI; // 각방 조명/콘센트 (스마트분전반)
private KnxAPI mKnxAPI; // 각방 조명/콘센트 (KNX분전반)
private Sdb_LivingRoomLightAPI mSdb_LivingRoomLightAPI = null; // 거실에너지미터 (스마트분전반)
private Knx_LivingRoomLightAPI mKnx_LivingRoomLightAPI = null; // 거실에너지미터 (KNX분전반)
private SmartKeyRfDoorAPI mSmartKeyRfDoorAPI = null; // 스마트현관카메라
private IGW200 mIGW200;
private IGW300 mIGW300;
PhonNRemocon PnRCtr;
boolean CallConnected = false;
long ALERTTIME = 0;
long CALLTIME = 0;
long OPENDOORTIME = 0;
long currentTime = 0;
long DoorDelayTime = 0;
static Handler ScheDulerHandler;
static final boolean iMAPDOORCTR = true;
private jni mGleInterface = null;
IOInterface mIOInterface = null;
private boolean ResetFlag = false;
final String PackageName_WallPadMain = "kr.co.icontrols.wallpadmain";
private int ResetCount = 0;
private boolean NowMainStatus = false;
public final static String MOBILE_USER_AUTH_PASSED = "MOBILE_USER_AUTH_PASSED";
public final static String WEB_USER_AUTH_PASSED = "WEB_USER_AUTH_PASSED";
public iMapServer() {
Log.i(TAG, "[iMapServer] ========== START ==========");
}
public static final int SENSOR_MAG = 0x01;
public static final int SENSOR_IN = 0x02;
public static final int SENSOR_OUT = 0x04;
static int PORT_NUM_iMAP = 10000;
static int SOCKET_WAIT_TIME = 40;
static long lSocketConnectionPeriod = 0;
static int TIMEOUT_iMAP_WAIT = 4000; // iMAP 타임아웃은 실제 3초 이지만, 마진을 두어 4초로 한다.
static int SOCKET_BUFFER_SIZE_READ = 50;
public static final String ITEM_MENU_TYPE = "call_menu";
static final int DOOR_DELAY_TIME = 3000;
static final String MULTISW_CTR = "remote_access_electric";
String XMLHeader;
SchedulerThread ScheServer;
int OutGoingSensorWaiting = 0;
private int ModelType = Version.getModelType();
private WpadSound mSound;
private WpadSound Sound() {
if (mSound == null) mSound = new WpadSound(getApplicationContext());
return mSound;
}
/**
* 신형 단지서버 사용 유무
*/
private boolean mNewDanjiServer = false;
/**
* 방범 앱 재실행 여부
*/
private boolean bOutModeRestart = false; // 거동수상자 녹화 후 재실행되는지 여부를 파악하기 위해
/**
* JEFF, 2019.12.31
* 통화앱 종료 BR를 수신하여, 현관벨 눌림 무시하는 코드를 삭제하고
* WallPadMain에서 WallPadCall의 BR응답을 받아 WallPadCall의 실행 상태를 확인하여
* 현관통화 여부 결정하는 코드로 수정, 서브폰모듈에서는 그대로 사용하고 있으므로 통화앱의
* 통화앱 종료 BR을 삭제하면 안됨
*/
// 통화어플이 종료중인 경우에는 호출 무시
// private boolean bBlockCallEvent = false;
////////////////////////////////////////////////////////////////////////////////
// 엘리베이터관련
////////////////////////////////////////////////////////////////////////////////
/**
* 엘리베이터 호출관련 class
*
* shkang
*/
private class ElevatorClass {
/**
* 엘리베이터 호출 타임아웃 (단위:초)
*/
private final int ELEVATOR_CALL_TIMEOUT_SEC = (int) (5 * 60); // 5분
/**
* 상향/하향 플레그 true:상향UP, false:하향DN
*/
private boolean mUpDn = false;
/**
* 엘리베이터 호출중
*/
private boolean mCallElevator = false;
/**
* 엘리베이터 호출 API
*/
private WallPadiMAPNotifyAPI mElevatorAPI;
/**
* 엘리베이터 호출 타이머
*/
private CountDownTimer mElevatorTimer;
/**
* 엘리베이터 호출중 상태 가져오기
*/
public boolean getElevatorCalling() {
return mCallElevator;
}
/**
* 엘리베이터 호출 상태 클리어
*/
public void ClearElevator() {
mCallElevator = false;
}
/**
* 생성자
*
* @param Up - (boolean) true:상향, false:하향
*/
private ElevatorClass(boolean Up) {
try {
Log.i(TAG, "[ElevatorClass] Create(" + (Up == true ? "UP" : "DOWN") + ")");
// 1. Input Param
mUpDn = Up;
mCallElevator = false;
// 2. Create API
mElevatorAPI = new WallPadiMAPNotifyAPI(getApplicationContext());
mElevatorAPI.SetElevatorRetCtr(new RetProci() {
@Override
public void ProcDoing() {
Log.i(TAG, "[ElevatorClass] ProcDoing()");
}
@Override
public void ProcError() {
Log.i(TAG, "[ElevatorClass] ProcError()");
mCallElevator = false;
// 엘리베이터 호출 에러 알림
SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_ERROR : define.NOTIFY_ELE_CALL_DOWN_ERROR);
}
@Override
public void ProcSuccess() {
Log.i(TAG, "[ElevatorClass] ProcSuccess()");
mCallElevator = true;
// 엘리베이터 호출 성공 알림
SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP : define.NOTIFY_ELE_CALL_DOWN);
// "엘리베이터를 호출하였습니다" 멘트출력
Log.i(TAG, "[ElevatorClass] GetForegroundAPP [" + GetForegroundAPP() + "]");
Log.i(TAG, "[ElevatorClass] bOutModeRestart [" + bOutModeRestart + "]");
if (!MainActivity.bKakaoiEnable && !bOutModeRestart)
Sound().PlayMent(WpadSound.SND.elevator.CALL);
bOutModeRestart = false;
// 카카오 데모를 위해 음성출력 주석처리 (jeff, 2019.06.19)
// 거동수상자 녹화 후 방범 재실행시 엘리베이터 호출 연동설정되어 있는 경우 음성이 재출력되는 증상 처리
// 타임아웃 시작
TimeOutStart();
}
});
// 3. Create Timer
mElevatorTimer = new CountDownTimer((long) (ELEVATOR_CALL_TIMEOUT_SEC * 1000), 1000) {
@Override
public void onFinish() {
Log.w(TAG, "[ElevatorClass] onFinish -> ElevatorUpTimer (TIMEOUT:" + ELEVATOR_CALL_TIMEOUT_SEC + "Sec)");
mCallElevator = false;
// 호출 타임아웃 알림
SendNotifyKindBR(mUpDn == true ? define.NOTIFY_ELE_CALL_UP_TIMEOUT : define.NOTIFY_ELE_CALL_DOWN_TIMEOUT);
}
@Override
public void onTick(long arg0) {
int RemainingTime = (int) (arg0 / 1000);
if (RemainingTime <= 10) {
Log.w(TAG, "[ElevatorClass] onTick -> ElevatorUpTimer (" + RemainingTime + ")");
}
}
};
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] ElevatorClass(boolean Up)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 엘리베이터 호출을 한다.
*/
public void CallElevator() {
try {
if (mElevatorAPI == null) return;
mElevatorAPI.CallElevator(mUpDn == true ? (byte) 1 : (byte) 0); // updown - (byte) 0 : down , 1 : up
mCallElevator = true;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] CallElevator()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 엘리베이터 상향호출 타임아웃을 취소한다.
*/
public void TimeOutCancel() {
try {
if (mElevatorTimer == null) return;
mElevatorTimer.cancel();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] TimeOutCancel()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 엘리베이터 상향호출 타임아웃을 시작한다.
*/
private void TimeOutStart() {
try {
if (mElevatorTimer == null) return;
mElevatorTimer.cancel();
mElevatorTimer.start();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] TimeOutStart()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* WALLPAD_NOTIFY 의 ActionName 으로 전달될 Broadcast 를 송신한다.
*
* @param kind - (int) 종류 (WallPadAPI -> define.java -> NOTIFY_xxxxxx 로 명명된 값을 넣는다)
*/
private void SendNotifyKindBR(int kind) {
try {
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, kind);
getApplicationContext().sendBroadcast(notiIntent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] SendNotifyKindBR(int kind)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
/**
* 엘리베이터 상향호출 Class
*/
private ElevatorClass ElevatorUp;
/**
* 엘리베이터 하향호출 Class
*/
private ElevatorClass ElevatorDown;
/**
* 엘리베이터 호출한다.
*
* @param Up (boolean) true : 상향, false : 하향
*/
private void CallElevatorBtn(boolean Up) {
try {
Log.i(TAG, "[CallElevatorBtn] Up [" + Up + "]");
if (Up) {
// 상향호출
if (ElevatorUp == null) {
Log.w(TAG, "[CallElevatorBtn] ElevatorUp is null!!");
return;
}
ElevatorUp.CallElevator();
} else {
// 하향호출
if (ElevatorDown == null) {
Log.w(TAG, "[CallElevatorBtn] ElevatorDown is null!!");
return;
}
ElevatorDown.CallElevator();
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] CallElevatorBtn(boolean Up)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@Override
public void onCreate() {
try {
super.onCreate();
Log.i(TAG, "[onCreate] ========== START ==========");
setGlobalScreenAppRunningStatus(false);
ModelType = Version.getModelType();
mSound = new WpadSound(getApplicationContext());
ElevatorUp = new ElevatorClass(true);
ElevatorDown = new ElevatorClass(false);
} catch (RuntimeException re) {
Log.e(TAG, "[Exception] onCreate()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] onCreate()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void SendBRElevatorCallState(ELEV_STATUS eStatus) {
try {
Intent notiIntent = new Intent();
notiIntent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
notiIntent.putExtra(Common.BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
notiIntent.putExtra("ElevatorFloor", eStatus.toString());
getApplicationContext().sendBroadcast(notiIntent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] SendBRElevatorCallState(ELEV_STATUS eStatus)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
protected String GetForegroundAPP() {
try {
ActivityManager am = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List taskInfo = am.getRunningTasks(1);
ComponentName topActivity = taskInfo.get(0).topActivity;
String str = topActivity.getPackageName();
return str;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return " ";
} catch (Exception e) {
Log.e(TAG, "[Exception] GetForegroundAPP()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return " ";
}
}
long lSavedTimestamp = 0;
BroadcastReceiver mWallPadNotifyBR = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
try {
String strActionName = intent.getAction();
Log.i(TAG, "[mWallPadNotifyBR] strActionName [" + strActionName + "]");
if (strActionName.equals(define.NOTIFY_DAIL)) {
long lTimestamp = System.currentTimeMillis();
long lInterval = lTimestamp - lSavedTimestamp;
if (lInterval < 1000) return;
else
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] The interval is acceptable!! lInterval [" + lInterval + "]");
lSavedTimestamp = lTimestamp;
if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
if (mSdb_LivingRoomLightAPI == null) {
Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI is null!!");
return;
}
byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
// 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
mSdb_LivingRoomLightAPI.SetControlMode(false);
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
}
return;
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight == null) {
// 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mSdb_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
return;
}
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Dimming [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Dimming + "], Color [" + mSdb_LivingRoomLightAPI.data.Data.LedLight[0].Data.Color + "]");
if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
} else {
setGlobalScreenAppRunningStatus(false);
}
} else if (Common.CurrentDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
if (mKnx_LivingRoomLightAPI == null) {
Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI is null!!");
return;
}
byte OnOff = intent.getByteExtra("ONOFF", (byte) 0xEE); // On : 0x01, Off : 0x02
byte Dial = intent.getByteExtra("DIAL", (byte) 0xEE);
byte Level = intent.getByteExtra("LEVEL", (byte) 0xEE);
byte Color = intent.getByteExtra("COLOR", (byte) 0xEE);
byte Control = intent.getByteExtra("CONTROL", (byte) 0xEE);
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] OnOff [" + OnOff + "], Dial [" + Dial + "], Level [" + Level + "], Color [" + Color + "], Control [" + Control + "]");
if (Control != Common.LIVINGEM_CTRL_TYPE_JOGDIAL) {
Log.w(TAG, "[mWallPadNotifyBR] Control type is wrong!! -> " + Control);
// 만약 BLE로 색온도 제어라면 강제로 밝기제어로 변경한다.
if (!getGlobalScreenAppRunningStatus() && getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp && Control == Common.LIVINGEM_CTRL_TYEP_BLE && Dial == Common.LIVINGEM_CTRL_COLOR) {
mKnx_LivingRoomLightAPI.SetControlMode(false);
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Ctrl mode change -> dimming");
}
return;
}
if (mKnx_LivingRoomLightAPI.data.Data.LIV_Lights == null) {
// 거실EM이 초기화된 경우이므로 무시한다. (JEFF, 2018.12.11)
Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] mKnx_LivingRoomLightAPI.mRealTimeMeterData.Data.LedLight is null!!");
return;
}
for (int i = 0; i < mKnx_LivingRoomLightAPI.data.Info.LightCount; i++) {
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] LIV_Lights[" + i + "] -> OnOff [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.OnOff + "], Dimming [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Dimming + "], Color [" + mKnx_LivingRoomLightAPI.data.Data.LIV_Lights[i].Data.Color + "]");
}
if (OnOff == Common.LIVINGEM_LIGHTSTATUS_ON) {
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] run WallPadGlobalScreen!!!, getGlobalScreenAppRunningStatus() : " + getGlobalScreenAppRunningStatus());
runGlobalScreenAPK(Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM, OnOff, Dial, Level, Color, Control);
} else {
setGlobalScreenAppRunningStatus(false);
}
} else {
Log.w(TAG, "[mWallPadNotifyBR.NOTIFY_DAIL] Distribution panel type is not available!! Type -> " + Common.CurrentDistributionPanelType);
}
} else if (strActionName.equals(Common.BR_BLACKOUT_SCREEN_RUN)) {
runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
} else if (strActionName.equals(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK)) {
int kind = intent.getIntExtra(define.NOTIBR_KIND, 0);
Log.i(TAG, "[mWallPadNotifyBR.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK] kind [" + kind + "]");
switch (kind) {
case define.NOTIFY_SCREEN_TOUCHED:
setTimeStamp_ScreenTouched();
break;
case define.NOTIFY_DOOR_OPENED:
setTimeStamp_Magnetic();
break;
}
} else if (strActionName.equals(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI)) {
int kind = intent.getIntExtra(Common.BR_MAIN_NOTI.KIND, 0);
Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
switch (kind) {
case Common.BR_MAIN_NOTI.REQ_UPLOAD_MISSEDVISITORPIC:
procUploadMissedVisitorPic(intent);
break;
case Common.BR_MAIN_NOTI.NOTI_CALLAPP_FINISHING:
// bBlockCallEvent = true;
// sendHandlerMsgDelayed(HANDLERMSG.CALLAPP_FINISHING_END, 0, 0, 3000);
break;
case Common.BR_MAIN_NOTI.SOUND_OUTMODE:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_OUTMODE");
Sound().Play(SND.mode.OUTMODE_SETTING);
break;
case Common.BR_MAIN_NOTI.SOUND_INMODE:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_INMODE");
Sound().Play(SND.mode.INMODE_SETTING);
break;
case Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.SOUND_COMBACK_MODE");
Sound().Play(SND.mode.NORMALMODE_COMEBACK);
break;
case Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_OUTMODE");
playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
break;
case Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.DOOR_SOUND_DEVICECHECK");
playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
break;
case Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_DOWN");
CallElevatorBtn(false);
break;
case Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.CALL_ELEVATOR_UP");
CallElevatorBtn(true);
break;
case Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUTMODE_CTRL_WORKING");
// 월패드 화면에서 호출하는 경우 Called 라는 값을 전달하고 다른곳에서 호출하는경우는 그냥...
int CalledWallPadUI = intent.getIntExtra("Called", 0);
if (CalledWallPadUI == 1) {
ModeRunCtrlWorking(true, false);
} else {
ModeRunCtrlWorking(false, false);
}
break;
case Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.COMBACK_CTRL_WORKING");
ModeReleaseCtrlWorking(false);
break;
case Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.APK_EXIT_MAIN_CHECK");
CheckMainStatus();
break;
case Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.GO_BAD_CTRL_WORKING");
ModeRunCtrlWorking(false, false);
break;
case Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.OUT_BAD_CTRL_WORKING");
ModeReleaseCtrlWorking(false);
break;
case Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.REQ_ELEVATOR_CALL_STATE");
if (ElevatorUp != null && ElevatorDown != null) {
boolean UpCalling = ElevatorUp.getElevatorCalling();
boolean DownCalling = ElevatorDown.getElevatorCalling();
Log.d(TAG, "ELEVATOR_CALL_STATE : " + UpCalling + " , DownCalling : " + DownCalling);
ELEV_STATUS ElvCallState = Common.ELEV_STATUS.NONE;
if (UpCalling && DownCalling)
Common.eElevCallStatus = Common.ELEV_STATUS.UP_DOWN;
else if (UpCalling && !DownCalling)
Common.eElevCallStatus = Common.ELEV_STATUS.UP;
else if (!UpCalling && DownCalling)
Common.eElevCallStatus = Common.ELEV_STATUS.DOWN;
else Common.eElevCallStatus = Common.ELEV_STATUS.NONE;
Log.d(TAG, " ElvCallState : " + ElvCallState);
SendBRElevatorCallState(ElvCallState);
// Intent sendIntent = new Intent( Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI, null);
// sendIntent.putExtra(Common.BR_MAIN_NOTI.KIND ,Common.BR_MAIN_NOTI.RET_ELEVATOR_CALL_STATE);
// sendIntent.putExtra("ELV", ElvCallState);
// getApplicationContext().sendBroadcast(sendIntent);
}
break;
case Common.BR_MAIN_NOTI.LIVE_CHECK_BR:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.LIVE_CHECK_BR");
try {
if (ScheServer != null) {
ScheServer.SetLive();
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END:
Log.i(TAG, "[mWallPadNotifyBR] Common.BR_MAIN_NOTI.NOTICE_PSTN_RING_END");
stopIGW300RingGenerator();
break;
}
} else if (strActionName.equals(define.NOTIFY_ACNAME)) {
int kind = intent.getIntExtra("KIND", 0);
Log.i(TAG, "[mWallPadNotifyBR] kind [" + kind + "]");
switch (kind) {
case define.NOTIFY_SERVER_VERSION:
try {
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SERVER_VERSION");
iMapSverReload tSock = new iMapSverReload();
tSock.start();
} catch (IOException e) {
Log.e(TAG, "[IOException] mWallPadNotifyBR -> define.NOTIFY_SERVER_VERSION");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case define.NOTIFY_DEVICE_ELE_CALL_UP:
// 제어기기 엘리베이터 상향 호출 요청
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_UP");
CallElevatorBtn(true);
break;
case define.NOTIFY_DEVICE_ELE_CALL_DOWN:
// 제어기기에서 엘리베이터 하향 호출 요청
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_ELE_CALL_DOWN");
CallElevatorBtn(false);
break;
case define.NOTIFY_SUBDEVCALLBUSY:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLBUSY");
CallConnected = true;
break;
case define.NOTIFY_SUBDEVCALLEND:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SUBDEVCALLEND");
CallConnected = false;
break;
case define.NOTIFY_STARTHEARTBEAT:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTHEARTBEAT");
{
Message msg = ScheDulerHandler.obtainMessage();
msg.what = SCHEDULE_CHANGE_HEARTBEAT;
ScheDulerHandler.sendMessage(msg);
}
break;
case define.NOTIFY_STARTSTATUSBEAT:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_STARTSTATUSBEAT");
{
Message msg = ScheDulerHandler.obtainMessage();
msg.what = SCHEDULE_START_STATUSBEAT;
ScheDulerHandler.sendMessage(msg);
}
break;
case define.NOTIFY_OUTGOINGSETTED:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_OUTGOINGSETTED");
OutGoingSensorWaiting = 0;
WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
sdata.closeDB();
if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
return;
WallPadInterface wpifc = new WallPadInterface();
if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0) > 0)
OutGoingSensorWaiting |= SENSOR_MAG;
int[] SensorInfoDB;
int sensorIn = 0;
int sensorOut = 0;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
if (SensorInfoDB[0] == 1) {
// 내부동체가 사용함이면 상태 검사
if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0)
OutGoingSensorWaiting |= SENSOR_IN;
}
if (SensorInfoDB[1] == 1) {
// 외부동체가 사용함이면 상태 검사
if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0)
OutGoingSensorWaiting |= SENSOR_OUT;
}
// if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_IN;
// if (wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0) > 0) OutGoingSensorWaiting|=SENSOR_OUT;
if (OutGoingSensorWaiting > 0) {
OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
SensorThread.start();
}
break;
case define.NOTIFY_DOOR_SET_DELAY:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DOOR_SET_DELAY");
DoorDelayTime = System.currentTimeMillis();
imapsvrlog("Receive " + define.NOTIFY_DOOR_SET_DELAY + " Set : " + DoorDelayTime);
break;
case define.NOTIFY_DEVICE_INIT_COMPLETION:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DEVICE_INIT_COMPLETION");
Common.setDeviceServeiceLoadComplite();
startRealtimemeterInfo(); // 실시간 검침기 확인
startSmartIoTCamInfo(); // 스마트현관카메라 확인
startDistributionPanel(); // 분전반 확인
getRoomName();
break;
case define.NOTIFY_DLOCK_SET_OUTING:
// 도어락 외출모드 / 대외향 RF 카드 외출모드
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_SET_OUTING");
try {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
int AlarmStatus = DBMGR.GetAlarmStatus();
DBMGR.closeDB();
if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
// 센서 체크하고
// 현관폰으로 사운드 출력하고
boolean bSensorOk = false;
if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
bSensorOk = mIGW300.checkSensorforOutmode();
} else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
bSensorOk = mIGW200.checkSensorforOutmode();
} else {
bSensorOk = checkSensorforOutmode();
}
if (bSensorOk) {
playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING);
CallOutModeRunActivity();
} else {
playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case define.NOTIFY_DLOCK_FREE_OUTING:
// 도어락 외출모드 해제
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_DLOCK_FREE_OUTING");
try {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
int AlarmStatus = DBMGR.GetAlarmStatus();
DBMGR.closeDB();
if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
Common.SendAppFinishReqBR(getApplicationContext());
//RF현관카메라 & 무선 도어락인 경우는 문열림을 보내도록 수정
WallpadDeviceSet devDB = new WallpadDeviceSet(getApplicationContext());
int ret = devDB.GetDeviceSetted("외출모드해제시자동문열림");
devDB.closeDB();
if (ret == WallpadDeviceSet.DEV_DATA_ENABLE) {
mWallPadAPI.SetDoorLock_Open_ForRFCamera();
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case define.NOTIFY_SMARTSW_SET_OUTING:
// 485 대외향 스마트스위치 외출모드
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_SET_OUTING");
setUnoccupiedModeByNotHDCSmartSwitch();
break;
case define.NOTIFY_SMARTSW_FREE_OUTING:
//대외향 485 스마트스위치 외출모드 해제
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMARTSW_FREE_OUTING");
releaseUnoccupiedModeByNotHDCSmartSwitch();
break;
case define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_LIGHT_SYSTEM_EVENT");
String Type = intent.getStringExtra("TYPE");
String Device = intent.getStringExtra("DEVICE");
String DeviceIndex = intent.getStringExtra("DEVICE_INDEX");
String CauseType = intent.getStringExtra("CAUSE_TYPE");
String CauseDetail = intent.getStringExtra("CAUSE_DETAIL");
iMAPSmartLightEvent imapSmartLightEvent;
imapSmartLightEvent = new iMAPSmartLightEvent(getApplicationContext());
imapSmartLightEvent.DoWork(Type, Device, DeviceIndex, CauseType, CauseDetail);
imapSmartLightEvent.SetRetCtr(new RetProci() {
@Override
public void ProcSuccess() {
Log.d(TAG, "iMAPSmartLightEvent ProcSuccess");
}
@Override
public void ProcError() {
Log.e(TAG, "iMAPSmartLightEvent ProcError");
}
@Override
public void ProcDoing() {
Log.d(TAG, "iMAPSmartLightEvent ProcDoing");
}
});
break;
case define.NOTIFY_KNX_DEVICE_EVENT:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_KNX_DEVICE_EVENT");
String strDevice = intent.getStringExtra(WallPadKNX.BR_DEVICE);
String strStatus = intent.getStringExtra(WallPadKNX.BR_STATUS);
String strCauseType = intent.getStringExtra(WallPadKNX.BR_CAUSE_TYPE);
String strCauseDetail = intent.getStringExtra(WallPadKNX.BR_CAUSE_DETAIL);
String strCauseTime = intent.getStringExtra(WallPadKNX.BT_CAUSE_TIME);
iMAPKNXDeviceEvent iMAPKNXDeviceEvent;
iMAPKNXDeviceEvent = new iMAPKNXDeviceEvent(getApplicationContext());
iMAPKNXDeviceEvent.DoWork(strDevice, strStatus, strCauseType, strCauseDetail, strCauseTime);
iMAPKNXDeviceEvent.SetRetCtr(new RetProci() {
@Override
public void ProcSuccess() {
Log.d(TAG, "iMAPKNXDeviceEvent ProcSuccess");
}
@Override
public void ProcError() {
Log.e(TAG, "iMAPKNXDeviceEvent ProcError");
}
@Override
public void ProcDoing() {
Log.d(TAG, "iMAPKNXDeviceEvent ProcDoing");
}
});
break;
case define.NOTIFY_SMART_DCAM_DETECT:
// 스마트현관카메라 거동수상자 발생
// Toast.makeText(getApplicationContext(), "Front camera sensor: DETECTED!!", Toast.LENGTH_SHORT).show();
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
if (!bWallPadCallLive && !bBlockFrontCall) {
if (getStrangerRecordingManagerSetting()) {
if (getStrangerRecordingUserSetting()) {
Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.NOTICE_DETECT_STRANGER");
Intent Newintent = new Intent();
Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_DETECT_STRANGER);
Newintent.putExtra("DOORCAM_TYPE", getSmartDoorCamType());
getApplicationContext().sendBroadcast(Newintent);
} else {
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
}
} else {
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
}
} else {
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
Log.w(TAG, "[mWallPadNotifyBR] define.NOTIFY_SMART_DCAM_DETECT -> Call Blocked!!");
}
break;
case define.NOTIFY_SMART_DCAM_RELEASE:
// Toast.makeText(getApplicationContext(), "Front camera sensor: RELEASED!!", Toast.LENGTH_SHORT).show();
break;
case define.NOTIFY_ACCEPT_RECORD_STRANGER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_ACCEPT_RECORD_STRANGER");
if (getStrangerRecordingManagerSetting()) {
if (getStrangerRecordingUserSetting()) {
// 알람 상태 확인
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
Log.d(TAG, "[mWallPadNotifyBR] nAlarmStatus [" + nAlarmStatus + "]");
if (nAlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
// 외출 대기중 (설정진행중)일 경우 녹화안함(거동수상자 감지시간이 설정대기시간보다 짧을 경우 외출모드 안걸리므로)
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
} else {
Log.d(TAG, "[mWallPadNotifyBR] Send BR --> Common.BR_MAIN_NOTI.ACCEPT_RECORDING");
Intent Newintent = new Intent();
Newintent.setAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
Newintent.putExtra(Common.BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.ACCEPT_RECORDING);
Newintent.putExtra("EMERGENCY_STATE", nAlarmStatus);
getApplicationContext().sendBroadcast(Newintent);
}
} else {
Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by user!! ");
}
} else {
Log.w(TAG, "[mWallPadNotifyBR] Stranger recording setting is disabled by manager!!");
}
break;
case define.NOTIFY_REJECT_RECORD_STRANGER:
case define.NOTIFY_REJECT_TAKEPIC_STRANGER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_RECORD_STRANGER");
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REJECT_TAKEPIC_STRANGER");
if (getStrangerRecordingManagerSetting() && getStrangerRecordingUserSetting()) {
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
}
break;
case define.NOTIFY_ROOMNAME_CHANGED:
getRoomName();
break;
case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_ELEC");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_ELEC");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_WATER");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_WATER");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HOTWATER");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HOTWATER");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_GAS");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_GAS");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_OCCUR_HEATING");
break;
case define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING:
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_REALTIMEMETER_ERROR_RELEASE_HEATING");
break;
case define.NOTIFY_FINISH_RECORD_STRANGER:
// 녹화 종료 알림
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int nAlarmStatus = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
Log.i(TAG, "[mWallPadNotifyBR] define.NOTIFY_FINISH_RECORD_STRANGER === nAlarmStatus === [" + nAlarmStatus + "]");
if (nAlarmStatus == WallpadStatusData.GUARD_OUT) bOutModeRestart = true;
break;
case define.NOTIFY_REMOTE_CTRL_LIGHT_TYPE_CHANGED:
// 사용자 설정화면에서 원격제어시 조명제어 타입 변경
getDeviceCtrlOption();
break;
default:
Log.w(TAG, "[mWallPadNotifyBR] (BR.nKind) Not support!! -> " + kind);
break;
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] mWallPadNotifyBR");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
};
private void setUnoccupiedModeByNotHDCSmartSwitch() {
try {
Log.i(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] start");
// 485 대외향 스마트스위치 외출모드
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
// 485 대외향 스마트 스위치 연동현장의 경우 외출모드와 외출방범모드가 구분이 되도록 한다.
boolean UseGuardSensorCheck = mWallpadStatusData.GetUseGuardSensorCheck();
mWallpadStatusData.closeDB();
if (UseGuardSensorCheck == false) {
// 그냥 외출모드 처리 .. 기기 연동 처리만
if (AlarmStatus == WallpadStatusData.ALARM_NONE) {
mWallpadStatusData = new WallpadStatusData(getApplicationContext());
mWallpadStatusData.SetAlarmStatus(WallpadStatusData.OUT_MODE);
mWallpadStatusData.closeDB();
Sound().PlayMent(SND.mode.OUTMODE_SETTING);
//메인화면 업데이트
Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
getApplicationContext().sendBroadcast(newIntent);
ModeRunCtrlWorking(false, false);
}
} else {
// 실제 외출 방범 모드를 설정하도록 한다.
Log.d(TAG, "[setUnoccupiedModeByNotHDCSmartSwitch] AlarmStatus [" + AlarmStatus + "]");
if (AlarmStatus == WallpadStatusData.ALARM_NONE || AlarmStatus == WallpadStatusData.GUARD_IN) {
// 센서 체크하고
// 센서 체크하는 부분이 들어가야 함
Common.SendAppFinishReqBR(getApplicationContext());
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (mIGW300.checkSensorforOutmode()) {
CallOutModeWaitingActivity(AlarmStatus);
} else {
playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
}
} else {
if (checkSensorforOutmode()) {
//playSoundthroughDoorphone(SND.mode.OUTMODE_SETTING );
CallOutModeWaitingActivity(AlarmStatus);
} else {
playSoundthroughDoorphone(SND.mode.HOME_DEVICE_CHECK);
}
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] setUnoccupiedModeByNotHDCSmartSwitch()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void releaseUnoccupiedModeByNotHDCSmartSwitch() {
try {
Log.i(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] start");
//대외향 485 스마트스위치 외출모드 해제
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
boolean OutModePwRelease = mWallpadStatusData.GetUseGuardReleasePW();
mWallpadStatusData.closeDB();
Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> AlarmStatus [" + AlarmStatus + "], OutModePwRelease [" + OutModePwRelease + "]");
if (AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
if (OutModePwRelease) {
Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 1");
// 외출방범 대기상태인데 비밀번호 사용하여 해제 선택되어 있는 경우, 스마트스위치에서 해제
// 요청하여도 해제 되지 않으며
// 바로 해제 안됨이라고 브로드캐스트 날려야 한다.
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
getApplicationContext().sendBroadcast(notiIntent);
} else {
Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 2");
// 외출방범 대기 상태의 경우 패스워드 입력없이 해제가 가능하도록 설정되어 있으면 복구
// 처리하고.
// 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
mWallpadStatusData = new WallpadStatusData(getApplicationContext());
mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
mWallpadStatusData.closeDB();
Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
Common.SendAppFinishReqBR(getApplicationContext());
}
} else if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
// 외출 방범의 경우에는 예외적으로 복귀 연동처리만 하고 방범상태를 유지해야 한다.
Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 3");
ModeReleaseCtrlWorking(false);
bSmartSwitch485ComebackMode = true;
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_CHANGE);
getApplicationContext().sendBroadcast(notiIntent);
} else if (AlarmStatus == WallpadStatusData.OUT_MODE) {
Log.d(TAG, "[releaseUnoccupiedModeByNotHDCSmartSwitch] NOTIFY_SMARTSW_FREE_OUTING -> Case 4");
// 그냥 외출모드의 경우 복귀 처리 ( 복귀 연동 기기만 처리 )
mWallpadStatusData = new WallpadStatusData(getApplicationContext());
mWallpadStatusData.SetAlarmStatus(WallpadStatusData.ALARM_NONE);
mWallpadStatusData.closeDB();
Sound().PlayMent(SND.mode.NORMALMODE_COMEBACK);
//메인화면 업데이트
Intent newIntent = new Intent(Common.MAIN_SCREEN_NOW_UPDATE, null);
getApplicationContext().sendBroadcast(newIntent);
ModeReleaseCtrlWorking(false);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] releaseUnoccupiedModeByNotHDCSmartSwitch()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 스마트현관카메라 녹화 여부 판별
* 사용자 화면에서 설정
*/
private boolean getStrangerRecordingUserSetting() {
boolean bResult = false;
WallpadStatusData DBMGR = new WallpadStatusData(this);
try {
bResult = DBMGR.GetStrangerRecordingOnOff();
DBMGR.closeDB();
Log.d(TAG, "[getStrangerRecordingUserSetting] bResult [" + bResult + "]");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
DBMGR.closeDB();
bResult = false;
} catch (Exception e) {
DBMGR.closeDB();
Log.e(TAG, "[Exception] getStrangerRecordingUserSetting()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
bResult = false;
}
return bResult;
}
private boolean getStrangerTakePic() {
try {
WallpadStatusData DBMGR = new WallpadStatusData(this);
boolean bResult = DBMGR.GetStrangerTakePicOnOff();
DBMGR.closeDB();
Log.d(TAG, "[getStrangerTakePic] bResult [" + bResult + "]");
return bResult;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] getStrangerTakePic()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
// 관리자 설정 항목에 있음
private boolean getStrangerRecordUsage() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
boolean bResult = mWallpadDeviceSet.Get_Stranger_RecordUse();
mWallpadDeviceSet.closeDB();
Log.d(TAG, "[getStrangerTakePic] getStrangerRecordUsage [" + bResult + "]");
return bResult;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] getStrangerRecordUsage()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
private boolean checkSensorforOutmode() {
try {
WallPadInterface wallPadInterface = new WallPadInterface();
Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
int[] SensorInfoDB;
int sensorIn = 0;
int sensorOut = 0;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
if (SensorInfoDB[0] == 1) {
// 내부동체가 사용함이면 상태 검사
sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
Log.w(TAG, "[checkSensorforOutmode] sensorIn = " + sensorIn);
}
if (SensorInfoDB[1] == 1) {
// 외부동체가 사용함이면 상태 검사
sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
Log.w(TAG, "[checkSensorforOutmode] sensorOut = " + sensorOut);
}
// int sensorIn = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
// int sensorOut = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
// 동체 사용 설정 체크..
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int sensor = devSet.Get_Sensor_Set();
Log.w(TAG, "[checkSensorforOutmode] sensor = " + sensor);
devSet.closeDB();
int OtherInSensor = 0;
// 내부동체 사용안함 이면
if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) sensorIn = 0;
// 외부동체 사용안함 이면
if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) == 0) sensorOut = 0;
Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "], sensorIn [" + sensorIn + "], sensorOut [" + sensorOut + "]");
if (sensorMag == 0 && sensorIn == 0 && sensorOut == 0) {
Log.w(TAG, "[checkSensorforOutmode] Result -> true");
return true;
} else {
Log.w(TAG, "[checkSensorforOutmode] Result -> false");
return false;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
private boolean checkSensorforInmode() {
try {
WallPadInterface wallPadInterface = new WallPadInterface();
Log.w(TAG, "[checkSensorforOutmode] ========== START ==========");
int sensorMag = wallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
Log.w(TAG, "[checkSensorforOutmode] sensorMag = " + sensorMag);
Log.w(TAG, "[checkSensorforOutmode] sensorMag [" + sensorMag + "]");
if (sensorMag == 0) {
Log.w(TAG, "[checkSensorforOutmode] Result -> true");
return true;
} else {
Log.w(TAG, "[checkSensorforOutmode] Result -> false");
return false;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, e.toString());
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
/////////////////////
// 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
//////////////
/////////////////////
// 외출모드 사운드 관련 출력 처리 ... "외출모드를 실행합니다." "기기를 점검하세요"
//////////////
public void playSoundthroughDoorphone(int SoundIdx) {
try {
WallPadInterface Wiface = new WallPadInterface();
mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
if (getUseSmartDoorCam()) {
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
}
Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 0); // 현관영상 선택
/*
JEFF (2019.01.14)
<< IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
강신구입니다.
동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
내용 공유합니다.
1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
이로 인해 GND가 OPEN되어 발생하는 문제입니다.
2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
문제 없습니다.
3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
문의사항은 하기 연락바랍니다.
감사합니다.
*/
mIGW300.changeCallPath(IGW300API.TEL_PATH.WPAD_DOOR);
} else {
// 대외향 모델 처리
// IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101, IHN-DW101
if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_ON);
Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_DOOR_WALLPAD, 1);
Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
}
try {
Thread.sleep(100);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
AudioManager amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
amanager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
try {
Thread.sleep(1500);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
WallpadDeviceSet Wdb = new WallpadDeviceSet(getApplicationContext());
int SLevel = Wdb.GetDoorSoundLevel();
Wdb.closeDB();
Log.d(TAG, "[playSoundthroughDoorphone] SLevel : " + SLevel);
if (SLevel != -1) {
/**
* A20 모델일 시 음량 크기 조절이 확인이 안되었으니 확인 바랍니다.
* **/
Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, SLevel);
} else {
// 사용안함이면
Wiface.DoControl(WallPadInterface.IOCTL_MONOOUT_SUB_GAIN_SET, 0x34);
}
// try{Thread.sleep(1000);}catch(Exception e){e.printStackTrace();}
int time = Sound().PlayMent(SoundIdx);
Log.v(TAG, "[playSoundthroughDoorphone] time = " + time);
if (0 > time) {
Log.w(TAG, "[playSoundthroughDoorphone] time is less than zero!! -> " + time);
time = 1000;
}
try {
Thread.sleep(time + 1000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
amanager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
amanager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
try {
Thread.sleep(100);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
mIGW300.changeCallPath(IGW300API.TEL_PATH.OFF);
if (getUseSmartDoorCam()) {
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
}
Wiface.DoControl(WallPadInterface.IOCTL_VIDEOINPUT_DOORCAMERA, 1); // 현관영상 선택 안함
/*
JEFF (2019.01.14)
<< IHN-D101 to IDC-810RF RF카드 인식 오동작 내용 공유 >>
강신구입니다.
동탄 호수공원 아이파크에 적용되는 IHN-D101과 IDC-810RF의 동작에서 RF카드가 인식되었다 안되었다 하는
증상이 있어 금일 원인 분석과 해결사항으로 결선도를 재 배포 했습니다.
내용 공유합니다.
1) 원인 : IHN-D101 제품부터는 스마트 현관카메라(HD영상)와 일반 현관카메라(SD영상)가 월패드 설정에 따라 사용이 가능한데,
HD 영상은 VIDEO를 DIFFERENTIAL로 받고, SD 영상은 VIDEO를 GND/VIDEO로 받습니다.
IDC-810RF/BLE는 모듈(통신/무선)의 전원 GND를 VIDEO GND와 동일하게 사용합니다.
이로 인해 GND가 OPEN되어 발생하는 문제입니다.
2) 해결 : VIDEO GND와 AUDIO GND를 결선도 재배포를 통해 서로 바꿨습니다. 통화시에는 SD 영상이 보여짐 GND가 연결되니,
문제 없습니다.
3) SW 조치 필요사항 : 현관카메라에서 소리만을 출력하는 경우, 외출모드로 설정하였습니다./해제되었습니다. 의 경우에
월패드(IHN-D101)의 VIDEO RELAY를 동작하게 하여 주시기 바랍니다. (현관 통화 시에 동작하는 RELAY)
문의사항은 하기 연락바랍니다.
감사합니다.
*/
mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, false);
} else {
// 대외향 모델 처리
// IHN-1010, IHN-1040, IHN-1050, IHN-T1010, IHN-HS101
if (getUseSmartDoorCam()) ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_OFF);
Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 0);
Wiface.DoControl(WallPadInterface.IOCTL_AUDIO_PATH_NORMAL, 1);
}
mWallPadOutmodeSleepHandler.sendEmptyMessageDelayed(0, 500);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public void CallOutModeRunActivity() {
int base = 8000;
int[] Menu_Id_List = {base + 11};
int Menu_StartId = base + 11;
int Menu_Option = -1;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
public void CallOutModeWaitingActivity(int nAlarmStatus) {
Log.d(TAG, "[CallOutModeWaitingActivity] nAlarmStatus [" + nAlarmStatus + "]");
int base = 4000;
int[] Menu_Id_List = {base + 11, base + 21};
int Menu_StartId = base + 11;
int Menu_Option = 1000;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
intent.putExtra("MENU_START_ID", Menu_StartId); // KEY : MENU_START_ID
intent.putExtra("MENU_START_OPTION", Menu_Option); // KEY : MENU_START_OPTION
intent.putExtra("ALARM_SET", nAlarmStatus); // 알람 상태
intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
private boolean getGlobalScreenAppRunningStatus() {
boolean bRunning = false;
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
try {
bRunning = DBMGR.getGlobalScreenAPKRun();
DBMGR.closeDB();
Log.d(TAG, "[getGlobalScreenAppRunningStatus] bRunning : " + bRunning);
return bRunning;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
DBMGR.closeDB();
} catch (Exception e) {
Log.e(TAG, "[Exception] getGlobalScreenAppRunningStatus()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
DBMGR.closeDB();
}
return bRunning;
}
private void setGlobalScreenAppRunningStatus(boolean bRun) {
Log.d(TAG, "[setGlobalScreenAppRunningStatus] bRun : " + bRun);
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
try {
boolean bResult = DBMGR.setGlobalScreenAPKRun(bRun);
Log.d(TAG, "[setGlobalScreenAppRunningStatus] bResult : " + bResult);
DBMGR.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
DBMGR.closeDB();
} catch (Exception e) {
Log.e(TAG, "[Exception] setGlobalScreenAppRunningStatus(boolean bRun)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
DBMGR.closeDB();
}
}
String strWallPadGlobalScreenPakageName = "kr.co.icontrols.wallpadglobalscreen";
boolean bGlobalScreenRun = false;
public void runGlobalScreenAPK(byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
try {
Log.i(TAG, "[runGlobalScreenAPK] hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
wakeupLCD();
if (!getGlobalScreenAppRunningStatus() && (getCurrentScreen() != API_Menu.SubMenuCtrl.HDC_LivingLamp)) {
setGlobalScreenAppRunningStatus(true);
sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
Intent mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.putExtra("ONOFF", hOnOff);
mIntent.putExtra("DIAL", hDial);
mIntent.putExtra("LEVEL", hLevel);
mIntent.putExtra("COLOR", hColor);
mIntent.putExtra("CONTROL", hControl);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setComponent(mComponentName);
startActivity(mIntent);
} else {
Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] runGlobalScreenAPK()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public void runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl) {
try {
Log.i(TAG, "[runGlobalScreenAPK] nScreenID [" + nScreenID + "], hOnOff [" + hOnOff + "], hDial [" + hDial + "], hLevel [" + hLevel + "], hColor [" + hColor + "], hControl [" + hControl + "]");
wakeupLCD();
if (!getGlobalScreenAppRunningStatus()) {
if (getCurrentScreen() == API_Menu.SubMenuCtrl.HDC_LivingLamp && nScreenID == Common.GLOBALSCREEN_ID.CTRL_LIGHT_LIVINGROOM) {
Log.i(TAG, "[runGlobalScreenAPK] CurrentScreen is HDC_LivingLamp!! ignore livinglight ctrl screen!!!");
return;
}
setGlobalScreenAppRunningStatus(true);
sendHandlerMsg(HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE, 0, 0);
ComponentName mComponentName = new ComponentName(strWallPadGlobalScreenPakageName, strWallPadGlobalScreenPakageName + ".MainActivity");
Intent mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.putExtra("SCREENID", nScreenID);
mIntent.putExtra("ONOFF", hOnOff);
mIntent.putExtra("DIAL", hDial);
mIntent.putExtra("LEVEL", hLevel);
mIntent.putExtra("COLOR", hColor);
mIntent.putExtra("CONTROL", hControl);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setComponent(mComponentName);
startActivity(mIntent);
} else {
Log.w(TAG, "[runGlobalScreenAPK] WallPadGlobalScreen is already running!!");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] runGlobalScreenAPK(int nScreenID, byte hOnOff, byte hDial, byte hLevel, byte hColor, byte hControl)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
String strBLACKOUT_RELEASED = "BLACKOUT_RELEASED";
public void sendBlackoutReleasedBR() {
try {
Intent notiIntent = new Intent();
notiIntent.setAction(strBLACKOUT_RELEASED);
getApplicationContext().sendBroadcast(notiIntent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendBlackoutReleasedBR()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private int getCurrentScreen() {
int nScreenID = 0;
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
try {
nScreenID = DBMGR.GetCurrentScreenIDValue();
DBMGR.closeDB();
Log.d(TAG, "[getCurrentScreen] nScreenID : " + nScreenID);
return nScreenID;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
DBMGR.closeDB();
} catch (Exception e) {
Log.e(TAG, "[Exception] getCurrentScreen()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
DBMGR.closeDB();
}
return nScreenID;
}
private void setCurrentScreen(int nScreenID) {
Log.d(TAG, "[setCurrentScreen] nScreenID : " + nScreenID);
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
try {
DBMGR.SetCurrentScreenIDValue(nScreenID);
DBMGR.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
DBMGR.closeDB();
} catch (Exception e) {
Log.e(TAG, "[Exception] setCurrentScreen(int nScreenID)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
DBMGR.closeDB();
}
}
ArrayList strArrayMissedPicURI = new ArrayList();
private void procUploadMissedVisitorPic(Intent intent) {
try {
String strDong = intent.getStringExtra("DONG");
String strHo = intent.getStringExtra("HO");
Log.i(TAG, "[procUploadMissedVisitorPic] strDong [" + strDong + "], strHo [" + strHo + "]");
int nCnt = intent.getIntExtra("CNT", 0);
String[] strMissedPicURI = new String[nCnt];
strArrayMissedPicURI.clear();
for (int i = 0; i < nCnt; i++) {
strMissedPicURI[i] = intent.getStringExtra("URI_" + i);
strArrayMissedPicURI.add(strMissedPicURI[i]);
Log.i(TAG, "[procUploadMissedVisitorPic] strMissedPicURI[" + i + "] = [" + strMissedPicURI[i] + "]");
}
for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
Log.i(TAG, "[procUploadMissedVisitorPic] strArrayMissedPicURI.get(" + i + ") = [" + strArrayMissedPicURI.get(i).toString() + "]");
}
prepareUploadPicturesOnFTPServer(strDong, strHo);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] procUploadMissedVisitorPic(Intent intent)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void prepareUploadPicturesOnFTPServer(String strDong, String strHo) {
try {
String strURI = "", strFileName = "", strTime = "", strType = "";
// for (int i = 0; i < strArrayMissedPicURI.size(); i++) {
// strURI = strArrayMissedPicURI.get(i).toString();
// strFileName = extractFileName(strURI);
// strTime = extractFileTime(strURI);
// strType = extractCallType(strFileName);
// Log.i(TAG, "[prepareUploadPicturesOnFTPServer] Sending BR to SKT -> Cnt [" + i + "], strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
// sendVisitorEventBRtoMobileVendorSKT(strType, strTime);
// }
if (strArrayMissedPicURI.size() > 0) {
strURI = strArrayMissedPicURI.get(0).toString();
strFileName = extractFileName(strURI);
strTime = extractFileTime(strFileName);
strType = extractCallType(strFileName);
Log.i(TAG, "[prepareUploadPicturesOnFTPServer] strFileName [" + strFileName + "], strTime [" + strTime + "], strType [" + strType + "]");
send_visitor_access_info_request(strDong, strHo, strType, strTime, strFileName, "null", strURI);
} else {
Log.w(TAG, "[prepareUploadPicturesOnFTPServer] strArrayMissedPicURI.size() [" + strArrayMissedPicURI.size() + "]");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] prepareUploadPicturesOnFTPServer()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public class uploadVisitorPicture extends Thread {
HDCFTPManager mFTPManager;
boolean bMainServer2dot0 = false;
String strRemoteIP = "10.0.1.1";
String strDong = "", strHo = "", strType = "", strTime = "", strFileName = "", strUploadFile = "";
public uploadVisitorPicture(String dong, String ho, String type, String time, String filename, String uploadfile) {
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
try {
strDong = dong;
strHo = ho;
strType = type;
strTime = time;
strFileName = filename;
strUploadFile = uploadfile;
bMainServer2dot0 = wallpadDeviceSet.GetNewDanjiServer();
Log.i(TAG, "[uploadVisitorPicture] bMainServer2dot0 [" + bMainServer2dot0 + "]");
wallpadDeviceSet.closeDB();
Log.i(TAG, "[uploadVisitorPicture] strUploadFile [" + strUploadFile + "], strFileName [" + strFileName + "], strTime [" + strTime + "]");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] uploadVisitorPicture(String strTargetFile)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public void run() {
try {
mFTPManager = new HDCFTPManager();
if (!mFTPManager.isFTPConnected()) {
if (!mFTPManager.connectFTP(strRemoteIP)) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> connectFTP(...)");
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
}
if (!mFTPManager.loginFTP(strUserID, strPW)) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> loginFTP(...)");
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
if (!bMainServer2dot0) {
if (!mFTPManager.setPassiveMode()) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setPassiveMode(...)");
disconnectFTP();
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
}
if (!mFTPManager.setCtrlEncoding(mFTPManager.ENCODING_TYPE_EUC_KR)) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setCtrlEncoding(...)");
disconnectFTP();
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
if (!mFTPManager.setFileType(FTP.BINARY_FILE_TYPE)) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> setFileType(...)");
disconnectFTP();
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
if (!mFTPManager.uploadFile(strRemoteURI, strUploadFile)) {
Log.w(TAG, "[uploadVisitorPicture.run()] FAIL!! -> strUploadFile [" + strUploadFile + "]");
disconnectFTP();
send_visitor_upload_complete_notice(false, strDong, strHo, strType, strTime, strFileName, "null");
return;
}
disconnectFTP();
Log.i(TAG, "[uploadVisitorPicture.run()] Complete upload!!!");
send_visitor_upload_complete_notice(true, strDong, strHo, strType, strTime, strFileName, "null");
sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] uploadVisitorPicture.run()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
prepareUploadPicturesOnFTPServer(strDong, strHo);
}
public boolean disconnectFTP() {
try {
if (mFTPManager.logoutFTP()) {
if (mFTPManager.disconnectFTP()) {
Log.i(TAG, "[disconnectFTP] disconnectFTP OK!!");
return true;
}
}
Log.i(TAG, "[disconnectFTP] disconnectFTP FAIL!!");
return false;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] disconnectFTP()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
}
private String extractCallType(String strFileName) {
try {
Log.i(TAG, "[extractCallType] strFileName [" + strFileName + "]");
String[] strParse_01 = strFileName.split("_");
if (strParse_01[4].equalsIgnoreCase("FRONT")) return "home";
else if (strParse_01[4].equalsIgnoreCase("LOBBY")) return "lobby";
else return "none";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] extractCallType(String strFileName)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private String extractFileName(String strTargetFile) {
try {
Log.i(TAG, "[extractFileName] strTargetFile [" + strTargetFile + "]");
String[] strParse_01 = strTargetFile.split("/");
return strParse_01[strParse_01.length - 1];
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] extractFileName(String strTargetFile)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private String extractFileTime(String strFileName) {
try {
Log.i(TAG, "[extractFileTime] strFileName [" + strFileName + "]");
String[] strParse_01 = strFileName.split("\\.");
String[] strParse_02 = strParse_01[0].split("_");
// 원래 프로토콜은 "연.월.일.시.분.초"의 형태로 timestamp를 찍어야 하나, 이전 현장에 "연월일_시분초"의 형태로 진행되어 왔음
// 이전현장 지원을 위해, 프로토콜을 변경하기로 함. 예) "2017년 9월 21일 오전 9시 58분 23초" 인 경우 "2017.09.21.09.58.23" 에서 "20170921_095823"으로 변경
// strTime = strParse_03[5].substring(0, 4) + "." + strParse_03[5].substring(4, 6) + "." + strParse_03[5].substring(6) + "." + strParse_03[6].substring(0, 2) + "." + strParse_03[6].substring(2, 4) + "." + strParse_03[6].substring(4);
return strParse_02[5] + "_" + strParse_02[6];
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] extractFileTime(String strFileName)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
String strRemoteURI, strUserID, strPW, strPath;
String strReply_User = "", strReply_PW = "", strReply_Path = "";
String strKey_Pass = "passwd";
public boolean send_visitor_access_info_request(final String strDong, final String strHo, final String strType, final String strTime, final String strFileName, String strMessage, final String strFilePath) {
try {
Log.v(TAG, "[send_visitor_access_info_request] strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "], strFilePath [" + strFilePath + "]");
final kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info visitor_access_info = new kr.co.icontrols.icwallpadmain.imap.Request_visitor_access_info(getApplicationContext());
if (visitor_access_info.send_visitor_access_info(strDong, strHo, strType, strTime, strFileName, strMessage)) {
visitor_access_info.setResultCtrl(new RetProci() {
@Override
public void ProcSuccess() {
Log.i(TAG, "[send_visitor_access_info_request] ProcSuccess()");
visitor_access_info.SetItem("ftp_info");
strReply_User = visitor_access_info.GetAttributeVal(0, "user");
strReply_PW = visitor_access_info.GetAttributeVal(0, strKey_Pass);
strReply_Path = visitor_access_info.GetAttributeVal(0, "path");
Log.v(TAG, "[send_visitor_access_info_request] Reply!! User [" + strReply_User + "], PW [" + strReply_PW + "], Path [" + strReply_Path + "]");
strUserID = strReply_User;
strPW = strReply_PW;
strPath = strReply_Path;
strRemoteURI = strPath + "/" + strFileName;
// uploadPicturesOnFTPServer(strDong, strHo, strType, strTime, strFileName, strFilePath);
uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strDong, strHo, strType, strTime, strFileName, strFilePath);
mUploadVisitorPicture.start();
// uploadVisitorPicture mUploadVisitorPicture = new uploadVisitorPicture(strFilePath);
// mUploadVisitorPicture.start();
}
@Override
public void ProcError() {
Log.i(TAG, "[send_visitor_access_info_request] ProcError()");
if (strArrayMissedPicURI != null) strArrayMissedPicURI.remove(0);
sendVisitorEventBRtoHDCLINKER(strType, strTime, strFileName);
prepareUploadPicturesOnFTPServer(strDong, strHo);
}
@Override
public void ProcDoing() {
Log.i(TAG, "[send_visitor_access_info_request] ProcDoing()");
}
});
return true;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] send_visitor_access_info_request(String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return false;
}
public boolean send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage) {
try {
Log.i(TAG, "[send_visitor_access_info_request] bResult [" + bResult + "], strDong [" + strDong + "], strHo [" + strHo + "], strType [" + strType + "], strTime [" + strTime + "], strFileName [" + strFileName + "], strMessage [" + strMessage + "]");
final Notice_visitor_upload_complete visitor_upload_complete = new kr.co.icontrols.icwallpadmain.imap.Notice_visitor_upload_complete(getApplicationContext());
if (visitor_upload_complete.send_visitor_access_info(bResult, strDong, strHo, strType, strTime, strFileName, strMessage)) {
visitor_upload_complete.setResultCtrl(new RetProci() {
@Override
public void ProcSuccess() {
Log.i(TAG, "[send_visitor_upload_complete_notice] ProcSuccess()");
}
@Override
public void ProcError() {
Log.i(TAG, "[send_visitor_upload_complete_notice] ProcError()");
}
@Override
public void ProcDoing() {
Log.i(TAG, "[send_visitor_upload_complete_notice] ProcDoing()");
}
});
return true;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] send_visitor_upload_complete_notice(boolean bResult, String strDong, String strHo, String strType, String strTime, String strFileName, String strMessage)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return false;
}
/**
* 이통사 연동 서비스를 위한 BR
* 방문자 사진이 발생 할때 BR 을 전송한다.
*
* @param kind (String) "lobby" or "home"
* @param datetime (String) 20170821150431 or 20170821_150431 or 2017_08_21_15_04_31
*/
public void sendVisitorEventBRtoHDCLINKER(String kind, String datetime, String filename) {
try {
Log.i(TAG, "[sendVisitorEventBRtoHDCLINKER] kind [" + kind + "], datetime [" + datetime + "], filename [" + filename + "]");
final String BR_ACTION_BASE = "kr.co.icontrols.mobileservice.BR_";
final int BASE = define.BR_COM_MOBILE_SERVICE;
final String BR_VISITOR_EVENT = BR_ACTION_BASE + "VISITOR_EVENT_HDC" + "(" + BASE + ")";
Intent mIntent = new Intent();
mIntent.setAction(BR_VISITOR_EVENT);
mIntent.putExtra("KIND", kind);
mIntent.putExtra("TIME", datetime);
mIntent.putExtra("FILENAME", filename);
getApplicationContext().sendBroadcast(mIntent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendVisitorEventBRtoHDCLINKER(String kind , String datetime, String filename)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
BroadcastReceiver mWallPadCTRDevBR = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ========== START ==========");
Bundle bundle;
WallpadDeviceSet devset;
Intent newintent;
boolean CallAppRun = false;
boolean MgrAppRun = false;
final String packageName = "com.artncore.apps.ic_wallpad";
final String packageNameMgr = "com.artncore.managersetting";
//CallAppRun = getForegroundAPK().equals(packageName);
// CallAppRun = getCallAppRunning();
MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
int Menu_Start_Option = 1;
if (intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT) != null) {
KeyEvent ReceiveEvt = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
int keyevt = ReceiveEvt.getKeyCode();
if (keyevt > WallPadInterface.EVT_SENSOR_EMRGENCY - 1 && keyevt < WallPadInterface.EVT_SENSOR_MOTIONOUT + 1) {
WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
int salsesample = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_SENSOR_DETECTING);
sdata.closeDB();
if (salsesample == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
return;
}
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int PsTnStAtUs = mWallpadStatusData.GetPSTNStatus();
int AlarmStatus = mWallpadStatusData.GetAlarmStatus();
boolean updatestate = mWallpadStatusData.GetUpgradeState();
mWallpadStatusData.closeDB();
WallpadSalesSampleData sdata = new WallpadSalesSampleData(getApplicationContext());
int salsesampleHWBtn = sdata.getSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_HW_BUTTON_OPERATION);
sdata.closeDB();
Log.d(TAG, "[mWallPadCTRDevBR.onReceive] AlarmStatus : " + AlarmStatus);
Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getAction() : " + ReceiveEvt.getAction() + " MainActivity.bWallPadCallLive : " + bWallPadCallLive);
Log.d(TAG, "[mWallPadCTRDevBR.onReceive] ReceiveEvt.getKeyCode() : " + ReceiveEvt.getKeyCode());
int nModelType = Version.getModelType();
switch (ReceiveEvt.getKeyCode()) {
case 251: // 현산향 비상버튼 다운 업 처리
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
if (ReceiveEvt.getAction() == KeyEvent.ACTION_DOWN) {
if (mGleInterface != null) mGleInterface.setEmerLedOnOff(true);
} else if (ReceiveEvt.getAction() == KeyEvent.ACTION_UP) {
if (mGleInterface != null) mGleInterface.setEmerLedOnOff(false);
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case WallPadInterface.EVT_RING:
case WallPadInterface.BTN_PSTN_RING_IHN1010:
Log.w(TAG, "########## PSTN EVT_RING ##########");
// 전화 수신 링 수신
// runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
if (Version.getGatewayUsage()) {
// 국선 시작만 올라온다.
startIGW300RingGenerator();
runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
} else {
runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.PSTN, AlarmStatus);
}
break;
case WallPadInterface.EVT_END_RING:
// 전화 수신 링 종료
// Jeff added below codes for call app (2018.01.25)
// This event is managed by WallPadCall
Log.w(TAG, "########## This event is managed by WallPadCall ##########");
if (Version.getGatewayUsage()) {
stopIGW300RingGenerator();
}
break;
case WallPadInterface.BTN_EMR:
case WallPadInterface.BTN_EMR_IHN1010:
Log.w(TAG, "########## EMERGENCY BUTTON ##########");
// 월패드 비상버튼 입력 SA 와 GLE 공통
Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
if (MgrAppRun) return;
if (Common.DIAGNOSTIC_MODE) return;
if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
return;
//currentTime = System.currentTimeMillis();
//if (ALERTTIME > currentTime) break;
//ALERTTIME = currentTime+EVENTTIMELIMITE;
Log.d(TAG, "AlarmStatus : " + AlarmStatus);
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
devset = new WallpadDeviceSet(getApplicationContext());
int StatusVal = devset.GetDeviceSetted("알람발생");
devset.closeDB();
Log.d("imap", "StatusVal : " + StatusVal);
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
// 보안 처리가 필요함..
// 지속적으로 이벤트가 들어올 경우 대비
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
// 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
if (getIsSubWallpad()) {
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
getApplicationContext().sendBroadcast(notiIntent);
}
break;
case WallPadInterface.BTN_CALL:
case WallPadInterface.BTN_CALL_IHN1010:
// 방범 모드 실행중에는 버튼 동작 하지 않도록 처리한다.
if (AlarmStatus == WallpadStatusData.GUARD_OUT) break;
if (AlarmStatus == WallpadStatusData.ALARM_ARISE) break;
// Jeff added below codes for call app (2018.01.25)
try {
Log.w(TAG, "[WallPadInterface.BTN_CALL] New Call App!!!");
if (getIsSubWallpad()) {
// 서브월패드
runCallMainActivity(CALLOWNER.SUB_WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
} else {
// 메인월패드
if (MainActivity.bRecordStatus) {
// 거동수상자 녹화 중 하단 현관 버튼 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
Log.d(TAG, "[WallPadInterface.BTN_CALL] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.NOTICE_FRONT_MONITOR_BTN);
getApplicationContext().sendBroadcast(iIntent);
}
runCallMainActivity(CALLOWNER.WALLPAD, CALLEVENTTYPE.REQUEST_FRONT_MONITORING, CALLTYPE.FRONT, AlarmStatus);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] onReceive().BTN_CALL");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
break;
case WallPadInterface.BTN_OPEN:
// 월패드 문여림 버튼 입력 상태 SA
break;
case WallPadInterface.BTN_DOOR:
case WallPadInterface.BTN_DOOR_IHN1010:
// 현관 도어폰 벨 눌림 입력 상태
// Jeff added below codes for call app (2018.01.25)
Log.i(TAG, "[WallPadInterface.BTN_DOOR] bWallPadCallLive [" + bWallPadCallLive + "], bBlockFrontCall [" + bBlockFrontCall + "]");
if (!bWallPadCallLive && !bBlockFrontCall) {
if (MainActivity.bRecordStatus) {
// 거동수상자 녹화 중 현관 띵똥 눌리는 경우 BR 전송 (녹화 여부 판별 위해)
Log.d(TAG, "[WallPadInterface.BTN_DOOR] Now Stranger Recording!!! bRecordStatus [" + MainActivity.bRecordStatus + "]");
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.NOTICE_DOORCAM_BTN);
getApplicationContext().sendBroadcast(iIntent);
}
bBlockFrontCall = true;
handlerCallCtrl.removeMessages(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL);
handlerCallCtrl.sendEmptyMessageDelayed(CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL, 3000);
mWallPadAPI.SetDevService_DoorCamUseOnOff(true);
try {
if (ModelType == MODEL_TYPE.IHN_1020GL) {
mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
mIGW200.ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, true);
} else if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.DOOR_POWER, true);
mIGW300.ctrlDeviceIO(IGW300API.OUTPUT.BELL_CONT, true);
}
if (!Version.getGatewayUsage()) {
mDingDongHandler.sendEmptyMessage(0); // 띵똥
}
Log.w(TAG, "[WallPadInterface.BTN_DOOR] New Call App!!!");
runCallMainActivity(CALLOWNER.NONE, CALLEVENTTYPE.RECEIVE_CALL, CALLTYPE.FRONT, AlarmStatus);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] onReceive().BTN_DOOR");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
} else {
Log.w(TAG, "[WallPadInterface.BTN_DOOR] Call Blocked!!");
}
break;
case WallPadInterface.BTN_CAMERA_SET:
Log.d(TAG, "[BTN_CAMERA_SET.BTN_DOOR]");
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ONOFF_CAMERA_BTN);
getApplicationContext().sendBroadcast(iIntent);
break;
case WallPadInterface.EVT_SENSOR_EMRGENCY:
case WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL:
if ((Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410)
&& (ReceiveEvt.getKeyCode() == WallPadInterface.EVT_SENSOR_EMRGENCY_IHN1010_BTN_EMR_IHN1010GL)) {
Log.w(TAG, "########## EMERGENCY BUTTON ##########");
// 월패드 비상버튼 입력 SA 와 GLE 공통
Log.d("imap", "MgrAppRun : " + MgrAppRun + " , Common.DIAGNOSTIC_MODE :" + Common.DIAGNOSTIC_MODE);
if (MgrAppRun) return;
if (Common.DIAGNOSTIC_MODE) return;
if (salsesampleHWBtn == WallpadSalesSampleData.SALES_SAMPLE_MODE_DO_NOT_USED)
return;
//currentTime = System.currentTimeMillis();
//if (ALERTTIME > currentTime) break;
//ALERTTIME = currentTime+EVENTTIMELIMITE;
Log.d(TAG, "AlarmStatus : " + AlarmStatus);
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
devset = new WallpadDeviceSet(getApplicationContext());
StatusVal = devset.GetDeviceSetted("알람발생");
devset.closeDB();
Log.d("imap", "StatusVal : " + StatusVal);
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
// 보안 처리가 필요함..
// 지속적으로 이벤트가 들어올 경우 대비
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "emergency_BT");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
// 서브월패드에서 비상 발생시 메인월패드로 비상 발생 알림 커맨드 송신
if (getIsSubWallpad()) {
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ALARM_FIRED);
getApplicationContext().sendBroadcast(notiIntent);
}
} else {
Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY I/O ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
if (!getEmergencyIOUsage()) {
Log.w(TAG, "[WallPadInterface.EVT_EMR] Blocked Wallpad emergency I/O");
return;
}
if (MgrAppRun) {
Log.w(TAG, "[WallPadInterface.EVT_EMR] Manager Setting App running!! MgrAppRun [" + MgrAppRun + "]");
return;
}
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
devset = new WallpadDeviceSet(getApplicationContext());
StatusVal = devset.GetDeviceSetted("알람발생");
devset.closeDB();
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[0]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "emergency_IO");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
}
break;
case WallPadInterface.EVT_SENSOR_MAGNETIC0:
case WallPadInterface.EVT_SENSOR_MAGNETIC0_IHN1010:
Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MAGNETIC ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
// 대외향의 경우 여기에서 마그네틱이 감지된다.
if (!Version.getGatewayUsage()) setTimeStamp_Magnetic();
if (MgrAppRun) return;
if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
WallPadInterface mWallPadInterface = new WallPadInterface();
int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
if (sensorMag == 0) return;
}
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
break;
if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
Log.d(TAG, "[mWallPadCTRDevBR] OutGoingSensorWaiting [" + OutGoingSensorWaiting + "]");
if (OutGoingSensorWaiting == 0) {
// wakeupLCD();
mIOInterface.ctrlLcdWakeUp();
OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
SensorThread.start();
}
OutGoingSensorWaiting |= SENSOR_MAG;
} else {
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "magnetic");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
break;
case WallPadInterface.EVT_BLACKOUT_OCCURRED:
saveBlackoutStatus(true);
runGlobalScreenAPK(Common.GLOBALSCREEN_ID.BLACKOUT_EMERGENCY_LIGHT, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
break;
case WallPadInterface.EVT_BLACKOUT_RELEASED:
saveBlackoutStatus(false);
sendBlackoutReleasedBR();
break;
case WallPadInterface.EVT_SENSOR_REFUGELADDER:
case WallPadInterface.EVT_SENSOR_REFUGELADDER_IHN1010:
Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY REFUGELADDER ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
if (MgrAppRun) return;
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
devset = new WallpadDeviceSet(getApplicationContext());
StatusVal = devset.GetDeviceSetted("피난사다리");
int LadderSend = devset.getEscapeLadderDownSend();
String pentHouseHo = devset.getPentHouseHoEscapeLadder();
devset.closeDB();
Log.d(TAG, "pentHouseHo ======> " + pentHouseHo);
Log.d(TAG, "ladder ======> " + StatusVal + ", ladder Send ======>" + LadderSend);
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
if (!pentHouseHo.equals("")) {
// 윗집이 펜트하우스인 경우
newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
} else {
if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
else if (LadderSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
}
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
break;
case WallPadInterface.EVT_SENSOR_MOTIONIN:
case WallPadInterface.EVT_SENSOR_MOTIONIN_IHN1010:
Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-IN ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
{
// 내부동체가 상태가 변경된 경우
int[] SensorInfoDB;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
if (SensorInfoDB[0] != 1) {
//내부동체가 사용함이면 상태 검사
return;
}
if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
WallPadInterface mWallPadInterface = new WallPadInterface();
int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
if (sensorMag == 0) return;
}
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int sensor = devSet.Get_Sensor_Set();
devSet.closeDB();
if ((sensor & WallpadDeviceSet.SET_IN_MOTION) == 0) return;
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
if (AlarmStatus != WallpadStatusData.GUARD_OUT) break;
if (OutGoingSensorWaiting == 0) {
OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
SensorThread.start();
}
OutGoingSensorWaiting |= SENSOR_IN;
}
break;
case WallPadInterface.EVT_SENSOR_MOTIONOUT:
case WallPadInterface.EVT_SENSOR_MOTIONOUT_IHN1010:
Log.w(TAG, "[mWallPadCTRDevBR] ########## EMERGENCY MOTION-OUT ########## KeyCode [" + ReceiveEvt.getKeyCode() + "]");
{
// 외부동체가 상태가 변경된 경우
int[] SensorInfoDB;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
if (SensorInfoDB[1] != 1) {
// 외부동체가 사용함이면 상태 검사
return;
}
if (Version.getModelType() == MODEL_TYPE.IHN_1010 || Version.getModelType() == MODEL_TYPE.IHN_1010_I || Version.getModelType() == MODEL_TYPE.IHN_1010_I_LX2) {
WallPadInterface mWallPadInterface = new WallPadInterface();
int sensorMag = mWallPadInterface.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
if (sensorMag == 0) return;
}
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int sensor = devSet.Get_Sensor_Set();
devSet.closeDB();
//if ((sensor&WallpadDeviceSet.SET_OUT_MOTION) > 0 && (sensor&WallpadDeviceSet.SET_OUT_TO_IN_MOTION)>0) return;
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
break;
if (AlarmStatus != WallpadStatusData.GUARD_IN && AlarmStatus != WallpadStatusData.GUARD_OUT)
break;
if (AlarmStatus == WallpadStatusData.GUARD_IN && (sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
break;
/*if (AlarmStatus == WallpadStatusData.GUARD_IN && Version.getModelType() == MODEL_TYPE.IHN_D101)
{
// IHN-D101(현산향 월패드)인 경우, 재실방범 설정시 내외부동체 감지 무시 (jeff, 2019.07.24)
Log.w(TAG, "[mWallPadCTRDevBR] GUARD IN mode! Ignore Motion Sensor!!! -> MODEL_TYPE.IHN_D101");
break;
}*/
if (AlarmStatus == WallpadStatusData.GUARD_OUT) {
if (OutGoingSensorWaiting == 0) {
OutgoingCheckSensor SensorThread = new OutgoingCheckSensor();
SensorThread.start();
}
OutGoingSensorWaiting |= SENSOR_OUT;
} else {
Common.SendAppFinishReqBR(getApplicationContext());
newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
if ((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0)
newintent.putExtra("MENU_DETAIL_INFO", "bugin");
else newintent.putExtra("MENU_DETAIL_INFO", "bugout");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(newintent);
}
}
break;
}
} else {
Log.w(TAG, "[WallPadInterface] EXTRA_KEY_EVENT is null!!");
}
}
};
protected void iMAPstartActivity(Intent intent) {
try {
startActivity(intent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] iMAPstartActivity(Intent intent)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 대외향 월패드의 현관카메라 띵똥 소리를 통화앱에서 재생하므로 느린 증상 발생
* 현관카메라 키이벤트 수신시 WallPadMain에서 띵똥 음원을 재생하는 것으로 보완
* 1. 현관카메라 키이벤트 수신
* 2. 시스템 볼륨 설정 (현관카메라 띵똥 음원이 시스템 볼륨음원을 따라가지 않도록 임의 설정)
* 3. 통화패스 설정 (AUDIO_MODE_IN_VOICE_DOOR)
* 4. 통화패스 설정 확인 및 띵똥 음원 재생
* 5. 노말 통화패스 설정 (AUDIO_MODE_NORMAL)
* 6. 시스템 볼륨 원복
* 7. 통화 앱(WallPadCall) 으로 BR 전송
*/
AudioManager mAudioManager;
int check1 = 0, check2 = 0; // 핸들러 오류를 체크하기 위한 변수
Handler mDingDongHandler = new Handler() {
public void handleMessage(Message msg) {
try {
Log.d(TAG, "[mDingDongHandler] msg.what [" + msg.what + "]");
if (msg.what == 0) {
// 띵똥 볼륨이 시스템 볼륨에 따라가지 않도록 시스템 볼륨 임의 설정
int nVolume = 10;
if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I)
nVolume = 12;
mAudioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nVolume, 0);
mAudioManager.setMode(WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR);
mDingDongHandler.sendEmptyMessage(1);
} else if (msg.what == 1) {
// 띵똥 패스 체크
check1++;
if (check1 > 200) {
Log.w(TAG, "[mDingDongHandler] check1 [" + check1 + "]");
finishDingDongHandler();
check1 = 0;
return;
} else {
if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_IN_VOICE_DOOR)
mDingDongHandler.sendEmptyMessageDelayed(2, 500);
else mDingDongHandler.sendEmptyMessageDelayed(1, 50);
}
} else if (msg.what == 2) {
// 띵똥 음원 재생
mIOInterface.ctrlSetTalkPathDoor();
sendHandlerMsgDelayed(HANDLERMSG.FRONTCAM_PLAY_DINGDONG, 0, 0, 100);
} else if (msg.what == 3) {
mIOInterface.ctrlSetTalkPathNormal();
mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
mDingDongHandler.sendEmptyMessage(4);
} else if (msg.what == 4) {
// Normal 패스 체크
check2++;
if (check2 > 200) {
Log.w(TAG, "[mDingDongHandler] check2 [" + check2 + "]");
finishDingDongHandler();
check2 = 0;
return;
} else {
if (mAudioManager.getMode() == WallPadInterface.AUDIO_MODE_NORMAL)
mDingDongHandler.sendEmptyMessageDelayed(5, 50);
else mDingDongHandler.sendEmptyMessageDelayed(4, 50);
}
} else if (msg.what == 5) {
Log.d(TAG, "[mDingDongHandler] ===== DingDong finish !!! =====");
WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
int nSavedVolume = wdb.GetWallPadMasterVolume();
wdb.closeDB();
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
Intent intent = new Intent(); // 통화 앱으로 BR 전송
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_FINISH_FRONT_DINGDONG);
sendBroadcast(intent);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
finishDingDongHandler();
} catch (Exception e) {
Log.e(TAG, "[Exception] mDingDongHandler.handleMessage()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
finishDingDongHandler();
}
}
};
private void finishDingDongHandler() {
try {
Log.d(TAG, "[finishDingDongHandler]");
if (mDingDongHandler != null) {
mDingDongHandler.removeMessages(0);
mDingDongHandler.removeMessages(1);
mDingDongHandler.removeMessages(2);
mDingDongHandler.removeMessages(3);
mDingDongHandler.removeMessages(4);
mDingDongHandler.removeMessages(5);
}
WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
int nSavedVolume = wdb.GetWallPadMasterVolume();
wdb.closeDB();
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, nSavedVolume, 0); // 시스템 볼륨 원복
mAudioManager.setMode(WallPadInterface.AUDIO_MODE_NORMAL);
mIOInterface.ctrlSetTalkPathNormal();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] finishDingDongHandler()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 외출방범 대기 모드 중 사운드와 센서 체크
class OutgoingCheckSensor extends Thread {
public OutgoingCheckSensor() {
}
public void run() {
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int timedata = mWallpadStatusData.GetComeBackWaitTime();
WallPadInterface wpifc = new WallPadInterface();
mWallpadStatusData.closeDB();
int checkcount = timedata / 5;
int i;
for (i = checkcount; i > 0; i--) {
mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int alarmst = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
if (alarmst != WallpadStatusData.GUARD_OUT) break;
Sound().PlayMent(WpadSound.SND.effect.WARNING005);
Log.d(TAG, "--------- OutgoingCheckSensor ");
try {
Thread.sleep(5000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
if (i == 0) {
mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int alarmst = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
if (alarmst == WallpadStatusData.GUARD_OUT) {
Common.SendAppFinishReqBR(getApplicationContext());
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
int Menu_Start_Option = 1;
Intent mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
mIntent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
mIntent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
String Cuase = (OutGoingSensorWaiting & SENSOR_OUT) > 0 ? "bugout" : "bugin";
if ((OutGoingSensorWaiting & SENSOR_OUT) > 0) Cuase = "bugout";
else if ((OutGoingSensorWaiting & SENSOR_MAG) > 0) Cuase = "magnetic";
else if ((OutGoingSensorWaiting & SENSOR_IN) > 0) Cuase = "bugin";
mIntent.putExtra("MENU_DETAIL_INFO", Cuase);
mIntent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
iMAPstartActivity(mIntent);
}
}
Log.d(TAG, "--------- OutgoingCheckSensor End");
OutGoingSensorWaiting = 0;
}
}
@Override
public IBinder onBind(Intent arg0) {
return mMessenger.getBinder();
//return null;
}
public void imapsvrlog(String msg) {
if (!log_sw) return;
Log.d(TAG, APIErrorCode.GetLogPrefix() + " IMAPSVR:" + msg);
}
public int onStartCommand(Intent intent, int flags, int startID) {
try {
try {
handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
getDeviceCtrlOption();
SvrSock = new iMapSverSocket();
SvrSock.start();
} catch (IOException e) {
Log.e(TAG, "[IOException] [onStartCommand] SvrSock init...");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
try {
mGleInterface = new jni();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] mGleInterface init...");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addr = DBMGR.getAddressMGR();
DBMGR.closeDB();
String AddressStr = addr.Dong + "동 " + addr.Ho + "호";
AddrDong = addr.Dong;
AddrHo = addr.Ho;
ho = Integer.valueOf(AddrHo.substring(0, 1));
XMLHeader = "\r\n" +
"\r\n";
Log.d(TAG, "*****************************************");
Log.d(TAG, "****************SchedulerThread**********");
Log.d(TAG, "*****************************************");
ScheServer = new SchedulerThread();
ScheServer.start();
// BR 등록 시작
Log.d(TAG, "[onStartCommand] BR register start!!!");
IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction(Common.BR_ACK_WALLPADCALL_LIVE);
registerReceiver(WallPadCallLiveBRCheck, mIntentFilter);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction("EVENT_DEVICE_CONTROL");
// mIntentFilter.addAction(Intent.EXTRA_KEY_EVENT);
registerReceiver(mWallPadCTRDevBR, mIntentFilter);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(define.NOTIFY_ACNAME);
mIntentFilter.addAction(define.NOTIFY_DAIL);
mIntentFilter.addAction(Common.BR_BLACKOUT_SCREEN_RUN);
mIntentFilter.addAction(Common.BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
mIntentFilter.addAction(define.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK); // 거주자 안전 확인
registerReceiver(mWallPadNotifyBR, mIntentFilter);
Log.d(TAG, "[onStartCommand] BR register end!!!");
// BR 등록 완료
mWallPadAPI = new WallPadAPI(this.getApplicationContext());
if (Version.getModelType() == MODEL_TYPE.IHN_1020GL)
IGW200APICheckHandler.sendEmptyMessage(0);
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
IGW300APICheckHandler.sendEmptyMessage(0);
}
mIOInterface = new IOInterface(getApplicationContext(), mWallPadAPI);
mIOInterface.setEmergencyType();
Intent notiIntent = new Intent();
notiIntent.setAction(define.NOTIFY_ACNAME);
notiIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_IMAPSERVER_START);
getApplicationContext().sendBroadcast(notiIntent);
CheckMainStatus();
checkDoorCamConfig(); // 현관카메라 설정정보 확인
getAirQualityUsage();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020SA_A) {
SendLHGWCheck GwCheckThread = new SendLHGWCheck();
GwCheckThread.start();
}
getResidentSafetyCheckSetting();
return START_STICKY;
}
//멀티기기 정보 전송을 위한 추가
public static final int MSG_REGISTER_CLIENT = 1;
//public static final int MSG_UNREGISTER_CLIENT = 2;
public static final int MSG_SEND_TO_SERVICE_DEVICES1 = 30;
public static final int MSG_SEND_TO_SERVICE_DEVICES2 = 31;
public static final int MSG_SEND_TO_SERVICE_DEVICES3 = 32;
public static final int MSG_SEND_TO_ACTIVITY = 4;
private Messenger mClient = null; // Activity 에서 가져온 Messenger
String remote_get_home_devices1;
String remote_get_home_devices2;
String remote_get_home_devices3;
int skipCount = 0;
/**
* activity로부터 binding 된 Messenger
*/
private final Messenger mMessenger = new Messenger(new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case MSG_REGISTER_CLIENT:
mClient = msg.replyTo; // activity로부터 가져온
break;
case MSG_SEND_TO_SERVICE_DEVICES1:
remote_get_home_devices1 = (String) msg.obj; // activity로부터 가져온
break;
case MSG_SEND_TO_SERVICE_DEVICES2:
remote_get_home_devices2 = (String) msg.obj; // activity로부터 가져온
break;
case MSG_SEND_TO_SERVICE_DEVICES3:
remote_get_home_devices3 = (String) msg.obj; // activity로부터 가져온
break;
default:
break;
}
return false;
}
}));
private void sendMsgToActivity(int sendValue) {
try {
Bundle bundle = new Bundle();
bundle.putInt("fromService", sendValue);
Message msg = Message.obtain(null, MSG_SEND_TO_ACTIVITY);
msg.setData(bundle);
if(mClient!=null) {
mClient.send(msg); // msg 보내기
}
} catch (Exception e) {
}
}
// 메인 서버 소켓 클래스
public class iMapSverSocket extends Thread {
ServerSocket svr;
private SSLServerSocket sslsvr;
boolean receiveSocketRun = true;
public iMapSverSocket() throws IOException {
/////////////////////////////////////////////////////////////////////
// 신형 단지서버 사용 유무를 가져온다.
/////////////////////////////////////////////////////////////////////
try {
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
wallpadDeviceSet.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
mNewDanjiServer = false;
} catch (Exception e) {
Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
mNewDanjiServer = false;
}
//////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// 신형 단지서버 사용유무에 따라 서버소켓을 생성한다.
/////////////////////////////////////////////////////////////////////
if (!mNewDanjiServer) {
svr = new ServerSocket(port);
} else {
int svrport = port + 1000;
Log.i(TAG, "============================================");
Log.i(TAG, "Use SSL Server Start !!! (port:" + svrport + ")");
Log.i(TAG, "============================================");
SSLServer sslServerSocket = new SSLServer(svrport, getResources().openRawResource(R.raw.wallpad_key), "icontrolswallpad1845!");
sslsvr = sslServerSocket.getServerSocket();
}
}
public void run() {
while (receiveSocketRun) {
try {
Socket sock = null;
/////////////////////////////////////////////////////////////////////
// 신형 단지서버 사용유무에 각각의 socket 에서 accept 를 한다.
/////////////////////////////////////////////////////////////////////
if (!mNewDanjiServer) {
sock = svr.accept();
} else {
sock = sslsvr.accept();
}
iMapSverSocketThread ProciMap = new iMapSverSocketThread(sock);
ProciMap.start();
} catch (IOException e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
public void destoryThread() {
receiveSocketRun = false;
try {
if (svr != null) {
svr.close();
svr = null;
}
if (sslsvr != null) {
sslsvr.close();
sslsvr = null;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
public String getRemoteIPAddress(Socket Sock) {
try {
// Log.i(TAG, "[getRemoteIPAddress] == START ==");
if (Sock == null) return "10.0.1.1";
String strRemoteIP = Sock.getRemoteSocketAddress().toString();
String[] strSplited_01 = strRemoteIP.split(":");
String[] strSplited_02 = strSplited_01[0].split("/");
strRemoteIP = strSplited_02[1];
return strRemoteIP;
} catch (Exception e) {
Log.e(TAG, "[Exception] getRemoteIPAddress(Sock)");
e.printStackTrace();
return "10.0.1.1";
}
}
// iMAP 서버 소켓 처리
public class iMapSverSocketThread extends Thread {
private final Socket iMAPSock;
String strRcvMSG;
WallPadiMAPUpgrade upgradeProc;
Document doc;
public iMapSverSocketThread(Socket sock) {
iMAPSock = sock;
}
public void run() {
try {
Log.i(TAG, "[iMAPSvrProc().run()] Received something!!");
InputStream InStm = iMAPSock.getInputStream();
iMAPSock.setSoLinger(true, 3000);
BufferedReader MsgReader = new BufferedReader(new InputStreamReader(InStm, "euc-kr"));
strRcvMSG = "";
String InBuffer;
int i = 0;
boolean bRcvOK = false;
lSocketConnectionPeriod = System.currentTimeMillis() + TIMEOUT_iMAP_WAIT; // 타임아웃시간을 설정한다.
/////////////////////////////////////////////////////////////////////
// 신형단지서버 미사용중일 경우 기존 코드로,
// 사용중일 경우 ready 를 사용하지 않는 수신부로 수행한다.
// (사유:암호화를 사용할 경우 ready 최초 동작되지않음)
/////////////////////////////////////////////////////////////////////
if (!mNewDanjiServer) {
while (System.currentTimeMillis() < lSocketConnectionPeriod) {
try {
if (MsgReader.ready()) {
try {
char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
InBuffer = "";
while (MsgReader.ready()) {
long charCnt = MsgReader.read(ReadData);
InBuffer += new String(ReadData, 0, (int) charCnt);
}
if (InBuffer != null) strRcvMSG += InBuffer;
if (0 < InBuffer.indexOf("")) {
bRcvOK = true;
Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!!");
break;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return;
} catch (Exception e) {
Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 1 =====");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return;
}
} else {
Thread.sleep(100);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
iMAPSock.close();
return;
} catch (Exception e) {
Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 =====");
iMAPSock.close();
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return;
}
}
} else {
// SSL 암호화 데이터 수신부
// * ready() 가 정상동작 되지않아 아래 와 같이 수신부를 수정함.
char[] ReadData = new char[SOCKET_BUFFER_SIZE_READ * 1024];
while (System.currentTimeMillis() < lSocketConnectionPeriod) {
try {
InBuffer = "";
long charCnt = MsgReader.read(ReadData);
if (charCnt > 0) {
InBuffer += new String(ReadData, 0, (int) charCnt);
strRcvMSG += InBuffer;
if (-1 < InBuffer.indexOf("")) {
bRcvOK = true;
Log.i(TAG, "[iMAPSvrProc().run()] Received DONE!! (SSL)");
break;
}
} else {
Thread.sleep(100);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
iMAPSock.close();
return;
} catch (Exception e) {
Log.e(TAG, "[Exception] iMAPSvrProc.run() ===== 2 ===== (SSL)");
iMAPSock.close();
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return;
}
}
}
if (!bRcvOK) {
Log.i(TAG, "[iMAPSvrProc().run()] iMAP message is unacceptable!!");
Log.i(TAG, "[iMAPSvrProc().run()] ========== START ==========");
Log.i(TAG, strRcvMSG);
Log.i(TAG, "[iMAPSvrProc().run()] ========== END ==========");
iMAPSock.close();
return;
}
strRcvMSG = strRcvMSG.substring(strRcvMSG.indexOf("<"));
imapsvrlog("Socket read end accept \n" + strRcvMSG);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream istream = new ByteArrayInputStream(strRcvMSG.getBytes());
doc = builder.parse(istream);
Element elelist = doc.getDocumentElement();
NodeList items = elelist.getElementsByTagName("service");
Node item = items.item(0);
NamedNodeMap attrs = item.getAttributes();
String retXML = "";
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
String cmd;
if (attr.getNodeName().equalsIgnoreCase("type")) {
cmd = attr.getNodeValue();
if (cmd.equalsIgnoreCase("notice")) {
iMAPSock.close();
}
} else if (attr.getNodeName().equalsIgnoreCase("name")) {
cmd = attr.getNodeValue();
if (cmd.equalsIgnoreCase("event_notify")) {
retXML = ProcEventNotify(elelist);
} else if (cmd.equalsIgnoreCase("elevator_move_info")) {
ProcElevatorinfo(elelist);
retXML = null;
} else if (cmd.equalsIgnoreCase("check_epics_upload")) {
retXML = ProcCheckEpiceUpload(doc);
} else if (cmd.equalsIgnoreCase("update_news")) {
retXML = ProcUpdateNews(doc);
} else if (cmd.equalsIgnoreCase("update_weather")) {
retXML = ProcUpdateWeather(doc);
} else if (cmd.equalsIgnoreCase("schedule_inquiry")) {
retXML = ProcSchduleInquiry(doc);
} else if (cmd.equalsIgnoreCase("schedule_renew")) {
retXML = ProcSchduleRenew(doc);
} else if (cmd.equalsIgnoreCase("schdule")) {
String SvcType = "";
int k;
for (k = j + 1; k < attrs.getLength(); k++) {
Node attr1 = attrs.item(k);
SvcType = attr1.getNodeName();
if (SvcType.equalsIgnoreCase("shc_type")) {
SvcType = attr1.getNodeValue();
break;
}
}
retXML = ProcUpdateSchedule(elelist, SvcType);
} else if (cmd.equalsIgnoreCase("device_reset")) {
retXML = ProcDeviceReset(elelist);
} else if (cmd.equalsIgnoreCase("notify_parcel_event")) {
retXML = ProcNotifyparcel(doc);
} else if (cmd.equalsIgnoreCase("notify_post_info")) {
// 스마트우편함 연동 여부
WallpadDeviceSet DevSet = new WallpadDeviceSet(getApplicationContext());
boolean bSmartPostUsage = DevSet.Get_SmartPostUse();
DevSet.closeDB();
Log.d(TAG, "[iMapSverSocketThread.run()] bSmartPostUsage [" + bSmartPostUsage + "]");
if (bSmartPostUsage) retXML = ProcNotiPostInfo(doc); // 스마트우편함
} else if (cmd.equalsIgnoreCase("get_security_mode")) {
String Dong = null;
String Ho = null;
WallpadStatusData statusDB = new WallpadStatusData(getApplicationContext());
String result;
String modeStr = null;
int status = statusDB.GetAlarmStatus();
if ((status == WallpadStatusData.ALARM_NONE) || (status == WallpadStatusData.GUARD_IN) || (status == WallpadStatusData.GUARD_OUT) || (status == WallpadStatusData.GUARD_OUT_WAIT)) {
if (status == WallpadStatusData.ALARM_NONE) modeStr = "normal";
else if (status == WallpadStatusData.GUARD_IN) modeStr = "occupied";
else if (status == WallpadStatusData.GUARD_OUT)
modeStr = "unoccupied";
else if (status == WallpadStatusData.GUARD_OUT_WAIT)
modeStr = "waitunoccupied";
result = "ok";
} else {
modeStr = "null";
result = "fail";
}
try {
NodeList GSM_items = elelist.getElementsByTagName("home_info");
Node GSM_item = GSM_items.item(0);
NamedNodeMap GSM_attrsParam = GSM_item.getAttributes();
for (int k = 0; k < GSM_attrsParam.getLength(); k++) {
Node GSM_attr = GSM_attrsParam.item(k);
if (GSM_attr.getNodeName().equalsIgnoreCase("dong"))
Dong = trimquotation(GSM_attr.getNodeValue());
else if (GSM_attr.getNodeName().equalsIgnoreCase("ho"))
Ho = trimquotation(GSM_attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((Dong.equalsIgnoreCase(addc.Dong) == false) || (Ho.equalsIgnoreCase(addc.Ho) == false)) {
result = "fail";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
result = "fail";
} catch (Exception e) {
result = "fail";
}
retXML = XMLHeader +
" \r\n" +
" \r\n" +
" \r\n" +
"\r\n";
statusDB.closeDB();
} else if (cmd.equalsIgnoreCase("set_setup_info")) {
retXML = ProcSetsetup(doc);
} else if (cmd.equalsIgnoreCase("get_setup_info")) {
retXML = ProcGetsetup(doc);
} else if (cmd.equalsIgnoreCase("check_lobby_passwd")) {
retXML = CheckPassword(doc);
} else if (cmd.equalsIgnoreCase("device_live_check")) {
retXML = ProcDeviceLiveCheck();
} else if (cmd.equalsIgnoreCase("pairing_hdev_sync_alarm")) {
retXML = ProcPairingHdevSyncAlarm(elelist);
} else if (cmd.equalsIgnoreCase("pairing_hdev_sync_security")) {
retXML = ProcPairingHdevSyncSecurity(elelist);
} else if (cmd.equalsIgnoreCase("notify_car_event")) {
retXML = ProcParkInformation(elelist);
} else if (cmd.equalsIgnoreCase("notify_smartkey_event")) {
retXML = ProcSmartKeyEvent(elelist);
} else if (cmd.equalsIgnoreCase("notify_parkinfo_cham_upis")) {
retXML = ProcParkInformation_cham_upis(elelist);
} else if (cmd.equalsIgnoreCase("remote_auscultate")) {
retXML = ProcauscultateReq(doc);
} else if (cmd.equalsIgnoreCase("upgrade")) {
imapsvrlog("Enter Upgrade");
procUpgrade();
retXML = null;
} else if (cmd.equals("check_sip_activation")) {
String sip_result = "fail";
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List rsi = manager.getRunningServices(50);
//add KSJ 2021.11.02 socket addr 가져오기 위해 추가
String strIP = getRemoteIPAddress(iMAPSock);
//~add KSJ
// Jeff added below codes for call app (2018.01.25)
String strSIPPackageName = "kr.co.icontrols.callengine.sip.SIPStun";
for (int k = 0; k < rsi.size(); k++) {
ActivityManager.RunningServiceInfo rsInfo = rsi.get(k);
if (rsInfo.service.getClassName().equals(strSIPPackageName)) {
sip_result = "ok";
break;
}
}
if(bWallPadCallLive && m_bWallpadCallScreen == false)
{
sip_result = "fail";
}
if(m_CallAppRunDelay == false)
{
retXML = XMLHeader + "\r\n \"null\"\r\n\r\n\r\n";
//add KSJ 2021.11.02 check_sip_activation msg recv 이후 wallpadcall app start
String[] IP_Parse = strIP.split("\\.");
Log.d(TAG, "1" + strIP);
//Log.d(TAG, "2" + strSplit[1]);
//Log.d(TAG, "3" + strSplit[2]);
//Log.d(TAG, "4" + strSplit[3]);
CALLTYPE eCallType = CALLTYPE.LOBBY;
if (IP_Parse[2].equals("0")) {
eCallType = CALLTYPE.LOBBY;
if (IP_Parse[3].equals("11"))
eCallType = CALLTYPE.FRONT;
} else if (IP_Parse[2].equals("129")) {
eCallType = CALLTYPE.FRONT;
} else {
eCallType = CALLTYPE.RESIDENCE;
}
if ((eCallType == CALLTYPE.LOBBY) || (eCallType == CALLTYPE.FRONT)) {
m_CallAppRunDelay = true;
runCallMainActivity_moip(CALLEVENTTYPE.RECEIVE_CALL, eCallType, strIP);
}
}
else
{
sip_result = "fail";
retXML = XMLHeader + "\r\n \"null\"\r\n\r\n\r\n";
}
}
//add KSJ 2021.11.02 stop_talking msg 추가 (wallpadcall 종료)
else if (cmd.equals("stop_talking")) {
String sip_result = "ok";
//sip_result = "ok";
retXML = XMLHeader + "\r\n \"null\"\r\n\r\n\r\n";
Common.SendAppFinishReqBR(getApplicationContext());
}
//~add KSJ
//add 2022.03.02 front_open msg 추가 (현관에서 문열림 요청)
else if (cmd.equals("front_open")) {
retXML = ProcFrontOpen();
}
//~add
else if (cmd.equalsIgnoreCase("remote_get_home_devices")) {
retXML = iCMDProcDevList(doc);
} else if (cmd.equalsIgnoreCase("remote_access_gas")) {
retXML = iCMDProcGASControl(elelist);
} else if (cmd.equalsIgnoreCase("remote_access_smartlight")) {
// 현대건설 더펜트하우스 와 구분하여 처리
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
mWallpadDeviceSet.closeDB();
if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST) {
retXML = iCMDProcChumDamSmartLightControl(doc);
}
else {
retXML = iCMDProcSDPSmartLightControl(doc);
}
} else if (cmd.equalsIgnoreCase("remote_access_livinglight")) {
if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
|| ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
retXML = iCMDProc_I_LightControl(doc);
} else {
retXML = iCMDProcLivingLightControl(doc);
}
} else if (cmd.equalsIgnoreCase("remote_access_electric")) {
if (ModelType == Version.MODEL_TYPE.IHN_D101 || ModelType == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| ModelType == Version.MODEL_TYPE.IHN_D101K || ModelType == Version.MODEL_TYPE.IHN_D101K_I
|| ModelType == MODEL_TYPE.IHN_D101_I_OCF) {
retXML = iCMDProcSDPConcentControl(doc);
} else if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
|| ModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443 || ModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
retXML = iCMDProcEnergyMeterConcentControl(doc);
} else {
retXML = iCMDProcMultiSWControl(doc);
}
} else if (cmd.equalsIgnoreCase("remote_access_doorlock")) {
retXML = iCMDProcDoorlockControl(doc);
} else if (cmd.equalsIgnoreCase("remote_access_temper")) {
retXML = iCMDProcTemperControl(doc);
} else if (cmd.equalsIgnoreCase("remote_access_mode")) {
retXML = iCMDProcModeControl(doc);
} else if (cmd.equalsIgnoreCase("remote_access_ventil")) {
retXML = iCMDProcVentilControl(doc);
} else if (cmd.equalsIgnoreCase("remote_access_curtain")) {
retXML = iCMDProcCurtainControl(doc);
} else if (cmd.equalsIgnoreCase("remote_access_light")) {
if (ModelType == MODEL_TYPE.IHN_1020GL || ModelType == MODEL_TYPE.IHN_1010GL || ModelType == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410) {
retXML = iCMDProcEnergyMeterLightControl(doc);
} else {
retXML = iCMDProcLightControl(doc);
}
} else if (cmd.equalsIgnoreCase("remote_access_light_batch_control")) {
retXML = iCMDProcLightBatchControl(elelist);
}
else if (cmd.equalsIgnoreCase("remote_access_sysaircon")) {
retXML = iCMDProcSysairconControl(elelist);
}
//모바일 사용자 인증 관련 메시지
else if (cmd.equalsIgnoreCase("remote_register_new_device_auth_number")) {
ProcMobileDevice_AuthNumber(elelist);
} else if (cmd.equalsIgnoreCase("remote_register_new_device")) {
retXML = ProcMobileDevice_ADD_Finish(elelist);
} else if (cmd.equalsIgnoreCase("remote_delete_device")) {
ProcMobileDevice_Delete(elelist);
} else if (cmd.equalsIgnoreCase("get_accesskey_info")) {
retXML = ProcGetSmartKeyInfo(elelist);
} else if (cmd.equalsIgnoreCase("get_app_version_info")) {
retXML = ProcGetAppVersionInfo();
} else if (cmd.equalsIgnoreCase("igate_init_info")) {
retXML = ProcIgateInitInfo(elelist);
} else if (cmd.equalsIgnoreCase("elec_car_charge_event")) {
retXML = ProcElecCarChargeEventInfo(elelist);
} else if (cmd.equalsIgnoreCase("energy_target_info_alarm")) {
retXML = ProcEnergyTargetInfoAlarm(elelist);
} else if (cmd.equalsIgnoreCase("check_call_option")) {
retXML = ProcCheckCallOption();
} else if (cmd.equalsIgnoreCase("chat_sequence")) {
retXML = ProcChatSequence(elelist);
} else if (cmd.equalsIgnoreCase("chat_message")) {
retXML = ProcChatMessage(elelist);
} else if (cmd.equalsIgnoreCase("evacuation_ladder_open")) {
retXML = ProcEvacuationLadderOpen(elelist);
} else if (cmd.equalsIgnoreCase("smart_light_info")) {
retXML = SmartLightDetailInfo(elelist);
} else if (cmd.equalsIgnoreCase("get_knx_device_info")) {
retXML = KNXDeviceDetailInfo(elelist);
} else if (cmd.equalsIgnoreCase("set_server_version")) {
retXML = ProcSetServerChange(elelist);
} else if (cmd.equalsIgnoreCase("remote_access_onepass")) {
retXML = iCMDProcOnePass(elelist);
} else if (cmd.equalsIgnoreCase("remote_entire_access_light_control")) {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
retXML = iCMDProcEntireLightControl(doc); // 전체 조명 제어
}
} else if (cmd.equalsIgnoreCase("check_resident_safety")) {
retXML = iCMDProcResidentSafety(elelist);
}
break;
}
}
if (retXML != null) {
imapsvrlog("Socket write line\n" + retXML + "\r\n SO :" + iMAPSock.getSoLinger());
DataOutputStream outstream = new DataOutputStream(iMAPSock.getOutputStream());
byte[] outBF = retXML.getBytes("euc-kr");
outstream.write(outBF);
outstream.flush();
try {
Thread.sleep(3000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
iMAPSock.close();
} else {
try {
iMAPSock.close();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
try {
iMAPSock.close();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception E) {
LogUtil.errorLogInfo("", TAG, E);
}
LogUtil.errorLogInfo("", TAG, e);
}
}
// Upgrade 설정 상태를 확인 하여 Upgrade 진입 여부 결정
private void procUpgrade() {
imapsvrlog("upgrade Start \n" + " " + WallPadiMAPUpgrade.active);
WallpadStatusData sdb = new WallpadStatusData(getApplicationContext());
String[] getstate = sdb.GetSystemUpdateStatus();
sdb.closeDB();
Log.i(TAG, "WallPadiMAPUpgrade.active [" + WallPadiMAPUpgrade.active + "]");
for (int i = 0; i < getstate.length; i++) {
Log.i(TAG, "getstate[" + i + "] = " + getstate[i]);
}
if (WallPadiMAPUpgrade.active == true || getstate[0].equalsIgnoreCase("SET")) return;
upgradeProc = new WallPadiMAPUpgrade(getApplicationContext(), doc, iMAPSock);
if (WallPadiMAPUpgrade.active == true) upgradeProc.StartUpgrade();
}
}
// " 제거
private String trimquotation(String sen) {
sen = sen.replaceAll("\"", "");
return sen.trim();
}
//remote_auscultate 처리
public String ProcauscultateReq(Document Doc) {
String RetVal = XMLHeader + "\r\n \"" + itemname + "\"\r\n\r\n";
SettManager.closeDB();
return RetVal;
} catch (Exception e) {
RetVal += "\"fail\" >\r\n \"" + itemname + "\"\r\n\r\n";
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
SettManager.closeDB();
return RetVal;
}
SettManager.closeDB();
RetVal += "\"ok\" >\r\n \r\n";
StatusBeatRequested = true;
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTSTATUSBEAT);
sendBroadcast(intent);
return RetVal;
}
public void DefaultProcauscultateReq(WallpadDevStatus SettManager) {
String defaultAUSSet = "\r\n" +
"\r\n" +
"\r\n" +
" \r\n" +
" \r\n" +
" \"light\"\r\n" +
" \"thermostat\"\r\n" +
" \"gas\"\r\n" +
" \"doorlock\"\r\n" +
" \"ventil\"\r\n" +
" \r\n" +
" \r\n" +
" \"sub_homedev\"\r\n" +
" \"kitchen_tv\"\r\n" +
" \"bath_tv\"\r\n" +
" \"bath_phone\"\r\n" +
" \r\n" +
" \r\n" +
" \"magnetic\"\r\n" +
" \"bugout\"\r\n" +
" \"bugin\"\r\n" +
" \"fire\"\r\n" +
" \"gas\"\r\n" +
" \"emergency\"\r\n" +
" \r\n" +
" \r\n" +
" \"gateway\"\r\n" +
" \"smartswitch\"\r\n" +
" \"handy\"\r\n" +
" \"energymeter\"\r\n" +
" \r\n" +
" \r\n" +
"\r\n" +
"\r\n";
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream istream = new ByteArrayInputStream(defaultAUSSet.getBytes());
Document doc = builder.parse(istream);
NodeList items = doc.getElementsByTagName("group");
Node item;
String itemname = null;
SettManager.DeleteSettingData();
SettManager.DropTable();
for (int i = 0; i < items.getLength(); i++) {
item = items.item(i);
itemname = GetAttributeVal(item, "type");
String GetCNT = GetAttributeVal(item, "count");
if (Integer.parseInt(GetCNT) <= 0)
continue;
Element SettingItem = (Element) item;
NodeList SettingList = SettingItem.getElementsByTagName("unit");
for (int j = 0; j < SettingList.getLength(); j++) {
Node subdevListitem = SettingList.item(j);
String devname = trimquotation(subdevListitem.getTextContent());
SettManager.InsertSettingData(itemname, devname, j);
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
String MakeFailMessage(String msg) {
return XMLHeader + "\r\n \"" + msg + "\"\r\n\r\n";
}
//SetInfo의 각 항목들의 무결성 확인
final String isUse = "사용함";
final String isNotUse = "사용안함";
boolean CheckSubdevData(String devName, String devData) {
String[] SplitedMSG;
try {
if (devName.equals("가스밸브")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String UseStr = SplitedMSG[2].split("[)]")[0];
if (!UseStr.equals(isUse) && !UseStr.equals(isNotUse)) return false;
} else if (devName.equals("디지털도어락")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
if (!UseStr[1].equals("종류")) return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("무선") && !UseStr[0].equals("유선")) return false;
} else if (devName.equals("온도조절기")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("조명제어기")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
if (!UseStr[1].equals("종류"))
return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("대외기본형")&&!UseStr[0].equals("대외각실형")&&!UseStr[0].equals("현산향일체형조명기본형")&&!UseStr[0].equals("현산향일체형조명일괄소등병합형"))
return false;
*/
} else if (devName.equals("환기시스템")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
if (!UseStr[1].equals("종류"))
return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("기본")&&!UseStr[0].equals("LH향")&&!UseStr[0].equals("후드"))
return false;
*/
} else if (devName.equals("시스템에어컨")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("전동커튼")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
if (!UseStr[1].equals("종류"))
return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("안방커튼")&&!UseStr[0].equals("거실커튼")&&!UseStr[0].equals("안방거실커튼"))
return false;
*/
} else if (devName.equals("실시간검침기")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("스마트스위치&일괄소등")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
if (!UseStr[1].equals("종류"))
return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("대외향스마트스위치")&&
!UseStr[0].equals("대외향일괄소등제어기")&&
!UseStr[0].equals("현산향3로제어일괄소등제어기")&&
!UseStr[0].equals("현산향스마트스위치")&&
!UseStr[0].equals("현산향LCD스마트스위치"))
return false;
*/
} else if (devName.equals("무선리모컨")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("현관카메라")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
if (!UseStr[1].equals("종류"))
return false;
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("기본")&&!UseStr[0].equals("RF현관카메라")&&!UseStr[0].equals("스마트키"))
return false;
*/
} else if (devName.equals("공지사항")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("날씨")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("메모")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("전자액자")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("일정표")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("주차확인")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("기본")&&!UseStr[0].equals("아이콘트롤스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("UPIS")&&!UseStr[0].equals("ETC"))
return false;
*/
} else if (devName.equals("시간설정")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("원격검침")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("뮤직")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("영상재생")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("CCTV")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("삼성테크윈")&&!UseStr[0].equals("티벳")&&!UseStr[0].equals("베스트디지탈")&&!UseStr[0].equals("제노시스")&&!UseStr[0].equals("넥스파")&&!UseStr[0].equals("시큐인포")&&!UseStr[0].equals("하니웰"))
return false;
*/
} else if (devName.equals("명칭설정")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("출동경비")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("경비실영상통화")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("엘리베이터")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("기본")&&!UseStr[0].equals("층표시"))
return false;
*/
} else if (devName.equals("현장특화기능")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("KCC")&&!UseStr[0].equals("엠코")&&!UseStr[0].equals("한라건설")&&!UseStr[0].equals("현대건설")&&!UseStr[0].equals("LH")&&!UseStr[0].equals("SH"))
return false;
*/
} else if (devName.equals("월패드카메라")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("무드등")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
/*
UseStr = SplitedMSG[3].split("[)]");
if (!UseStr[0].equals("하단등")&&!UseStr[0].equals("상단등")&&!UseStr[0].equals("상하단등"))
return false;
*/
} else if (devName.equals("피난사다리")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("동체설정")) {
return true;
/*
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName))
return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
return false;
if (UseStr[0].equals(isNotUse)) return true;
if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
return false;
for (int i=3; i < SplitedMSG.length; i++)
{
UseStr = SplitedMSG[i].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse))
return false;
if (i != SplitedMSG.length-1)
{
if (!UseStr[1].equals("외부동체사용")&&!UseStr[1].equals("내부동체사용")&&!UseStr[1].equals("외부동체를내부동체로사용"))
return false;
}
}
*/
} else if (devName.equals("알람발생")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else if (devName.equals("UI순서")) {
SplitedMSG = devData.split("[(]");
if (!SplitedMSG[1].split(":")[1].equals(devName)) return false;
String[] UseStr = SplitedMSG[2].split("[)]");
if (!UseStr[0].equals(isUse) && !UseStr[0].equals(isNotUse)) return false;
} else {
Log.w("iMAP", "No Such Name, Set Setup devName =" + devName + ", devData =" + devData);
Log.w("iMAP", "Return true");
return true;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
return true;
}
ArrayList roomNameList_light = null;
ArrayList roomNameList_concent = null;
ArrayList roomNameList_heating = null;
ArrayList roomNameList_systemaircon = null;
ArrayList roomNameList_purity = null;
ArrayList roomNameList_shading = null;
public String ProcSetsetup(Document ele) {
Common.DebugLog("ProcSetsetup------------------------->");
String RetVal = XMLHeader + " AfterTransactionTodoList = new LinkedList();
if (!SettManager.StartTransaction()) {
ResetFlag = false;
RetVal += "\"fail\" >\r\n \"service\"\r\n\r\n";
SettManager.EndTransaction(false);
SettManager.closeDB();
return RetVal;
}
try {
for (int i = 0; i < items.getLength(); i++) {
item = items.item(i);
itemname = GetAttributeVal(item, "name");
if (itemname != null) {
if (itemname.equals("beat_time")) {
heartbeatP = GetAttributeVal(item, "value");
} else if (itemname.equals("ver_setting")) {
Versions = GetAttributeVal(item, "value");
} else if (itemname.equals(define.iMAP_NODENAME_GUARD)) {
Element guardlist = (Element) item;
NodeList GuardCTList = guardlist.getElementsByTagName("list");
if (GuardCTList.getLength() > 0) SettManager.DeleteGuardData();
else continue;
for (int j = 0; j < GuardCTList.getLength(); j++) {
Node GuardListitem = GuardCTList.item(j);
String guardname = GetAttributeVal(GuardListitem, "name");
String guardvalue = GetAttributeVal(GuardListitem, "value");
SettManager.InsertSettingData(define.iMAP_NODENAME_GUARD, guardname, j, guardvalue);
}
} else if (itemname.equals(define.iMAP_NODENAME_SUBDEV)) {
Element subdevList = (Element) item;
NodeList SubDevList = subdevList.getElementsByTagName("list");
for (int j = 0; j < SubDevList.getLength(); j++) {
Node subdevListitem = SubDevList.item(j);
String devname = GetAttributeVal(subdevListitem, "name");
String devval = GetAttributeVal(subdevListitem, "value");
if (devname != null && devval != null) {
devname = devname.replaceAll("\\p{Z}", "");
devval = devval.replaceAll("\\p{Z}", "");
if (devname.indexOf("스마트스위치_일괄소등") >= 0) {
devname = devname.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
devval = devval.replaceAll("스마트스위치_일괄소등", "스마트스위치&일괄소등");
}
if (CheckSubdevData(devname, devval) == false) {
ResetFlag = false;
Log.w("iMAP", "Set Setup Fail name : " + devname + " Value : " + devval);
SettManager.EndTransaction(false);
SettManager.closeDB();
return MakeFailMessage(devname);
}
String[] SettingDBValue = SettManager.GetSettingData(devname);
if (SettingDBValue != null) {
String devInfo = SettingDBValue[1];
if (devInfo.equals(devval) == false) {
Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
Log.w("iMAP", "DB Setup Value : " + devInfo);
SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
ResetFlag = true;
}
} else {
Log.w("iMAP", "DB No Setup Name and Value");
Log.w("iMAP", "Set Setup(imap) Name : " + devname + " Value : " + devval);
SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
ResetFlag = true;
}
//iMAP 설정값 수신 시 즉시 적용해야할 사항들.
if (devname.equals("로고설정")) {
String devInfo = devval;
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] DetailInfo = devInfo.split("_");
int LogoType = 0;
if (DetailInfo[5].equals("표시안함") == true) {
LogoType = 0;
} else if (DetailInfo[5].equals("SKT스마트홈") == true) {
LogoType = 1;
} else if (DetailInfo[5].equals("양우내안애") == true) {
LogoType = 2;
} else if (DetailInfo[5].equals("GSITM") == true) {
LogoType = 3;
} else if (DetailInfo[5].equals("제로에너지하우스") == true) {
LogoType = 4;
} else if (DetailInfo[5].equals("거실조명표시") == true) {
LogoType = 5;
} else if (DetailInfo[5].equals("거실조명삭제") == true) {
LogoType = 6;
} else if (DetailInfo[5].equals("기타1") == true) {
LogoType = 7;
} else if (DetailInfo[5].equals("기타2") == true) {
LogoType = 8;
}
if ((LogoType >= 0) && (LogoType <= 8)) {
AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("로고설정", LogoType, "null");
AfterTransactionTodoList.offer(afterTransactionTodoListData);
}
} else if (devname.equals("엘리베이터위젯복구")) {
String devInfo = devval;
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] DetailInfo = devInfo.split("_");
if (DetailInfo[3].equals("사용함") == true) {
AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("엘리베이터위젯복구", 0, "null");
AfterTransactionTodoList.offer(afterTransactionTodoListData);
}
} else if (devname.equals("분전반알람설정")) {
try {
String devInfo = devval;
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
SdbAPI sdbAPI = mWallPadAPI.Get_SdbController();
//[0] - 기기번호
//[1] - 회로수
//[2] - 기기이름
//[3] - 사용유무 (사용함 or 사용안함)------------> 사용할 정보
//[4] - 명칭
//[5] - 명칭에 대한 정보 ----------------------> 사용할 정보, ','로 구분됨
String[] DetailInfo = devInfo.split("_");
for (int a = 0; a < DetailInfo.length; a++) {
if (DetailInfo[a].equals("누적전력초기화")) {
// 분전반 알람 설정 안에 '초기화'가 있는 경우
if ((a + 1) <= DetailInfo.length) {
// 설정정보가 존재해야 인식하도록 함
if (DetailInfo[a + 1].equals("1")) {
// 1(사용함) 일때
if (sdbAPI != null) {
if (sdbAPI.Set_AccPwReset() >= 0) {
Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Success !!!");
} else {
Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset FAIL !!!");
}
}
AfterTransactionTodoListData afterTransactionTodoListData = new AfterTransactionTodoListData("분전반알람설정_누적전력초기화", 0, "null");
AfterTransactionTodoList.offer(afterTransactionTodoListData);
}
devval = devval.replace("누적전력초기화(1)", "누적전력초기화(0)");
SettManager.UpdateSettingData(define.iMAP_NODENAME_SUBDEV, devname, 0, devval);
Log.d(TAG, "[ProcSetsetup] Sdb ACC PW Reset Data Init : 0 !!!");
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[ProcSetsetup] SDB ALARM ERROR !!!");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
} else if (devname.equals("욕실폰통화음량값")) {
Intent Iintent = new Intent();
Iintent.setAction(define.NOTIFY_ACNAME);
Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_BATHPHONE_VOLUME);
sendBroadcast(Iintent);
} else if (devname.equals("주방TV통화음량값")) {
Intent Iintent = new Intent();
Iintent.setAction(define.NOTIFY_ACNAME);
Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SET_KITCHENTV_VOLUME);
sendBroadcast(Iintent);
} else if (devname.equals("현관카메라")) {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
String devInfo = devval;
if (devInfo != null) {
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] DetailInfo = devInfo.split("_");
if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
if (DetailInfo[5].equalsIgnoreCase(Common.DOOR_CAMERA_TYPE_IOT_SMART)) {
Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
if (mIOInterface != null)
mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
} else {
Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_NORMAL_FRONT ===");
if (mIOInterface != null)
mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_NORMAL_FRONT);
}
}
}
}
} else if (devname.equals("거동수상자녹화")) {
String devInfo = devval;
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] DetailInfo = devInfo.split("_");
} else if (devname.equals("스마트현관카메라좌우반전")) {
String devInfo = devval;
if (devInfo != null) {
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
}
String[] DetailInfo = devInfo.split("_");
if (DetailInfo != null && devname.equalsIgnoreCase(DetailInfo[2])) {
if (DetailInfo[3].equalsIgnoreCase(define.DEVICE_ENABLE)) {
Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT ===");
mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT);
} else {
Log.d(TAG, "[ProcSetsetup] CameraSet === WALLPAD_CAM_AHD_FRONT_FLIP ===");
mIOInterface.setCameraConfigure(Common.WALLPAD_CAM_AHD_FRONT_FLIP);
}
}
} else {
Log.w(TAG, "[ProcSetsetup] Not available devname -> " + devname);
}
}
}
} else if (itemname.equals("datetime")) {
dateData = GetAttributeVal(item, "value");
} else {
String GetVal = GetAttributeVal(item, "value");
if (GetVal != null) {
if (!GetVal.equals("list")) {
if (itemname.equals("site_code")) {
String[] Existing_SiteCode_Array = SettManager.GetSettingData(itemname);
if (Existing_SiteCode_Array == null) {
ResetFlag = true;
} else {
String Existing_SiteCode = Existing_SiteCode_Array[1];
if (GetVal != null && GetVal.equals(Existing_SiteCode) == false) {
ResetFlag = true;
}
}
}
SettManager.UpdateSettingData(itemname, itemname, 0, GetVal);
} else {
String GetCNT = GetAttributeVal(item, "count");
if (Integer.parseInt(GetCNT) <= 0) continue;
Element SettingItem = (Element) item;
NodeList SettingList = SettingItem.getElementsByTagName("list");
for (int j = 0; j < SettingList.getLength(); j++) {
Node subdevListitem = SettingList.item(j);
String devname = GetAttributeVal(subdevListitem, "name");
String devval = GetAttributeVal(subdevListitem, "value");
SettManager.UpdateSettingData(itemname, devname, j, devval);
}
}
}
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
ResetFlag = false;
RetVal += "\"fail\" >\r\n \"" + itemname + "\"\r\n\r\n";
SettManager.EndTransaction(false);
SettManager.closeDB();
return RetVal;
} catch (Exception e) {
ResetFlag = false;
RetVal += "\"fail\" >\r\n \"" + itemname + "\"\r\n\r\n";
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
SettManager.EndTransaction(false);
SettManager.closeDB();
return RetVal;
}
SettManager.EndTransaction(true);
SettManager.closeDB();
//** 리셋은 set_setup_info 이상없음 확인 & 처리 후 실행 & S/W 원격 업데이트 중이 아닌경우
if ((ResetFlag == true) && (ResetCount == 0) && (!WallPadiMAPUpgrade.active)) {
Log.i(TAG, "[ProcSetsetup] ========== The device is going to be reboot by updating setting info.!!! ==========");
mResetHandler.sendEmptyMessageDelayed(0, 1000);
}
if (AfterTransactionTodoList != null) {
if (AfterTransactionTodoList.size() > 0) {
for (int i = 0; i < AfterTransactionTodoList.size(); i++) {
AfterTransactionTodoListData afterTransactionTodoListData = AfterTransactionTodoList.poll();
if (afterTransactionTodoListData != null) {
if (afterTransactionTodoListData.Title.equals("로고설정")) {
WallpadSalesSampleData mWallpadSalesSampleData;
mWallpadSalesSampleData = new WallpadSalesSampleData(getApplicationContext());
mWallpadSalesSampleData.updateSalesSampleData(WallpadSalesSampleData.SALES_SAMPLE_MODE_LOGO_SHOW_OPTION, afterTransactionTodoListData.Valueint);
mWallpadSalesSampleData.closeDB();
} else if (afterTransactionTodoListData.Title.equals("엘리베이터위젯복구")) {
//ifdb에 있는지
ShortcutManager shortcutManager = new ShortcutManager(getApplicationContext());
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int result = devSet.Get_Elevator_Info();
devSet.closeDB();
if (result != WallpadDeviceSet.ELEVATOR_NONE) {
// 엘리베이터가 사용함이면
if (shortcutManager.getSearchWidget(define.WIDGET_ELEVATOR) == false) {
boolean result_get_restoreUseOrNot;
WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
if (wdb != null) {
result_get_restoreUseOrNot = wdb.GetElevator_Widget_Restore();
if (result_get_restoreUseOrNot == false) {
wdb.SetElevator_Widget_Restore(true);
//위젯 DB 초기화
WallpadDeviceSet devSet2 = new WallpadDeviceSet(getApplicationContext());
devSet2.DropTable(wallpaddbmgr.WidgetTBL);
devSet2.CreateTable("create table " + wallpaddbmgr.WidgetTBL + " (seqnum INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER unique, widgetid INTEGER); ");
devSet2.initWidgetData();
devSet2.closeDB();
}
}
wdb.closeDB();
}
}
else if (afterTransactionTodoListData.Title.equals("방명칭편집_조명") || afterTransactionTodoListData.Title.equals("방명칭편집_콘센트") || afterTransactionTodoListData.Title.equals("방명칭편집_난방")
|| afterTransactionTodoListData.Title.equals("방명칭편집_시스템에어컨") || afterTransactionTodoListData.Title.equals("방명칭편집_청정환기") || afterTransactionTodoListData.Title.equals("방명칭편집_차광")) {
String deviceType = afterTransactionTodoListData.ValueString;
Log.d(TAG, "[ProcSetsetup] deviceType [" + deviceType + "]");
WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
if (wdb != null) {
if (deviceType.equals(define.ROOM_NAME_LIGHT)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change LIGHT roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_light != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_light = " + roomNameList_light.toString()); // debugging
String[] roomNameArr = roomNameList_light.toArray(new String[roomNameList_light.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_light != null) roomNameList_light = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
else if (deviceType.equals(define.ROOM_NAME_CONCENT)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change CONCENT roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_concent != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_concent = " + roomNameList_concent.toString()); // debugging
String[] roomNameArr = roomNameList_concent.toArray(new String[roomNameList_concent.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_concent != null) roomNameList_concent = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
else if (deviceType.equals(define.ROOM_NAME_HEATING)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change HEATING roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_heating != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_heating = " + roomNameList_heating.toString()); // debugging
String[] roomNameArr = roomNameList_heating.toArray(new String[roomNameList_heating.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_heating != null) roomNameList_heating = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
else if (deviceType.equals(define.ROOM_NAME_SYSTEMAIRCON)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change SYSTEM AIRCON roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_systemaircon != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_systemaircon = " + roomNameList_systemaircon.toString()); // debugging
String[] roomNameArr = roomNameList_systemaircon.toArray(new String[roomNameList_systemaircon.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_systemaircon != null) roomNameList_systemaircon = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
else if (deviceType.equals(define.ROOM_NAME_PURITY)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change PURITY roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_purity != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_purity = " + roomNameList_purity.toString()); // debugging
String[] roomNameArr = roomNameList_purity.toArray(new String[roomNameList_purity.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_purity != null) roomNameList_purity = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
else if (deviceType.equals(define.ROOM_NAME_SHADING)) {
if (!wdb.GetRoomNameChangeByUser(deviceType)) {
Log.w(TAG, "[ProcSetsetup] Change SHADING roomname by Manager!!! deviceType [" + deviceType + "]");
if (roomNameList_shading != null) {
Log.d(TAG, "[ProcSetsetup] roomNameList_shading = " + roomNameList_shading.toString()); // debugging
String[] roomNameArr = roomNameList_shading.toArray(new String[roomNameList_shading.size()]);
wdb.SetDevRoomNameList(roomNameArr, deviceType);
wdb.SetRoomNameChangeByManager(1, deviceType);
if (roomNameList_shading != null) roomNameList_shading = null;
}
}
else {
Log.w(TAG, "[ProcSetsetup] Do not change roomname cause change by User!!! deviceType [" + deviceType + "]");
}
}
}
wdb.closeDB();
}
}
}
}
}
}
if (dateData != null) {
try {
int year = Integer.parseInt(dateData.substring(0, 4));
int month = Integer.parseInt(dateData.substring(4, 6));
int day = Integer.parseInt(dateData.substring(6, 8));
int hour = Integer.parseInt(dateData.substring(8, 10));
int min = Integer.parseInt(dateData.substring(10, 12));
int sec = Integer.parseInt(dateData.substring(12, 14));
Calendar nowdate = new GregorianCalendar();
long settedtime = nowdate.getTimeInMillis();
nowdate.set(Calendar.YEAR, year);
nowdate.set(Calendar.MONTH, month);
nowdate.set(Calendar.DAY_OF_MONTH, day);
nowdate.set(Calendar.HOUR_OF_DAY, hour);
nowdate.set(Calendar.MINUTE, min);
nowdate.set(Calendar.SECOND, sec);
long bootupmil = nowdate.getTimeInMillis();
if (Math.abs(bootupmil - settedtime) > 5000) {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
DBMGR.setSystemTime(year, month, day, hour, min, sec);
DBMGR.closeDB();
Intent Iintent = new Intent();
Iintent.setAction(define.NOTIFY_ACNAME);
Iintent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SYSTEMTIMESETTED);
sendBroadcast(Iintent);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
if (heartbeatP != null) {
try {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
DBMGR.SetHeartbeatPeriod(Integer.parseInt(heartbeatP));
DBMGR.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
RetVal += "\"fail\" >\r\n \"beat_time\"\r\n\r\n";
SettManager.closeDB();
return RetVal;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
RetVal += "\"fail\" >\r\n \"beat_time\"\r\n\r\n";
SettManager.closeDB();
return RetVal;
}
}
if (Versions != null) {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
Log.d(TAG, "-----------Version Save ---------->" + Versions);
DBMGR.SetSettingVer(Versions);
DBMGR.closeDB();
}
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
getApplicationContext().sendBroadcast(intent);
RetVal += "\"ok\" >\r\n \r\n";
return RetVal;
}
public String ProcNotifyparcel(Document doc) {
String moveInfo = "null";
String boxNo = "null";
String serviceInfo = "null";
String receiverInfo = "null";
String message = "null";
int remainCnt = 0;
try {
NodeList param = doc.getElementsByTagName("move_info");
Node item = param.item(0);
moveInfo = trimquotation(item.getTextContent());
param = doc.getElementsByTagName("params");
item = param.item(0);
if (item != null) {
boxNo = GetAttributeVal(item, "box_num");
serviceInfo = GetAttributeVal(item, "service_info");
receiverInfo = GetAttributeVal(item, "receiver_info");
message = GetAttributeVal(item, "message");
if (message != null) {
String[] msgList = message.split(define.DEVCTR_DATA_SPLITER);
if (msgList[0].equalsIgnoreCase("remains")) {
remainCnt = Integer.parseInt(msgList[1]);
if (remainCnt > 0) {
wakeupLCD();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
intent.putExtra(define.NOTIBR_CONTENT, moveInfo);
intent.putExtra("BOX_NO", boxNo);
intent.putExtra("SERVICE_INFO", serviceInfo);
intent.putExtra("RECEIVER_INFO", receiverInfo);
intent.putExtra("REMAIN_CNT", remainCnt);
getApplicationContext().sendBroadcast(intent);
}
}
}
}
String retVal = XMLHeader +
"\r\n" +
"\r\n";
return retVal;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
String retVal = XMLHeader +
"\r\n" +
"\r\n";
return retVal;
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
String retVal = XMLHeader +
"\r\n" +
"\r\n";
return retVal;
}
}
public String ProcNotiPostInfo(Document doc) {
NodeList param = doc.getElementsByTagName("move_info");
Node item = param.item(0);
String aa = item.getTextContent();
aa = trimquotation(aa);
if (item != null) {
String info = item.getTextContent();
if (info != null) {
Log.d(TAG, "[ProcNotiPostInfo] info [" + info + "]");
if (info.contains("post_in")) { // 우편물 보관
wakeupLCD();
int itemCount = -1;
param = doc.getElementsByTagName("params");
item = param.item(0);
if (item != null) {
String devname = GetAttributeVal(item, "message");
if (devname != null) {
if (!devname.equals("null")) { // 우편물 수량을 파악할 수 있는 경우
String[] msgList = devname.split(define.DEVCTR_DATA_SPLITER);
if (msgList[0].equalsIgnoreCase("remains")) {
itemCount = Integer.parseInt(msgList[1]);
}
}
}
}
if (itemCount > 0) {
Log.d(TAG, "[ProcNotiPostInfo] ===== Send NOTIFY_UPDATEPOST BR =====");
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPOST);
intent.putExtra(define.NOTIBR_CONTENT, aa);
intent.putExtra("ITEM", itemCount);
getApplicationContext().sendBroadcast(intent);
}
}
}
}
String retVal = XMLHeader +
"\r\n" +
"\r\n";
return retVal;
}
/* 15.04.02 강현수 주석처리(기존 ANC 작업분)
public String ProcNotifypark(Document doc)
{
String MoveInfo = "none";
NodeList param = doc.getElementsByTagName("destination");
Node item = param.item(0);
if (item != null)
{
String dong = GetAttributeVal(item, "id_high").trim();
String ho = GetAttributeVal(item, "id_low").trim();
if (!AddrDong.equals(dong) || (!AddrHo.equals(ho)))
return (XMLHeader +
"\r\n"+
"\r\n");
}
param = doc.getElementsByTagName("move_info");
item = param.item(0);
if (item != null) MoveInfo = trimquotation(item.getNodeValue());
param = doc.getElementsByTagName("params");
item = param.item(0);
if (item != null)
{
String carnum = GetAttributeVal(item, "car_num");
String locinfo = GetAttributeVal(item, "loc_info");
String msg = GetAttributeVal(item, "message");
WallpadParkInfo parkdb = new WallpadParkInfo(getApplicationContext());
parkdb.updateParkInfo(carnum, locinfo, MoveInfo ,msg);
parkdb.closeDB();Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARKING);
getApplicationContext().sendBroadcast(intent);
}
String retVal = XMLHeader +
"\r\n"+
"\r\n";
return retVal;
}
*/
public String ProcGetsetup(Document doc) {
WallpadDeviceSet SettManager = new WallpadDeviceSet(getApplicationContext());
NodeList items = doc.getElementsByTagName("variable");
String RetVal = XMLHeader + "\r\n" +
" \r\n";
Node item;
try {
for (int i = 0; i < items.getLength(); i++) {
item = items.item(i);
//String mRealTimeMeterData = item.getNodeValue();
String data = trimquotation(item.getTextContent());
List gData = SettManager.GetSettingGroupData(data);
if (gData.size() == 1) {
RetVal += " \r\n";
} else if (gData.size() > 1) {
RetVal += " \r\n";
RetVal += "
\r\n";
for (int k = 0; k < gData.size(); k++) {
// String replace "&" -> "_" : 스마트스위치&일괄소등 -> 스마트스위치_일괄소등
if (gData.get(k)[0].equals("스마트스위치&일괄소등")) {
//String temp = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
gData.get(k)[0] = gData.get(k)[0].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
gData.get(k)[1] = gData.get(k)[1].replaceAll("스마트스위치&일괄소등", "스마트스위치_일괄소등");
}
RetVal += "
\r\n";
}
if (bAirQualityEnable) {
RetVal += "
\r\n";
}
RetVal += " \r\n";
} else {
if (data.equals("beat_time")) {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
int heartbeatP = DBMGR.GetHeartbeatPeriod();
DBMGR.closeDB();
RetVal += " \r\n";
} else if (data.equals("ver_setting")) {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
RetVal += " \r\n";
DBMGR.closeDB();
} else if (data.equals("datetime")) {
Calendar cal = new GregorianCalendar();
RetVal += " \r\n";
} else if (data.equals("security_state")) {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
int alarmST = DBMGR.GetAlarmStatus();
String SEC_ST;
if (alarmST == WallpadStatusData.GUARD_OUT) SEC_ST = "out";
else if (alarmST == WallpadStatusData.GUARD_IN) SEC_ST = "in";
else SEC_ST = "normal";
RetVal += " \r\n";
DBMGR.closeDB();
} else if (data.equals("sensor_state")) {
int senIDX = 0;
String resultStr = "";
WallpadDeviceSet DBMGR = new WallpadDeviceSet(getApplicationContext());
int BugSensor = DBMGR.Get_Sensor_Set();
WallPadInterface wpifc = new WallPadInterface();
if (BugSensor > 0) {
if ((BugSensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0) {
int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
String Senret;
if (outSen > 0) Senret = "detect";
else Senret = "undetect";
resultStr += "
\r\n";
senIDX++;
} else {
if ((BugSensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
String Senret;
if (outSen > 0) Senret = "detect";
else Senret = "undetect";
resultStr += "
\r\n";
senIDX++;
}
if ((BugSensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
String Senret;
if (outSen > 0) Senret = "detect";
else Senret = "undetect";
resultStr += "
\r\n";
senIDX++;
}
}
int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
String Senret;
if (outSen > 0) Senret = "detect";
else Senret = "undetect";
resultStr += "
\r\n";
senIDX++;
int StatusVal = DBMGR.GetDeviceSetted("알람발생");
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
if (outSen > 0) Senret = "detect";
else Senret = "undetect";
resultStr += "
\r\n";
senIDX++;
}
DBMGR.closeDB();
}
if (senIDX > 0) {
RetVal += " \r\n";
RetVal += resultStr;
RetVal += " \r\n";
}
} else if (data.equals("statusbeat_time")) {
} else {
RetVal += " \r\n";
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcGetsetup(Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
SettManager.closeDB();
RetVal += " \r\n \r\n";
return RetVal;
}
public void ProcElevatorinfo(Element ele) {
try {
String floor;
String move_dir;
/*
NodeList evinfo = ele.getElementsByTagName("ev_count");
imapsvrlog("HIGH", "ProcElevatorinfo->ev_count "+evinfo);
Node info = evinfo.item(0);
imapsvrlog("HIGH", "ProcElevatorinfo->ev_count cnt 1 "+info.getNodeValue());
if (info != null)
{
elecount = Integer.parseInt(trimquotation(info.getNodeValue()));
}
*/
NodeList ievinfo = ele.getElementsByTagName("ev_info");
Log.d(TAG, "***************** : ievinfo.getLength() : " + ievinfo.getLength());
Node iinfo = ievinfo.item(0);
if (iinfo == null) {
Log.d("iMapServer", "func ProcElevatorinfo info == null");
return;
}
floor = GetAttributeVal(iinfo, "ev_floor"); // 0 이면 하향 호출 상태, 1이면 상향 호출 상태 , 2이면 상하향 둘다 호출상태
// byte updown = (GetAttributeVal(iinfo, "ev_call_dir").equalsIgnoreCase("down")?(byte)0:(byte)1);
move_dir = GetAttributeVal(iinfo, "ev_move_dir"); //up이면 상향, down이면 하향, stop이면 정지, wrong이면 이상발생, finish이면 전송중지
int MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
if (move_dir != null) {
if (move_dir.equalsIgnoreCase("up")) {
MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_UP;
} else if (move_dir.equalsIgnoreCase("down")) {
MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_DOWN;
} else if (move_dir.equalsIgnoreCase("stop")) {
MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_STOP;
} else if (move_dir.equalsIgnoreCase("wrong")) {
MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
} else if (move_dir.equalsIgnoreCase("finish")) {
MoveDirForIntent = define.NOTIFY_DEVICE_ELE_MOVE_DIR_ERROR;
}
Log.d("iMapServer", "MoveDirForIntent: " + MoveDirForIntent);
}
byte updown = 0x00;
if (ievinfo != null) {
boolean downCall = false;
boolean upCall = false;
for (int i = 0; i < ievinfo.getLength(); i++) {
Node valItem = ievinfo.item(i);
if (valItem != null) {
if (downCall == false) {
String val = GetAttributeVal(valItem, "ev_call_dir");
if (val != null)
downCall = val.equalsIgnoreCase("down");
}
if (upCall == false) {
String val = GetAttributeVal(valItem, "ev_call_dir");
if (val != null) {
upCall = val.equalsIgnoreCase("up");
}
}
}
}
Log.d("iMapServer", "func ProcElevatorinfo downCall : " + downCall + " , upCall : " + upCall);
if (downCall == true && upCall == true) updown = 0x02;
else if (downCall == false && upCall == true) updown = 0x01;
}
Log.d(TAG, "[ProcElevatorinfo] func ProcElevatorinfo elevator move info intent updown : " + updown);
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_MOVE);
intent.putExtra(define.NOTIBR_FLOOR, floor);
intent.putExtra(define.NOTIBR_UPDOWN, updown);
intent.putExtra(define.NOTIBR_MOVEDIR, MoveDirForIntent);
getApplicationContext().sendBroadcast(intent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcElevatorinfo(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private String MakeTargetStr(WallpadiCMDParser data) {
return " \r\n";
}
public String iCMDProcVentilControl(Document doc) {
try {
String unit_status = "null", mode = "null", unit_mode = "null";
String retStr = CheckiCMDProc("remote_access_ventil");
if (retStr != null) return retStr;
else retStr = XMLHeader + " = 0) procSucc = true;
else procSucc = false;
} else {
// 환기가 Off인 경우
if (VentilCTR.SetOnOff(true) >= 0) {
if (VentilCTR.SetWind(strength) >= 0) procSucc = true;
else procSucc = false;
} else {
procSucc = false;
}
}
}
if (VentilCTR.Refresh(true) == 0) {
if (VentilCTR.data.OnOff == false) unit_status = "off";
else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
else unit_status = "unknown";
if (VentilCTR.data.Support.AutoDriving) {
mode = "normal/auto";
if (VentilCTR.data.AutoDriving) unit_mode = "auto";
else unit_mode = "normal";
} else {
mode = "normal";
unit_mode = "normal";
}
} else {
procSucc = false;
}
} else {
procSucc = false;
}
} else if (trimquotation(ventilParser.actionTXT).equalsIgnoreCase("status")) {
if (VentilCTR != null && VentilCTR.Refresh(false) == 0) {
if (VentilCTR.data.OnOff == false) unit_status = "off";
else if (VentilCTR.data.Wind == VentiAPI.WIND.HI) unit_status = "high";
else if (VentilCTR.data.Wind == VentiAPI.WIND.MID) unit_status = "mid";
else if (VentilCTR.data.Wind == VentiAPI.WIND.LOW) unit_status = "low";
else unit_status = "unknown";
if (VentilCTR.data.Support.AutoDriving) {
mode = "normal/auto";
if (VentilCTR.data.AutoDriving) unit_mode = "auto";
else unit_mode = "normal";
} else {
mode = "normal";
unit_mode = "normal";
}
} else {
procSucc = false;
}
} else {
procSucc = false;
}
if (procSucc == false) {
retStr += (" result=\"fail\" >\r\n");
unit_status = "unknown";
} else {
retStr += (" result=\"ok\" >\r\n");
}
retStr += " \r\n";
retStr += " \"" + trimquotation(ventilParser.actionTXT) + "\"\r\n";
retStr += " \r\n";
// retStr += " \r\n \r\n\r\n";
retStr += " \r\n \r\n\r\n";
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcVentilControl(Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcTemperControl(Document doc) {
try {
String target = "null", tid = "null", msgno = "null";
String retStr = CheckiCMDProc("remote_access_temper");
if (retStr != null) return retStr;
else
retStr = XMLHeader + " \r\n \r\n \r\n ";
return retStr;
}
} else {
CtrList = tempercmd.ctraction.split("/");
if (CtrList[0].equals("on")) ctrl = 1;
else ctrl = 0;
roomNum = (byte) 0xFF;
temp = Double.parseDouble(CtrList[1]);
}
if (HeatingKind == 1) {
boolean OnOff = false;
if (ctrl == 1) OnOff = true;
if (tempercmd.unitnum.equals("all") && heatingV1API != null) {
int ret = heatingV1API.SetAllRoomStatus(OnOff);
if (ret != APIErrorCode.C_SUCCESS) {
retStr += "\"fail\">\r\n \r\n \r\n ";
return retStr;
}
heatingV1API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
} else {
for (byte i = 0; i < knxRoomNameList.length; i++) {
if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
roomNum = i;
break;
}
}
if (roomNum == (byte) 0xFF) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
if (heatingV1API != null) {
int ret = heatingV1API.SetEachRoomStatus(roomNum, (OnOff) ? (byte) 1 : (byte) 2, temp);
if (ret != APIErrorCode.C_SUCCESS) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
heatingV1API.Refresh(roomNum, false);
}
}
}
else if (HeatingKind == 2) {
byte Mode = HeatingV2.MODE.HeatingOFF;
if (ctrl == 1) Mode = HeatingV2.MODE.HeatingON;
if (tempercmd.unitnum.equals("all")) {
if (heatingV2API != null) {
int ret_pre = heatingV2API.SetAllRoomStatus(HeatingV2.MODE.PauseRelease);
int ret = heatingV2API.SetAllRoomStatus(Mode);
if (ret_pre != APIErrorCode.C_SUCCESS && ret != APIErrorCode.C_SUCCESS) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
heatingV2API.Refresh(define.DEVICE_ALL_OR_NOTHING, false);
}
} else {
int nDevNum = Integer.parseInt(tempercmd.devnum)-1;
if (heatingV2API != null) {
int ret = heatingV2API.SetEachRoomStatus((byte) nDevNum, Mode, temp);
if (ret != APIErrorCode.C_SUCCESS) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
heatingV2API.Refresh((byte) nDevNum, false);
}
}
}
else {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
}
String resultStr = " \r\n";
if (HeatingKind == 1) {
try {
if (heatingV1API == null) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
byte RoomCount = heatingV1API.data.Device.RoomCount;
resultStr += " \"" + tempercmd.actionTXT + "\"\r\n";
resultStr += " \r\n";
if ((tempercmd.unitnum.equals("all")) || (tempercmd.unitnum.equals("null"))) {
String drvmode = "off";
for (byte i = 0; i < RoomCount; i++) {
HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[i];
if (roomData.bOnOff) drvmode = "on";
else drvmode = "off";
drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
resultStr += " \r\n";
}
resultStr += " \r\n\r\n";
retStr += ("\"ok\">\r\n" + resultStr);
return retStr;
} else {
String drvmode = "off";
byte roomNum = (byte) 0xFF;
for (byte i = 0; i < knxRoomNameList.length; i++) {
if (tempercmd.unitnum.equals(knxRoomNameList[i])) {
roomNum = i;
break;
}
}
if (roomNum == (byte) 0xFF) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
HeatingV1.RoomData roomData = heatingV1API.data.Device.Room[roomNum];
if (roomData.bOnOff) drvmode = "on";
else drvmode = "off";
drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
resultStr += " \r\n";
resultStr += " \r\n\r\n";
retStr += ("\"ok\">\r\n" + resultStr);
return retStr;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
}
else if (HeatingKind == 2) {
try {
if (heatingV2API == null) {
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
byte RoomCount = heatingV2API.data.Device.info.RoomCount;
resultStr += " \"" + tempercmd.actionTXT + "\"\r\n";
//resultStr += " \r\n";
if ((tempercmd.devnum.equals("all"))) {
Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& all :" + RoomCount);
String drvmode = "off";
for (byte i = 0; i < RoomCount; i++) {
HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[i];
if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
else drvmode = "off";
drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
resultStr += " \r\n";
if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
resultStr += " \r\n";
} else {
resultStr += " \r\n";
}
}
resultStr += " \r\n\r\n";
retStr += ("\"ok\">\r\n" + resultStr);
return retStr;
}
else {
String drvmode = "off";
int nDevNum = Integer.parseInt(tempercmd.devnum);
HeatingV2.RoomData roomData = heatingV2API.data.Device.Room[nDevNum-1];
if (HeatingV2.MODE.GetOnOff(roomData.Mode)) drvmode = "on";
else drvmode = "off";
drvmode += "/" + roomData.SetTemp + "/" + roomData.NowTemp;
resultStr += " \r\n";
resultStr += " \r\n";
resultStr += " \r\n\r\n";
retStr += ("\"ok\">\r\n" + resultStr);
return retStr;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
} else {
Log.d(TAG, "&&&&&&&&&&&&&&&&&&&&& :^^^^^^^^^^^^^");
retStr += "\"fail\">\r\n \r\n \r\n";
return retStr;
}
// retStr+="\"fail\">\r\n \r\n \r\n";
// return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcTemperControl(Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcDoorlockControl(Document doc) {
try {
String DLStatus = "none";
String strResult = CheckiCMDProc("remote_access_doorlock");
if (strResult != null) return strResult;
else
strResult = XMLHeader + " \r\n" +
" \r\n" +
" \"status\"\r\n" +
" \r\n" +
" \r\n \r\n";
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcDoorlockControl(Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
/*
protected String iCMDProcsavelog(Document doc)
{
String SucretStr = XMLHeader+"\r\n";
String FailretStr = XMLHeader+"\r\n";
NodeList items = doc.getElementsByTagName("guidemap");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for(int j=0; j< attrsParam.getLength();j++)
{
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("enable"))
{
String enable = attr.getNodeValue();
if (enable == null) return FailretStr;
if (enable.equals("false"))
{
WallpadLogData logSet = new WallpadLogData(getApplicationContext());
logSet.SetLogDoing(0);
logSet.closeDB();
return SucretStr;
}
WallpadLogData logSet = new WallpadLogData(getApplicationContext());
logSet.SetLogDoing(1);
logSet.closeDB();
}
}
items = doc.getElementsByTagName("setting");
item = items.item(0);
attrsParam = item.getAttributes();
String SaveType = "";
String FtpLoc = "";
String Ftpuser = "";
String FtpPW= "";
String period = "";
String FileSize = "";
for(int j=0; j< attrsParam.getLength();j++)
{
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("save_type"))
SaveType = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("ftp_info"))
FtpLoc = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("user"))
Ftpuser = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("passwd"))
FtpPW = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("period"))
period = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("filesize"))
FileSize = attr.getNodeValue();
}
if (SaveType.equalsIgnoreCase("now"))
{
LogUploader LogUpThread = new LogUploader(FtpLoc, Ftpuser, FtpPW);
LogUpThread.start();
return SucretStr;
}
else if (SaveType.equalsIgnoreCase("periodic"))
{
try
{
WallpadLogData logSet = new WallpadLogData(getApplicationContext());
period = period.trim();
String[] logperiod = period.split("[-]");
String StartDate = logperiod[0].replace(".", "_");
String EndDate = logperiod[1].replace(".", "_");
logSet.SetLogDoing(1);
logSet.logFTPSet(FtpLoc, Ftpuser, FtpPW);
if (FileSize.equalsIgnoreCase("null"))
logSet.SetLogLogFileSize(0);
else
logSet.SetLogLogFileSize(Integer.parseInt(FileSize));
logSet.SetLogStartDate(StartDate);
logSet.SetLogEndDate(EndDate);
logSet.closeDB();
return SucretStr;
}
catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
}
catch (Exception e)
{
e.printStackTrace();
return FailretStr;
}
}
else
{
return FailretStr;
}
}
*/
protected void SendLogSaved(String ftploc, String fname, String size) {
String SendMsg = XMLHeader + "\r\n" +
" \r\n" +
" \r\n\r\n";
SendToServer(SendMsg);
}
public final static int FTPLOGTRSUCC = 1110;
public final static int FTPLOGTRFAIL = 1120;
Handler FileTrHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case FTPLOGTRSUCC:
String[] getMSG = ((String) (msg.obj)).split(define.DEVCTR_CMD_SPLITER);
File fileinfo = new File(define.LOG_FILE_LOCATION + "/" + getMSG[1]);
int size = (int) (fileinfo.length() / 1024);
SendLogSaved(getMSG[0], getMSG[1], String.valueOf(size));
imapsvrlog("FTPLOGTRSUCC");
break;
case FTPLOGTRFAIL:
imapsvrlog("FTPLOGTRFAIL");
break;
}
}
};
class LogUploader extends Thread {
int fileidx = 0;
boolean TRing = false;
String FtpLoc;
String FtpID;
String FtpPasswd;
class ftpuploader extends WallPadFTPUploader {
String filename;
public ftpuploader(Context ctx, String ftpPath, String User, String Passwd, String LocalFile) {
super(ctx, ftpPath, User, Passwd, define.LOG_FILE_LOCATION + "/" + LocalFile);
filename = LocalFile;
}
protected void ProcUploadFail() {
Message TrResult = FileTrHandler.obtainMessage();
TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
TrResult.what = FTPLOGTRFAIL;
TRing = false;
imapsvrlog("Send Log Fail Message");
FileTrHandler.sendMessage(TrResult);
}
protected void ProcUploadSuccess() {
Message TrResult = FileTrHandler.obtainMessage();
TrResult.obj = ftpPATH + define.DEVCTR_CMD_SPLITER + filename + define.DEVCTR_CMD_SPLITER + id + define.DEVCTR_CMD_SPLITER + passwd;
TrResult.what = FTPLOGTRSUCC;
TRing = false;
imapsvrlog("Send Log success Message");
FileTrHandler.sendMessage(TrResult);
}
}
public LogUploader(String loc, String user, String pw) {
FtpLoc = loc;
FtpID = user;
FtpPasswd = pw;
}
public void run() {
File LogLoc = new File(define.LOG_FILE_LOCATION);
String[] LogFileList = LogLoc.list();
while (true) {
if (TRing == false) {
if (LogFileList != null && fileidx < LogFileList.length) {
ftpuploader uploader = new ftpuploader(getApplicationContext(), FtpLoc, FtpID, FtpPasswd, LogFileList[fileidx]);
fileidx++;
TRing = true;
uploader.start();
} else
return;
}
try {
Thread.sleep(500);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
}
}
public String iCMDProcDevList(Document ele) {
try {
String strResult = CheckiCMDProc("remote_get_home_devices");
if (strResult != null) return strResult;
else
strResult = XMLHeader + " \r\n";
strResult += " \r\n";
strResult += " \r\n";
//strResult += " \r\n";
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
String strLight = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("조명(") + 3) , (strDeviceSeqValue[1].indexOf(")난방(")));
String strHeating = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("난방(") + 3) , (strDeviceSeqValue[1].indexOf(")에어컨(")));
String strAircon = strDeviceSeqValue[1].substring( (strDeviceSeqValue[1].indexOf("에어컨(") + 4) , (strDeviceSeqValue[1].indexOf("))")));
strLight = (strLight.substring(strLight.indexOf(":")+1)).replaceAll("_","/");
strHeating = (strHeating.substring(strHeating.indexOf(":")+1)).replaceAll("_","/");
strAircon = (strAircon.substring(strAircon.indexOf(":")+1)).replaceAll("_","/");
for (int i = 0; i < devlist.length; i++) {
if (devlist[i].equals("cooktop")) {
if (mWallPadAPI.GetGasKind() == 1) {
// 가스밸브
int Gasinfo = devSet.Get_GAS_Info();
if (Gasinfo == 1) {
// 사용함
if (bGasAsCooktopOutlet) {
strResult += " \r\n";
strResult += " \r\n";
} else {
strResult += " \r\n";
strResult += " \r\n";
}
} else {
// 사용안함
strResult += " \r\n";
strResult += " \r\n";
}
} else if (mWallPadAPI.GetGasKind() == 2) {
// 하이브리드 쿡탑
// 쿡탑 최대로 연동 안됨
strResult += " \r\n";
strResult += " \r\n";
/*
if (mCooktopAPI != null) {
int ret = mCooktopAPI.Refresh((byte) 0xFF, false);
int nGas = 0;
int nOutlet = 0;
if (ret >= 0) {
for (int k = 0; k < mCooktopAPI.data.Device[0].circuit.length; k++) {
if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE)
nGas++;
else if (mCooktopAPI.data.Device[0].circuit[k].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET)
nOutlet++;
}
strResult += " \r\n";
strResult += " \r\n";
}
}
*/
} else {
strResult += " \r\n";
strResult += " \r\n";
}
}
else if (devlist[i].equals("doorlock")) {
try {
int[] DoorLockInfo = devSet.Get_DoorLock_Info();
if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("light")) {
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdbAPI != null) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
} else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
} else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
strResult += " \r\n";
} else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte) 0xFF, false);
if (ret < 0 || multisw.data.DeviceCnt < 1)
strResult += " \r\n";
else
strResult += " \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("livinglight")) {
try {
int[] lightinfo = devSet.Get_Light_info();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdb_LivingRoomLightAPI != null) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
} else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
strResult += " \r\n";
} else {
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("ventil")) {
try {
int[] Ventilinfo = devSet.Get_Ventil_Info();
if (Ventilinfo[0] == 0)
strResult += " \r\n";
else
strResult += " \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("thermostat")) {
try {
int Temperinfo = devSet.Get_Temper_Info();
int HeatingKind = mWallPadAPI.GetHeatingKind();
HeatingV1API heatingV1API = null;
HeatingV2API heatingV2API = null;
byte RoomCount = 0;
// 종류별 API를 로딩한다.
if (HeatingKind == 1) {
heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
if (heatingV1API != null) {
RoomCount = heatingV1API.data.Device.RoomCount;
}
} else if (HeatingKind == 2) {
heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
if (heatingV2API != null) {
RoomCount = heatingV2API.data.Device.info.RoomCount;
}
}
if (Temperinfo == 0)
strResult += " \r\n";
else
strResult += " \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("curtain")) {
try {
int[] Curtaininfo = devSet.Get_CURTAIN_Info();
if (Curtaininfo[0] == 0)
strResult += " \r\n";
else
strResult += " \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("electric")) {
try {
if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
// 청담 콘센트 처리
KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
int BadConcentCount = 0;
if (KnxApi != null) {
int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
if (KnxApi.data.LivingRoom_EnergyMeter.Info.ConcentCount > 0) {
BadConcentCount = 1;
}
int BadConCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
for (int k = 0; k < BadConCount; k++) {
if (KnxApi.data.BadRoom_EnergyMeter[k].Info.ConcentCount > 0)
BadConcentCount++;
}
Log.d(TAG, "[yskim] iCMDProcDevList() electric : " + BadConcentCount);
strResult += " \r\n";
}
} else {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
int nOutlet = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
} else {
nOutlet = 1;
}
} else {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count;
} else {
nOutlet = 0;
}
}
strResult += " \r\n";
} else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
} else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte) 0xFF, false);
if (ret < 0 || multisw.data.DeviceCnt < 1) {
strResult += " \r\n";
} else {
int DeviceCount = 0;
for (int j = 0; j < multisw.data.DeviceCnt; j++) {
if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
DeviceCount++;
}
}
strResult += " \r\n";
}
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("smartlight")) {
if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
// KNX 조명 처리
try {
KnxAPI KnxApi = mWallPadAPI.Get_KnxController();
if (KnxApi != null) {
int ret = KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING);
if (KnxApi.data == null)
Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data == null");
if (KnxApi.data.MasterController == null)
Log.d(TAG, "[yskim] iCMDProcDevList KnxApi.data.MasterController == null");
if (ret >= 0) {
int LivingLightCount = 0;
if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
} else {
if (KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
LivingLightCount = 1;
}
int AllEMcount = LivingLightCount + KnxApi.data.MasterController.Info.Bad_EnergyMeterCount + KnxApi.data.MasterController.Info.Light_SwitchCount; // + KnxApi.data.MasterController.Info.Liv_EnergyMeterCount;
strResult += " \r\n";
}
}
} catch (Exception ek) {
strResult += " \r\n";
}
} else {
if (!bLightCMDUseAsSmartLight) {
int nSmartLight = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
} else {
nSmartLight = 1;
}
} else {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
} else {
nSmartLight = 0;
}
}
strResult += " \r\n";
}
}
}
else if (devlist[i].equals("sysaircon")) {
// 에어컨 처리
if (nResultPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
KnxSystemAirconAPI airconAPI = mWallPadAPI.Get_KnxAirconController();
if (airconAPI != null) {
int nCount = airconAPI.data.Device.info.InsideAirconCount;
Log.d(TAG, "[yskim] iCMDProcDevList() sysaircon : " + nCount);
// 현대건설 에어컨 처리, 포트가 다르기 때문에 구분해서 처리 필요, 에어컨 API가 동일하다면 그럴 필요는 없음
strResult += " \r\n";
} else {
strResult += " \r\n";
}
} else {
strResult += " \r\n";
}
}
}
//방범, 센서 여부 응답(고급주택은 사용하지 않아 value 0으로 처리
strResult += " \r\n";
strResult += " \r\n";
if (remote_get_home_devices1 != null && !remote_get_home_devices1.equals("")) {
strResult += remote_get_home_devices1;
}
if (remote_get_home_devices2 != null && !remote_get_home_devices2.equals("")) {
strResult += remote_get_home_devices2;
}
if (remote_get_home_devices3 != null && !remote_get_home_devices3.equals("")) {
strResult += remote_get_home_devices3;
}
/*
for (int i = 0; i < devlist.length; i++) {
if (devlist[i].equals("cooktop")) {
if (mWallPadAPI.GetGasKind() == 1) {
// 가스밸브
int Gasinfo = devSet.Get_GAS_Info();
if (Gasinfo == 1) {
// 사용함
if (bGasAsCooktopOutlet) {
strResult +=" \r\n";
strResult +=" \r\n";
}
else {
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else {
// 사용안함
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else if (mWallPadAPI.GetGasKind() == 2) {
// 하이브리드 쿡탑
if (mCooktopAPI != null) {
int nGas = 0; int nOutlet = 0;
for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
}
}
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else {
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else if (devlist[i].equals("doorlock")) {
try {
int[] DoorLockInfo = devSet.Get_DoorLock_Info();
if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
strResult +=" \r\n";
}
else {
strResult +=" \r\n";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("light")) {
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdbAPI != null) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
}
else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
strResult += " \r\n";
}
else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte)0xFF, false);
if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" \r\n";
else strResult +=" \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("livinglight")) {
try {
int[] lightinfo = devSet.Get_Light_info();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdb_LivingRoomLightAPI != null) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
strResult += " \r\n";
}
else {
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
strResult += " \r\n";
}
else {
strResult += " \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("ventil")) {
try {
int[] Ventilinfo = devSet.Get_Ventil_Info();
if (Ventilinfo[0] == 0) strResult +=" \r\n";
else strResult +=" \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("thermostat")) {
try {
int Temperinfo = devSet.Get_Temper_Info();
int HeatingKind = mWallPadAPI.GetHeatingKind();
HeatingV1API heatingV1API = null;
HeatingV2API heatingV2API = null;
byte RoomCount = 0;
// 종류별 API를 로딩한다.
if (HeatingKind == 1) {
heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
if (heatingV1API != null) {
RoomCount = heatingV1API.data.Device.RoomCount;
}
}
else if (HeatingKind == 2) {
heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
if (heatingV2API != null) {
RoomCount = heatingV2API.data.Device.info.RoomCount;
}
}
if (Temperinfo == 0) strResult += " \r\n";
else strResult +=" \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("curtain")) {
try {
int[] Curtaininfo = devSet.Get_CURTAIN_Info();
if (Curtaininfo[0] == 0) strResult += " \r\n";
else strResult += " \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("electric")) {
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
int nOutlet = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
}
else {
nOutlet = 1;
}
}
else {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count;
}
else {
nOutlet = 0;
}
}
strResult += " \r\n";
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult += " \r\n";
}
else {
strResult += " \r\n";
}
}
else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
}
else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte)0xFF, false);
if (ret< 0 || multisw.data.DeviceCnt < 1) {
strResult += " \r\n";
}
else {
int DeviceCount = 0;
for (int j = 0; j < multisw.data.DeviceCnt; j++) {
if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
DeviceCount++;
}
}
strResult += " \r\n";
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("smartlight")) {
if (!bLightCMDUseAsSmartLight) {
int nSmartLight = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
}
else {
nSmartLight = 1;
}
}
else {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
}
else {
nSmartLight = 0;
}
}
strResult += " \r\n";
}
}
}
for (int i = 0; i < devlist.length; i++) {
if (devlist[i].equals("cooktop")) {
if (mWallPadAPI.GetGasKind() == 1) {
// 가스밸브
int Gasinfo = devSet.Get_GAS_Info();
if (Gasinfo == 1) {
// 사용함
if (bGasAsCooktopOutlet) {
strResult +=" \r\n";
strResult +=" \r\n";
}
else {
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else {
// 사용안함
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else if (mWallPadAPI.GetGasKind() == 2) {
// 하이브리드 쿡탑
if (mCooktopAPI != null) {
int nGas = 0; int nOutlet = 0;
for (int j = 0; j < mCooktopAPI.data.DeviceCnt; j++) {
for (int k = 0; k < mCooktopAPI.data.DeviceCnt; k++) {
if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.GASVALVE) nGas++;
else if (mCooktopAPI.data.Device[j].circuit[i].hType == DataClasses.CooktopCtrl.DEVICE_TYPE.OUTLET) nOutlet++;
}
}
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else {
strResult +=" \r\n";
strResult +=" \r\n";
}
}
else if (devlist[i].equals("doorlock")) {
try {
int[] DoorLockInfo = devSet.Get_DoorLock_Info();
if ((DoorLockInfo[0] == 1) && (DoorLockInfo[1] == WallpadDeviceSet.DOORLOCK_TYPE_NORMAL)) {
strResult +=" \r\n";
}
else {
strResult +=" \r\n";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("light")) {
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdbAPI != null) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
}
else if ((lightinfo[0] == 1) && (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING)) {
strResult += " \r\n";
}
else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte)0xFF, false);
if (ret < 0 || multisw.data.DeviceCnt < 1) strResult +=" \r\n";
else strResult +=" \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("livinglight")) {
try {
int[] lightinfo = devSet.Get_Light_info();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (bLightCMDUseAsSmartLight) {
if (mSdb_LivingRoomLightAPI != null) {
strResult +=" \r\n";
}
else {
strResult += " \r\n";
}
}
else {
strResult += " \r\n";
Log.w(TAG, "[iCMDProcDevList] Not supported!!");
}
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
strResult += " \r\n";
}
else {
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_LIVING) {
strResult += " \r\n";
}
else {
strResult += " \r\n";
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("ventil")) {
try {
int[] Ventilinfo = devSet.Get_Ventil_Info();
if (Ventilinfo[0] == 0) strResult +=" \r\n";
else strResult +=" \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult +=" \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult +=" \r\n";
}
}
else if (devlist[i].equals("thermostat")) {
try {
int Temperinfo = devSet.Get_Temper_Info();
int HeatingKind = mWallPadAPI.GetHeatingKind();
HeatingV1API heatingV1API = null;
HeatingV2API heatingV2API = null;
byte RoomCount = 0;
// 종류별 API를 로딩한다.
if (HeatingKind == 1) {
heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
if (heatingV1API != null) {
RoomCount = heatingV1API.data.Device.RoomCount;
}
}
else if (HeatingKind == 2) {
heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
if (heatingV2API != null) {
RoomCount = heatingV2API.data.Device.info.RoomCount;
}
}
if (Temperinfo == 0) strResult += " \r\n";
else strResult +=" \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("curtain")) {
try {
int[] Curtaininfo = devSet.Get_CURTAIN_Info();
if (Curtaininfo[0] == 0) strResult += " \r\n";
else strResult += " \r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("electric")) {
try {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
int nOutlet = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count + 1;
}
else {
nOutlet = 1;
}
}
else {
if (mSdbAPI != null) {
nOutlet = mSdbAPI.data.BadRoom_Em_Count;
}
else {
nOutlet = 0;
}
}
strResult += " \r\n";
}
else if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
EnergyMeterAPI energymeter = mWallPadAPI.Get_EnergyMeterController();
if ((energymeter.Refresh((byte)0xFF, false) == 0) && (energymeter.data.RoomCnt > 0)) {
strResult += " \r\n";
}
else {
strResult += " \r\n";
}
}
else {
int[] lightinfo = devSet.Get_Light_info();
if (lightinfo[0] == 0 || lightinfo[1] != WallpadDeviceSet.LIGHT_TYPE_ROOM) {
strResult += " \r\n";
}
else {
MultiSwitchAPI multisw = mWallPadAPI.Get_MultiSwitchController();
int ret = multisw.Refresh((byte)0xFF, false);
if (ret< 0 || multisw.data.DeviceCnt < 1) {
strResult += " \r\n";
}
else {
int DeviceCount = 0;
for (int j = 0; j < multisw.data.DeviceCnt; j++) {
if (multisw.data.Device[j].info.Support.hOutletCnt > 0) {
DeviceCount++;
}
}
strResult += " \r\n";
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
strResult += " \r\n";
}
catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
strResult += " \r\n";
}
}
else if (devlist[i].equals("smartlight")) {
if (!bLightCMDUseAsSmartLight) {
int nSmartLight = 0;
if (mSdb_LivingRoomLightAPI != null) {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count + 1;
}
else {
nSmartLight = 1;
}
}
else {
if (mSdbAPI != null) {
nSmartLight = mSdbAPI.data.BadRoom_Em_Count;
}
else {
nSmartLight = 0;
}
}
strResult += " \r\n";
}
}
}
*/
strResult += " \r\n\r\n";
devSet.closeDB();
return strResult;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcDevList(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcMultiSWControl(Document ele) {
try {
String retStr = CheckiCMDProc(MULTISW_CTR);
if (retStr != null) return retStr;
else retStr = XMLHeader + " 0) result = "ok";
else result = "fail";
retStr += (" result=\"" + result + "\" >\r\n");
if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
retStr += MakeTargetStr(multiswcmd);
retStr += " \"status\"\r\n";
retStr += " \r\n";
if (multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || multiswcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
retStr += " \r\n";
} else {
retStr += " \r\n";
}
} else {
retStr += " \r\n";
}
String unitStr;
for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
Log.e(TAG, multisw.data.Device[devNum - 1].device.ToDebugString((byte) i));
//unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
//unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.On) ? "on" : "off";
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
}
} else if (trimquotation(multiswcmd.actionTXT).equalsIgnoreCase("control")) {
int devNum = Integer.parseInt(multiswcmd.devnum);
int swNum = Integer.parseInt(multiswcmd.unitnum.replaceAll("switch", ""));
{
if (multisw != null) {
multisw.Refresh((byte) 0xFF, false);
String result;
int ret = -1;
if (multiswcmd.ctraction.equalsIgnoreCase("set")) {
ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), true);
} else if (multiswcmd.ctraction.equalsIgnoreCase("unset")) {
ret = multisw.SetConcentMode((byte) (devNum - 1), (byte) (swNum - 1), false);
} else if (multiswcmd.ctraction.equalsIgnoreCase("on")) {
ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), true);
} else if (multiswcmd.ctraction.equalsIgnoreCase("off")) {
ret = multisw.SetConcentOnOff((byte) (devNum - 1), (byte) (swNum - 1), false);
}
if (ret == APIErrorCode.C_SUCCESS) result = "ok";
else result = "fail";
if (ret == APIErrorCode.C_SUCCESS) {
ret = multisw.Refresh((byte) 0xFF, false);
if (ret == APIErrorCode.C_SUCCESS && multisw.data.DeviceCnt > 0) {
retStr += (" result=\"" + result + "\" > \r\n");
retStr += MakeTargetStr(multiswcmd);
retStr += " \"control\"\r\n";
retStr += " \r\n";
String unitStr;
for (int i = 0; i < multisw.data.Device[devNum - 1].device.hOutletCnt; i++) {
//unitStr = ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x30) == 0x10)?"set/":"unset/";
//unitStr += ((multisw.mRealTimeMeterData.device[devNum-1].ConcentStatus[i]&0x05) > 2)?"off":"on";
unitStr = (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Mode == MultiSwitch.OUTLET_MODE.Auto) ? "set/" : "unset/";
unitStr += (multisw.data.Device[devNum - 1].device.getOutletStatus(i).Status == MultiSwitch.OUTLET_STATUS.Off) ? "off" : "on";
retStr += " \r\n";
}
} else {
retStr += (" result=\"fail\"> \r\n");
}
} else {
retStr += (" result=\"fail\"> \r\n");
}
retStr += " \r\n\r\n";
}
}
}
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcMultiSWControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcSDPConcentControl(Document ele) {
try {
WallpadiCMDParser concentcmd = new WallpadiCMDParser(ele);
String retStr = CheckiCMDProc("remote_access_electric");
if (retStr != null) return retStr;
else retStr = XMLHeader + " \r\n \r\n";
Log.w(TAG, "[iCMDProcSDPConcentControl] mSdbAPI is null!!!");
return retStr;
}
if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
int nTotalLightCnt = 0;
if (mSdbAPI.data.LivingRoom_EnergyMeter != null) {
nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
} else {
nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count;
}
Log.w(TAG, "[iCMDProcSDPConcentControl] LivingConcentCount [" + mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
int nDevNo = 0;
try {
nDevNo = Integer.parseInt(concentcmd.devnum);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[iCMDProcSDPConcentControl] concentcmd.devnum is not number!! = 1 =");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if (nDevNo < 1 && 12 < nDevNo) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPConcentControl] nDevNo is out of range!! -> " + nDevNo);
return retStr;
}
String strAction = trimquotation(concentcmd.actionTXT);
String unit_status = "null", status_mode = "unset", status_onoff = "off";
String dev_num = "null", unit_num = "null", ctrl_action = "null";
int nRet_Mode = -99, nRet_OnOff = -99;
boolean Set = false, OnOff = false; // 제어요청 상태
boolean bCtrl_Set = false, bCtrl_OnOff = false; // 제어여부
if (strAction.equalsIgnoreCase("status")) {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + strAction + "\"\r\n";
if (nDevNo == 1) {
if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
retStr += " \r\n";
} else {
retStr += " \r\n";
}
for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
status_mode = "unset";
else status_mode = "set";
if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
status_onoff = "on";
else status_onoff = "off";
unit_status = status_mode + "/" + status_onoff;
retStr += " \r\n";
}
// retStr += " \r\n";
retStr += " \r\n\r\n";
} else if (nDevNo > 1) {
if (concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || concentcmd.target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
retStr += " \r\n";
} else {
retStr += " \r\n";
}
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
status_mode = "unset";
else status_mode = "set";
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
status_onoff = "on";
else status_onoff = "off";
unit_status = status_mode + "/" + status_onoff;
retStr += " \r\n";
}
// retStr += " \r\n";
retStr += " \r\n\r\n";
}
} else if (strAction.equalsIgnoreCase("control")) {
NodeList items = ele.getElementsByTagName("params");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Node attr = attrs.item(i);
if (attr.getNodeName().equalsIgnoreCase("dev_num"))
dev_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
unit_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
ctrl_action = attr.getNodeValue();
}
} else {
Log.w(TAG, "[iCMDProcSDPConcentControl] msg error!!!");
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
try {
nDevNo = Integer.parseInt(dev_num);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[iCMDProcSDPConcentControl] dev_num is not number!! = 1 =");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if (nDevNo < 1 && 12 < nDevNo) {
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
int nUnitNo = 0;
if (!unit_num.equalsIgnoreCase("all")) {
try {
nUnitNo = Integer.parseInt(unit_num.replaceAll("switch", ""));
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[iCMDProcSDPConcentControl] unit_num is error!! = 2 =");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
}
if (ctrl_action.contains("/")) {
String[] strParsed = ctrl_action.split("/");
if (strParsed[0].equals("set")) {
Set = true;
bCtrl_Set = true;
} else if (strParsed[0].equals("unset")) {
Set = false;
bCtrl_Set = true;
}
if (strParsed[1].equals("on")) {
OnOff = true;
bCtrl_OnOff = true;
} else if (strParsed[1].equals("off")) {
OnOff = false;
bCtrl_OnOff = true;
}
} else {
if (ctrl_action.contains("set") || ctrl_action.contains("unset")) {
if (ctrl_action.equalsIgnoreCase("set")) {
Set = true;
bCtrl_Set = true;
} else if (ctrl_action.equalsIgnoreCase("unset")) {
Set = false;
bCtrl_Set = true;
}
}
if (ctrl_action.contains("on") || ctrl_action.contains("off")) {
if (ctrl_action.equalsIgnoreCase("on")) {
OnOff = true;
bCtrl_OnOff = true;
} else if (ctrl_action.equalsIgnoreCase("off")) {
OnOff = false;
bCtrl_OnOff = true;
}
}
}
Log.w(TAG, "[iCMDProcSDPConcentControl] bCtrl_Set [" + bCtrl_Set + "], bCtrl_OnOff [" + bCtrl_OnOff + "]");
if (nDevNo == 1) {
if (unit_num.equalsIgnoreCase("all")) {
for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
if (bCtrl_Set)
nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) i, Set);
if (bCtrl_OnOff)
nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) i, OnOff);
Log.w(TAG, "[iCMDProcSDPConcentControl] 1 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
}
} else {
if (bCtrl_Set)
nRet_Mode = mSdbAPI.SetConcentMode(EM_INDEX_LIVING, (byte) (nUnitNo - 1), Set);
if (bCtrl_OnOff)
nRet_OnOff = mSdbAPI.SetConcentOnOff(EM_INDEX_LIVING, (byte) (nUnitNo - 1), OnOff);
Log.w(TAG, "[iCMDProcSDPConcentControl] 2 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
}
} else {
if (unit_num.equalsIgnoreCase("all")) {
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
if (bCtrl_Set)
nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) i, Set);
if (bCtrl_OnOff)
nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) i, OnOff);
Log.w(TAG, "[iCMDProcSDPConcentControl] 3 nUnitNo [" + i + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
}
} else {
if (bCtrl_Set)
nRet_Mode = mSdbAPI.SetConcentMode((byte) (nDevNo - 2), (byte) (nUnitNo - 1), Set);
if (bCtrl_OnOff)
nRet_OnOff = mSdbAPI.SetConcentOnOff((byte) (nDevNo - 2), (byte) (nUnitNo - 1), OnOff);
Log.w(TAG, "[iCMDProcSDPConcentControl] 4 nUnitNo [" + (nUnitNo - 1) + "], nRet_Mode [" + nRet_Mode + "], nRet_OnOff [" + nRet_OnOff + "]");
if ((bCtrl_Set && (0 > nRet_Mode)) || (bCtrl_OnOff && (0 > nRet_OnOff))) {
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
}
}
if (mSdbAPI.Refresh(define.DEVICE_ALL_OR_NOTHING, define.DEVICE_ALL_OR_NOTHING) != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPConcentControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + strAction + "\"\r\n";
if (nDevNo == 1) {
retStr += " \r\n";
for (int i = 0; i < mSdbAPI.data.LivingRoom_EnergyMeter.Info.ConcentCount; i++) {
if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
status_mode = "unset";
else status_mode = "set";
if (mSdbAPI.data.LivingRoom_EnergyMeter.Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
status_onoff = "on";
else status_onoff = "off";
unit_status = status_mode + "/" + status_onoff;
retStr += " \r\n";
}
// retStr += " \r\n";
retStr += " \r\n\r\n";
} else if (nDevNo > 1) {
retStr += " \r\n";
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.ConcentCount; i++) {
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Mode == MultiSwitch.OUTLET_MODE.Always)
status_mode = "unset";
else status_mode = "set";
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.Concent[i].Data.CutOffConcent.Status == MultiSwitch.OUTLET_STATUS.On)
status_onoff = "on";
else status_onoff = "off";
unit_status = status_mode + "/" + status_onoff;
retStr += " \r\n";
}
// retStr += " \r\n";
retStr += " \r\n\r\n";
}
} else {
Log.w(TAG, "[iCMDProcSDPConcentControl] cmd wrong!! -> " + concentcmd.actionTXT);
retStr += " result = \"fail\">\r\n \r\n";
}
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPConcentControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcEnergyMeterConcentControl(Document ele) {
try {
String retStr = CheckiCMDProc(MULTISW_CTR);
if (retStr != null) return retStr;
else retStr = XMLHeader + " 0) result = "ok";
else result = "fail";
retStr += (" result=\"" + result + "\" >\r\n");
if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
retStr += MakeTargetStr(energymetercmd);
retStr += " \"status\"\r\n";
retStr += " \r\n";
String unitStr;
for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
if (i == 2) {
unitStr += "on";
} else {
unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
}
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
} else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
int devNum = Integer.parseInt(energymetercmd.devnum) - 1;
int swNum = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", "")) - 1;
byte cmd = 0;
int ret = 0;
String result;
if (energymetercmd.ctraction.equalsIgnoreCase("set")) cmd = 1;
else if (energymetercmd.ctraction.equalsIgnoreCase("unset")) cmd = 2;
else if (energymetercmd.ctraction.equalsIgnoreCase("on")) cmd = 3;
else if (energymetercmd.ctraction.equalsIgnoreCase("off")) cmd = 4;
if (cmd > 0) {
if (energymeter != null) {
energymeter.Refresh((byte) 0xFF, false);
if (cmd == 1) {
ret = energymeter.SetConcentCutoffMode((byte) devNum, true);
} else if (cmd == 2) {
ret = energymeter.SetConcentCutoffMode((byte) devNum, false);
} else if (cmd == 3) {
ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, true);
} else if (cmd == 4) {
ret = energymeter.SetConcentOnOff((byte) devNum, (byte) swNum, false);
}
if (ret == APIErrorCode.C_SUCCESS) result = "ok";
else result = "fail";
retStr += (" result=\"" + result + "\" >\r\n");
if (ret == APIErrorCode.C_SUCCESS) {
ret = energymeter.Refresh((byte) 0xFF, false);
if (ret == APIErrorCode.C_SUCCESS && energymeter.data.RoomCnt > 0) {
retStr += MakeTargetStr(energymetercmd);
retStr += " \"control\"\r\n";
retStr += " \r\n";
String unitStr;
for (int i = 0; i < energymeter.data.Em.eachRoom[devNum].ConCnt; i++) {
unitStr = (energymeter.data.Em.eachRoom[devNum].ConMode == true) ? "set/" : "unset/";
if (i == 2) {
unitStr += "on";
} else {
unitStr += (energymeter.data.Em.eachRoom[devNum].ConOnOff[i] == true) ? "on" : "off";
}
retStr += " \r\n";
}
} else {
retStr += (" result=\"fail\"> \r\n");
}
} else {
retStr += (" result=\"fail\"> \r\n");
}
retStr += " \r\n\r\n";
}
}
}
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcEnergyMeterConcentControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcModeControl(Document doc) {
try {
String status = "unknown";
boolean SendBR = false;
String retStr = CheckiCMDProc("remote_access_mode");
if (retStr != null) return retStr;
else retStr = XMLHeader + "\r\n ");
retStr += " \r\n";
retStr += " \"" + trimquotation(accmode.actionTXT) + "\"\r\n";
retStr += " \r\n";
retStr += " \r\n \r\n\r\n";
return retStr;
}
if (!SendBR) {
retStr += "\"fail\">\r\n \r\n";
SetData.closeDB();
return retStr;
} else {
try {
Thread.sleep(1000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
int getStatus = SetData.GetAlarmStatus();
switch (getStatus) {
case WallpadStatusData.GUARD_IN:
status = "occupied";
break;
case WallpadStatusData.GUARD_OUT:
status = "unoccupied";
break;
case WallpadStatusData.ALARM_NONE:
status = "normal";
break;
case WallpadStatusData.ALARM_ARISE:
status = "emergency";
break;
}
}
retStr += "\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + trimquotation(accmode.actionTXT) + "\"\r\n";
retStr += " \r\n";
retStr += " \r\n \r\n\r\n";
SetData.closeDB();
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcModeControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcCurtainControl(Document ele) {
return " ";
}
public String iCMDProcSDPLightControl(Document ele) {
try {
String retStr = CheckiCMDProc("remote_access_light");
if (retStr != null) return retStr;
else retStr = XMLHeader + " 0)) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
retStr += " \r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
}
retStr += "\r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
num--;
int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
if (energymeter == null) return null;
if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
retStr += "result=\"ok\">\r\n" +
" \"control\"\r\n" +
" \r\n";
for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
retStr += " \r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
}
retStr += "\r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else {
retStr += "result = \"fail\">\r\n\r\n";
}
energymetercmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcEnergyMeterLightControl(Document ele) {
try {
String retStr = CheckiCMDProc("remote_access_light");
if (retStr != null) return retStr;
else retStr = XMLHeader + " 0)) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
retStr += " \r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
}
retStr += "\r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else if (trimquotation(energymetercmd.actionTXT).equalsIgnoreCase("control")) {
int num = Integer.parseInt(energymetercmd.unitnum.replaceAll("switch", ""));
num--;
int deviceNum = Byte.parseByte(energymetercmd.devnum) - 1;
if (!energymetercmd.ctraction.equalsIgnoreCase("null"))
if (energymeter != null && energymeter.SetLightOnOff((byte) deviceNum, (byte) num, energymetercmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
if ((energymeter.Refresh((byte) 0xFF, false) == 0) && (energymeter.data.Em.eachRoom[deviceNum].LightCnt > 0)) {
retStr += "result=\"ok\">\r\n" +
" \"control\"\r\n" +
" \r\n";
for (int i = 0; i < energymeter.data.Em.eachRoom[deviceNum].LightCnt; i++) {
retStr += " \r\n", i + 1, energymeter.data.Em.eachRoom[deviceNum].LightOnOff[i] ? "on" : "off");
}
retStr += "\r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else {
retStr += "result=\"fail\">\r\n\r\n ";
}
} else {
retStr += "result = \"fail\">\r\n\r\n";
}
energymetercmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcEnergyMeterLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcLightControl(Document ele) {
try {
String retStr = CheckiCMDProc("remote_access_light");
if (retStr != null) return retStr;
else retStr = XMLHeader + " 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n";
if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
retStr += " \r\n";
} else {
retStr += " \r\n";
}
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
retStr += " \r\n", i + 1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n";
} else {
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
if (mMultiSwitchAPI != null) {
int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
if (nResult == 0) {
if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n";
if (target.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH) || target.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
if (Version.getModelType() == MODEL_TYPE.IHN_HS101 || Version.getModelType() == MODEL_TYPE.IHN_HS101_I) {
retStr += " \r\n";
} else {
retStr += " \r\n";
}
} else {
retStr += " \r\n";
}
for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
retStr += " \r\n", i + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(i) ? "on" : "off");
}
retStr += " \r\n";
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI is null!!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
}
} else if (trimquotation(MSlightcmd.actionTXT).equalsIgnoreCase("control")) {
int deviceNum = Byte.parseByte(MSlightcmd.devnum) - 1;
boolean OnOff = false;
if (MSlightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
if (!MSlightcmd.ctraction.equalsIgnoreCase("null")) {
if (bLightCMDUseAsSmartLight) {
if (mSdbAPI != null) {
if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) define.DEVICE_ALL_OR_NOTHING, OnOff);
if (ret >= 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
retStr += " \r\n", i + 1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
int ret = mSdbAPI.SetLightOnOff((byte) deviceNum, (byte) num, OnOff);
if (ret >= 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
int nRefreshResult = mSdbAPI.Refresh(SdbAPI.DEVICE_INDEX.ENERGY_METER, define.DEVICE_ALL_OR_NOTHING);
Log.i(TAG, "[iCMDProcLightControl] nRefreshResult [" + nRefreshResult + "]");
for (int i = 0; i < mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Info.LightCount; i++) {
Log.i(TAG, "[iCMDProcLightControl] mSdbAPI.data.BadRoom_EnergyMeter[" + deviceNum + "].Data.LedLight[" + i + "].Data.OnOff [" + mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff + "]");
retStr += " \r\n", i + 1, mSdbAPI.data.BadRoom_EnergyMeter[deviceNum].Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
}
} else {
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
if (MSlightcmd.unitnum.equalsIgnoreCase("all")) {
if (mMultiSwitchAPI != null) {
int nResultRefresh = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
if (nResultRefresh == 0) {
int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) 0xFF, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
if (nCtrlResult == 0) {
int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
if (nResult == 0) {
if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
for (int j = 0; j < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; j++) {
retStr += " \r\n", j + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(j) ? "on" : "off");
}
retStr += " \r\n";
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
}
} else {
int num = (Integer.parseInt(MSlightcmd.unitnum.replaceAll("switch", "")) - 1);
if (mMultiSwitchAPI != null) {
int nCtrlResult = mMultiSwitchAPI.SetLightOnOff((byte) deviceNum, (byte) num, MSlightcmd.ctraction.equalsIgnoreCase("on") ? true : false);
if (nCtrlResult == 0) {
int nResult = mMultiSwitchAPI.Refresh((byte) 0xFF, false);
if (nResult == 0) {
if (mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt > 0) {
retStr += "result=\"ok\">\r\n" +
" \"status\"\r\n" +
" \r\n";
for (int i = 0; i < mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt; i++) {
retStr += " \r\n", i + 1, mMultiSwitchAPI.data.Device[deviceNum].device.getLightPower(i) ? "on" : "off");
}
retStr += " \r\n";
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI.data.Device[" + deviceNum + "].device.LightCount is unavailable!! -> " + mMultiSwitchAPI.data.Device[deviceNum].device.hLightCnt);
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI refresh fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
} else {
Log.w(TAG, "[iCMDProcLightControl] mMultiSwitchAPI light ctrl fail!!");
retStr += "result=\"fail\">\r\n \r\n ";
}
}
}
}
} else {
retStr += "result = \"fail\">\r\n \r\n ";
}
} else {
retStr += "result = \"fail\">\r\n \r\n ";
}
MSlightcmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcSDPSmartLightControl(Document ele) {
try {
WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
String retStr = CheckiCMDProc("remote_access_smartlight");
if (retStr != null) return retStr;
else
retStr = XMLHeader + " \r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdb_LivingRoomLightAPI is null!!!");
return retStr;
}
if (mSdbAPI == null) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] mSdbAPI is null!!!");
return retStr;
}
if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
return retStr;
}
for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) i) != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
}
int nTotalLightCnt = mSdbAPI.data.BadRoom_Em_Count + 1; // 각방 EM 개수 + 거실EM
Log.w(TAG, "[iCMDProcSDPSmartLightControl] LivingLightCount [" + mSdb_LivingRoomLightAPI.data.Info.LightCount + "], mSdbAPI.data.BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "], nTotalLightCnt [" + nTotalLightCnt + "]");
if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status")) {
if (lightcmd.devnum.equalsIgnoreCase("all")) {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"" + nTotalLightCnt + "\"\r\n";
for (int i = 0; i < nTotalLightCnt; i++) {
if (i == 0) {
retStr += " \r\n";
for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
} else {
retStr += " \r\n";
for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
} else {
int nDevNo = 0;
try {
nDevNo = Integer.parseInt(lightcmd.devnum);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + lightcmd.devnum + ")");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if ((nDevNo - 1) > nTotalLightCnt) {
Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"status\"\r\n";
retStr += " \"1\"\r\n";
if (nDevNo == 1) {
retStr += " \r\n";
for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
} else {
retStr += " \r\n";
for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nDevNo - 2].Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
}
retStr += " \r\n\r\n";
}
} else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
int nResult = -99;
String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
NodeList items = ele.getElementsByTagName("params");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("dev_num"))
dev_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
dev_mode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
unit_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
unit_status = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
unit_dimming = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
unit_color = attr.getNodeValue();
}
}
if (dev_num.equalsIgnoreCase("all")) {
nResult = 0;
for (int i = 0; i < nTotalLightCnt; i++) {
if (i == 0) {
nResult += mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
} else {
nResult += mSdbAPI.SetLight2((byte) (i - 1), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
}
}
if (nResult != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] All EM ctrl failed!!!");
return retStr;
} else {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"" + nTotalLightCnt + "\"\r\n";
}
if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
return retStr;
}
if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) define.DEVICE_ALL_OR_NOTHING) != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
for (int i = 0; i < nTotalLightCnt; i++) {
if (i == 0) {
retStr += " \r\n";
for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
} else {
retStr += " \r\n";
for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[i - 1].Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
} else {
int nDevNo = 0;
int nUnitNo = 0;
try {
nDevNo = Integer.parseInt(dev_num);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if ((nDevNo - 1) > nTotalLightCnt) {
Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + nTotalLightCnt + "]");
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
nResult = -99;
if (unit_num.equalsIgnoreCase("all")) {
if (nDevNo == 1) {
nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
} else {
nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) define.DEVICE_ALL_OR_NOTHING, convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
}
if (nResult != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
return retStr;
}
} else {
try {
nUnitNo = Integer.parseInt(unit_num);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
nResult = -99;
if (nDevNo == 1) {
nResult = mSdb_LivingRoomLightAPI.SetLight2((byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
} else {
nResult = mSdbAPI.SetLight2((byte) (nDevNo - 2), (byte) (nUnitNo - 1), convertSmartLightPowerValue(unit_status),
unit_dimming.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_dimming),
unit_color.equalsIgnoreCase("null") ? define.DEVICE_ALL_OR_NOTHING : (byte) Integer.parseInt(unit_color));
}
if (nResult != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Each EM - All light ctrl failed!!!");
return retStr;
}
}
if (nDevNo == 1) {
if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
return retStr;
} else {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
}
retStr += " \r\n";
for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
} else {
int nRealDevNo = (byte) (nDevNo - 2);
if (mSdbAPI.Refresh((byte) SdbAPI.DEVICE_INDEX.ENERGY_METER, (byte) nRealDevNo) != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
} else {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
}
retStr += " \r\n";
for (int j = 0; j < mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdbAPI.data.BadRoom_EnergyMeter[nRealDevNo].Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n";
}
retStr += " \r\n\r\n";
}
} else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("mode_control")) {
int nResult = 0;
String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
NodeList items = ele.getElementsByTagName("params");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("dev_num"))
dev_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("dev_mode"))
dev_mode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_num"))
unit_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_status"))
unit_status = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_dimming"))
unit_dimming = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_color"))
unit_color = attr.getNodeValue();
}
}
if (dev_num.equalsIgnoreCase("all")) {
if (!dev_mode.equals("null")) {
nResult = -99;
nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
if (nResult != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
return retStr;
} else {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
}
retStr += " \r\n";
// 각방EM 모드제어 API 추가해야함 (JEFF,2019.09.29)
retStr += " \r\n \r\n\r\n";
} else {
int nDevNo = 0;
try {
nDevNo = Integer.parseInt(dev_num);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if (nDevNo != 1) {
Log.e(TAG, "The LivingEM only can be controlled mode control!! nDevNo [" + nDevNo + "]");
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if (!dev_mode.equals("null")) {
nResult = -99;
nResult = mSdb_LivingRoomLightAPI.SetLightMode((byte) Integer.parseInt(dev_mode));
if (nResult != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
if (mSdb_LivingRoomLightAPI.Refresh() != 0) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcSDPSmartLightControl] Refreshing mSdb_LivingRoomLightAPI is failed!!!");
return retStr;
} else {
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
}
retStr += " \r\n";
for (int j = 0; j < mSdb_LivingRoomLightAPI.data.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.OnOff) {
status_power = (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.OnOff) ? "on" : "off";
} else {
status_power = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Dimming) {
status_dim = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Dimming);
} else {
status_dim = "null";
}
if (mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Info.Support.Color) {
status_color = Integer.toString((int) mSdb_LivingRoomLightAPI.data.Data.LedLight[j].Data.Color);
} else {
status_color = "null";
}
retStr += " \r\n";
}
retStr += " \r\n \r\n\r\n";
}
} else {
retStr += " result = \"fail\">\r\n \r\n";
}
lightcmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private byte getLightType(KNX_DataClasses.EnergyMeterClass benEm, int lightIndex) {
byte type = 0;
//각 스위치 개수는 4개임
switch (lightIndex) {
case 0:
type = benEm.Info.LightType_1;
break;
case 1:
type = benEm.Info.LightType_2;
break;
case 2:
type = benEm.Info.LightType_3;
break;
case 3:
type = benEm.Info.LightType_4;
break;
default:
break;
}
return type;
}
public String iCMDProcChumDamSmartLightControl(Document ele) {
try {
WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
String retStr = CheckiCMDProc("remote_access_smartlight");
if (retStr != null) return retStr;
else retStr = XMLHeader + " \r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] mSdbAPI is null!!!");
return retStr;
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
int LivingLightCount = 0;
if (KnxApi.data.LivingRoom_EnergyMeter.Info.Install == false) {
Log.w(TAG, "[Registration_Light_NewLiv]mData.LivingRoom_EnergyMeter.Info.Install == false");
} else {
if(KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount > 0)
LivingLightCount = 1;
}
//기준층 명칭
String[] defaultNameList = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
"복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "드레스룸2", "서재1", "작업실","드레스룸3","추가룸1","추가룸2","추가룸3","추가룸4","추가룸5"};
String[] knxRoomNameList = getRoomNameFromDBV2(define.ROOM_NAME_LIGHT);
if(knxRoomNameList==null) knxRoomNameList = defaultNameList;
int BadLightCount = KnxApi.data.MasterController.Info.Bad_EnergyMeterCount;
int SwitchCount = KnxApi.data.MasterController.Info.Light_SwitchCount;
int totalLightCount = LivingLightCount + BadLightCount + SwitchCount;
int emCount = LivingLightCount + BadLightCount;
//mData.MasterController.Info.Light_SwitchCount
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] LivingLightCount [" + LivingLightCount + "], mSdbAPI.data.BadConcentCount [" + BadLightCount + "], nTotalLightCnt [" + totalLightCount +"]");
if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("status"))
{
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"" + totalLightCount + "\"\r\n";
if (lightcmd.devnum.equalsIgnoreCase("all")) {
for (int i = 0; i < totalLightCount; i++) {
if (i == 0) {
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
retStr += " \r\n";
}
retStr += " \r\n";
} else if(i>0 && i\r\n";
for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
status_dim ="null";
retStr += " \r\n";
}
retStr += " \r\n";
} else{
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
status_dim ="null";
// zzz
//Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] ***** getLightType" + getLightType( KnxApi.data.BadRoom_EnergyMeter[i - 1], j) );
retStr += " \r\n";
}
retStr += " \r\n";
}
}
}
else
{
int nResult = 0;
String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
NodeList items = ele.getElementsByTagName("params");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j< attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
}
}
int nDevNo = Integer.parseInt(dev_num);
if (nDevNo == 1) {
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
retStr += " \r\n";
}
retStr += " \r\n";
} else if(nDevNo>1 && nDevNo\r\n";
for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.OnOff) ? "on" : "off";
status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo-2].Data.BadLight[j].Data.Dimming);
if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo-2], j) == 0x0F)
status_dim ="null";
retStr += " \r\n";
}
retStr += " \r\n";
} else{
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
status_dim ="null";
retStr += " \r\n";
}
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
}
else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
int nResult = 0;
String dev_num = "null", dev_mode = "null", unit_num = "null", unit_status = "null", unit_dimming = "null", unit_color = "null";
NodeList items = ele.getElementsByTagName("params");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j< attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("dev_num")) dev_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("dev_mode")) dev_mode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_num")) unit_num = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_status")) unit_status = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_dimming")) unit_dimming = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("unit_color")) unit_color = attr.getNodeValue();
}
}
if (dev_num.equalsIgnoreCase("ALL")) {
// 일괄소등 실행/해제
if (!unit_status.equalsIgnoreCase("null")) {
KnxApi.AllLightOnOff((unit_status.equalsIgnoreCase("on")) ? true : false);
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"" + totalLightCount + "\"\r\n";
for (int i = 0; i < totalLightCount; i++) {
if (i == 0) {
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.OnOff);
status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.OnOff) ? "on" : "off";
Log.w(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming : " + KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Info.Support.Dimming);
status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[j].Data.Dimming);
retStr += " \r\n";
}
retStr += " \r\n";
}
else if(i>0 && i\r\n";
for (int j = 0; j < KnxApi.data.BadRoom_EnergyMeter[i - 1].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.OnOff) ? "on" : "off";
status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[i - 1].Data.BadLight[j].Data.Dimming);
if( getLightType( KnxApi.data.BadRoom_EnergyMeter[i-1], j) == 0x0F)
status_dim ="null";
retStr += " \r\n";
}
retStr += " \r\n";
} else {
retStr += " \r\n";
for (int j = 0; j < KnxApi.data.Light_Switch[i-emCount].Info.LightCount; j++) {
String status_power = "off", status_dim = "null", status_color = "null";
status_power = (KnxApi.data.Light_Switch[i - emCount].Data.LightSwitch[j].Data.OnOff) ? "on" : "off";
status_dim ="null";
retStr += " \r\n";
}
retStr += " \r\n";
}
}
retStr += " \r\n\r\n";
}
else {
int nDevNo = 0;
int nUnitNo = 0;
try {
nDevNo = Integer.parseInt(dev_num);
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
e.printStackTrace();
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if ((nDevNo - 1) > totalLightCount) {
Log.e(TAG, "Out of range!! nDevNo [" + nDevNo + "], nTotalLightCnt [" + totalLightCount +"]");
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
// retStr += " result=\"ok\">\r\n";
// retStr += " \r\n";
// retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
// retStr += " \"1\"\r\n";
if (unit_num.equalsIgnoreCase("all")) {
if (nDevNo == 1) {
// 거실 조명 일괄제어일 경우
if (!unit_status.equalsIgnoreCase("null")) {
int ret = KnxApi.SetLivingLightOnOff(define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
//mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
}
if (!unit_dimming.equalsIgnoreCase("null")) {
KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
retStr += " \r\n";
}
}
else if(nDevNo>1 && nDevNo Fan : " + nDevNo );
for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
// 욕실팬은 제어하지 말아야 하는데...코드 추가해야함
int nRet =KnxApi.SetEMLightDimming((byte) (nDevNo -2), (byte)i,(byte) Integer.parseInt(unit_dimming));
Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
}
}
else {
int nRet = KnxApi.SetEMLightDimming((byte) (nDevNo - 2), define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] KnxApi.SetEMLightDimming!!nRet : " + nRet);
}
//KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming)); // 거실이라는 이야기인데;
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
nDevNo = Integer.parseInt(dev_num);
for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
//KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
status_dim ="null";
retStr += " \r\n";
}
} else {
// 각각 EM 스위치 일괄제어일 경우
if (!unit_status.equalsIgnoreCase("null")) {
KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), define.DEVICE_ALL_OR_NOTHING, (unit_status.equalsIgnoreCase("on")) ? true : false);
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
nDevNo = Integer.parseInt(dev_num);
for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
//KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
String status_dim ="null";
retStr += " \r\n";
}
}
// retStr += " \r\n";
// retStr += " \r\n\r\n";
}
else {
// 회로별 제어일경우
try {
nUnitNo = Integer.parseInt(unit_num);
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcChumDamSmartLightControl(Document ele) -> nDevNo (" + dev_num + ")");
e.printStackTrace();
retStr += " result=\"fail\">\r\n \r\n";
return retStr;
}
if (nDevNo == 1) {
if (!unit_status.equalsIgnoreCase("null")) {
int ret = KnxApi.SetLivingLightOnOff((byte) (nUnitNo-1) , (unit_status.equalsIgnoreCase("on")) ? true : false);
//mSdb_LivingRoomLightAPI.SetLightOnOff((byte) 0xFF, (unit_status.equalsIgnoreCase("on")) ? true : false);
}
if (!unit_dimming.equalsIgnoreCase("null")) {
KnxApi.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) Integer.parseInt(unit_dimming));
//mSdb_LivingRoomLightAPI.SetLightDimming((byte) 0xFF, (byte) Integer.parseInt(unit_dimming));
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
nDevNo = Integer.parseInt(dev_num);
for( int i = 0 ; i < KnxApi.data.LivingRoom_EnergyMeter.Info.LightCount ; i++) {
String status_power = (KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.OnOff) ? "on" : "off";
String status_dim = Integer.toString((int) KnxApi.data.LivingRoom_EnergyMeter.Data.LivingLight[i].Data.Dimming);
retStr += " \r\n";
}
}
else if(nDevNo>1 && nDevNo\r\n \r\n";
Log.w(TAG, "[iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
nDevNo = Integer.parseInt(dev_num);
for( int i = 0 ; i < KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightCount ; i++) {
String status_power = (KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.OnOff) ? "on" : "off";
String status_dim = Integer.toString((int) KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Data.BadLight[i].Data.Dimming);
if( getLightType( KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2], i) == 0x0F)
status_dim ="null";
retStr += " \r\n";
}
} else{
if (!unit_status.equalsIgnoreCase("null")) {
KnxApi.SetLightSwitchOnOff((byte) (nDevNo-emCount-1), (byte)(nUnitNo-1), (unit_status.equalsIgnoreCase("on")) ? true : false);
}
if ( KnxApi.Refresh(KnxAPI.DEVICE_INDEX.ALL, (byte) define.DEVICE_ALL_OR_NOTHING) < 0 ) {
retStr += " result=\"fail\">\r\n \r\n";
Log.d(TAG, "yskim [iCMDProcChumDamSmartLightControl] Refreshing mSdbAPI is failed!!!");
return retStr;
}
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \"" + lightcmd.actionTXT + "\"\r\n";
retStr += " \"1\"\r\n";
retStr += " \r\n";
nDevNo = Integer.parseInt(dev_num);
for( int i = 0 ; i < KnxApi.data.Light_Switch[nDevNo-emCount-1].Info.LightCount ; i++) {
//KnxApi.data.BadRoom_EnergyMeter[nDevNo - 2].Info.LightType_1
String status_power = (KnxApi.data.Light_Switch[nDevNo-emCount-1].Data.LightSwitch[i].Data.OnOff) ? "on" : "off";
String status_dim ="null";
retStr += " \r\n";
}
}
}
retStr += " \r\n";
retStr += " \r\n\r\n";
}
}
else {
retStr += " result = \"fail\">\r\n \r\n";
}
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSDPSmartLightControl(Document ele)");
e.printStackTrace();
return null;
}
}
public String iCMDProcLivingLightControl(Document ele) {
try {
WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
String retStr = CheckiCMDProc("remote_access_livinglight");
if (retStr != null) return retStr;
else
retStr = XMLHeader + " \r\n \"status\"\r\n \r\n";
for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
retStr += " \r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n ";
}
} else {
LightAPI lightCTR = mWallPadAPI.Get_LightController();
if (lightCTR != null) {
if (lightCTR.Refresh(false) == 0) {
retStr += " result=\"ok\">\r\n \"status\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n ";
}
}
}
} else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
if (!lightcmd.ctraction.equalsIgnoreCase("null")) {
boolean OnOff = false;
if (lightcmd.ctraction.equalsIgnoreCase("on")) OnOff = true;
if (bLightCMDUseAsSmartLight) {
if (lightcmd.unitnum.equalsIgnoreCase("all")) {
int ret = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, OnOff);
if (ret >= 0) {
ret = mSdb_LivingRoomLightAPI.Refresh();
if (ret >= 0) {
retStr += " result=\"ok\">\r\n \"control\"\r\n \r\n";
for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
retStr += " \r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
int ret = mSdb_LivingRoomLightAPI.SetLightOnOff((byte) (num - 1), OnOff);
if (ret >= 0) {
ret = mSdb_LivingRoomLightAPI.Refresh();
if (ret >= 0) {
retStr += " result=\"ok\">\r\n \"control\"\r\n \r\n";
for (int i = 0; i < mSdb_LivingRoomLightAPI.data.Info.LightCount; i++) {
retStr += " \r\n", i + 1, mSdb_LivingRoomLightAPI.data.Data.LedLight[i].Data.OnOff ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
}
} else {
LightAPI lightCTR = mWallPadAPI.Get_LightController();
if (lightCTR != null) {
if (lightcmd.unitnum.equalsIgnoreCase("all")) {
int ret = lightCTR.SetLightOnOff((byte) 0xFF, OnOff);
if (ret >= 0) {
ret = lightCTR.Refresh(false);
if (ret >= 0) {
retStr += " result=\"ok\">\r\n \"control\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
int ret = lightCTR.SetLightOnOff((byte) num, OnOff);
if (ret >= 0) {
ret = lightCTR.Refresh(false);
if (ret >= 0) {
retStr += " result=\"ok\">\r\n \"control\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.OnOff[i] ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
}
}
}
} else {
retStr += " result=\"fail\">\r\n \r\n";
}
} else {
retStr += " result = \"fail\">\r\n \r\n";
}
lightcmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcLivingLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProc_I_LightControl(Document ele) {
try {
WallpadiCMDParser lightcmd = new WallpadiCMDParser(ele);
String retStr = CheckiCMDProc("remote_access_livinglight");
if (retStr != null) return retStr;
else
retStr = XMLHeader + " \r\n \"status\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n \r\n ";
}
} else if (trimquotation(lightcmd.actionTXT).equalsIgnoreCase("control")) {
if ((lightcmd.unitnum.equalsIgnoreCase("program1") == true) || (lightcmd.unitnum.equalsIgnoreCase("program2") == true)) {
int num = Integer.parseInt(lightcmd.unitnum.replaceAll("program", ""));
int result = -999;
if (lightCTR != null) {
if (lightcmd.ctraction.equalsIgnoreCase("on") == true) {
result = lightCTR.LightProgramControl((byte) num, (byte) 1);
} else if (lightcmd.ctraction.equalsIgnoreCase("off") == true) {
result = lightCTR.LightProgramControl((byte) num, (byte) 0);
}
if (result >= 0) {
// 제어 성공
try {
Thread.sleep(1000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
lightCTR.Refresh(false);
retStr += "result=\"ok\"> \r\n \"control\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
}
retStr += " \r\n";
} else {
retStr += "result=\"fail\">\r\n \r\n";
}
} else {
retStr += "result=\"fail\">\r\n \r\n";
}
} else {
int num = Integer.parseInt(lightcmd.unitnum.replaceAll("switch", ""));
if (!lightcmd.ctraction.equalsIgnoreCase("null"))
if (lightCTR != null && lightCTR.LightControl((byte) num, lightcmd.ctraction.equalsIgnoreCase("on") ? true : false) == 0) {
try {
Thread.sleep(1000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
lightCTR.Refresh(false);
retStr += "result=\"ok\"> \r\n \"control\"\r\n \r\n";
for (int i = 0; i < lightCTR.data.LightCount; i++) {
retStr += " \r\n", i + 1, lightCTR.data.LightStatus[i] == true ? "on" : "off");
}
retStr += " \r\n\r\n";
} else {
retStr += "result=\"fail\">\r\n \r\n";
}
}
} else {
retStr += "result = \"fail\">\r\n \r\n";
}
lightcmd = null;
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProc_I_LightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String iCMDProcGASControl(Element ele) {
try {
String target = "null", tid = "null", msgno = "null", devnum = "null", ctraction = "null", valvestatus = "null";
String strResult = CheckiCMDProc("remote_access_gas");
if (strResult != null) return strResult;
else
strResult = XMLHeader + " \r\n \r\n";
return strResult;
}
int OnOpenCount = 0;
int OperationCount = 0;
for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
// 콘센트 ON/OFF 업데이트
if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
OnOpenCount++;
} else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
OperationCount++;
}
}
}
if (OperationCount > 0) {
valvestatus = "ing";
} else if (OnOpenCount > 0) {
valvestatus = "open";
} else {
valvestatus = "close";
}
}
} else {
if (GasValveCTR != null) {
int ret = GasValveCTR.Refresh((byte) 0, false);
if (ret < 0) {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
if (GasValveCTR.data.DeviceCnt == 2) {
GasValveCTR.Refresh((byte) 1, false);
}
byte GasStatus = GasAPI.GASSTATUS.Close;
for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
GasStatus = GasAPI.GASSTATUS.Operation;
break;
}
if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
GasStatus = GasAPI.GASSTATUS.Open;
break;
}
}
if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
else valvestatus = "unknown";
}
}
} else if (actionTXT.equalsIgnoreCase("control")) {
// 가스밸브 콘트롤
if (mWallPadAPI.GetGasKind() == 2) {
//하이브리드
if (HybridCookTopCTR != null) {
int ret = HybridCookTopCTR.setEntireCircuitClose((byte) 0);
if (ret < 0) {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
ret = HybridCookTopCTR.Refresh((byte) 0xFF, false);
if (ret < 0) {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
int OnOpenCount = 0;
int OperationCount = 0;
for (int RoomIndex = 0; RoomIndex < HybridCookTopCTR.data.Device[0].circuit.length; RoomIndex++) {
// 콘센트 ON/OFF 업데이트
if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus != DataClasses.CooktopCtrl.DEVICE_STATUS.NOINFO) {
if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.OPEN) {
OnOpenCount++;
} else if (HybridCookTopCTR.data.Device[0].circuit[RoomIndex].hStatus == DataClasses.CooktopCtrl.DEVICE_STATUS.WORKING) {
OperationCount++;
}
}
}
if (OperationCount > 0) {
valvestatus = "ing";
} else if (OnOpenCount > 0) {
valvestatus = "open";
} else {
valvestatus = "close";
}
}
} else {
if (GasValveCTR != null) {
int ret = GasValveCTR.SetClose((byte) 0xFF);
if (ret < 0) {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
ret = GasValveCTR.Refresh((byte) 0, false);
if (ret < 0) {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
if (GasValveCTR.data.DeviceCnt == 2) {
GasValveCTR.Refresh((byte) 1, false);
}
byte GasStatus = GasAPI.GASSTATUS.Close;
for (int i = 0; i < GasValveCTR.data.DeviceCnt; i++) {
if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Operation) {
GasStatus = GasAPI.GASSTATUS.Operation;
break;
}
if (GasValveCTR.data.Device[i].GasStatus == GasAPI.GASSTATUS.Open) {
GasStatus = GasAPI.GASSTATUS.Open;
break;
}
}
if (GasStatus == GasAPI.GASSTATUS.Close) valvestatus = "close";
else if (GasStatus == GasAPI.GASSTATUS.Open) valvestatus = "open";
else if (GasStatus == GasAPI.GASSTATUS.Operation) valvestatus = "ing";
else valvestatus = "unknown";
}
}
} else {
strResult += "\"fail\">\r\n \r\n";
return strResult;
}
strResult += "\"ok\" >\r\n";
strResult += " \r\n";
strResult += " \"" + actionTXT + "\"\r\n";
strResult += " \r\n";
strResult += " \r\n";
strResult += " \r\n";
strResult += " ";
return strResult;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcGASControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private String iCMDProcLightBatchControl(Element ele) {
try {
String target = "null", tid = "null", msgno = "null", ctraction = "null", ilgalstatus = "null";
String retStr = CheckiCMDProc("remote_access_light_batch_control");
if (retStr != null) return retStr;
NodeList items = ele.getElementsByTagName("target");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
msgno = attr.getNodeValue();
}
}
// 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
if (NewServerUse()) {
String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED))
return ServerCheckResult;
}
NodeList itemsParam = ele.getElementsByTagName("params");
Node itemParam = itemsParam.item(0);
if (itemParam != null) {
NamedNodeMap attrsParam = itemParam.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
ctraction = attr.getNodeValue();
}
}
}
NodeList itemsaction = ele.getElementsByTagName("action");
Node itemaction = itemsaction.item(0);
Node text = itemaction.getFirstChild();
String actionTXT = text.getNodeValue();
retStr = XMLHeader + " 1) {
retStr += " \"fail\" >\r\n \r\n";
return retStr;
}
if (ret == 0) {
ilgalstatus = "on";
} else if (ret == 1) {
ilgalstatus = "off";
} else {
ilgalstatus = "error";
}
} else if (actionTXT.equalsIgnoreCase("control")) {
// 일괄소등 제어
int ret = -1;
int status = -1;
if (ctraction.equals("on") == true) {
ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
status = 0;
} else if (ctraction.equals("off") == true) {
ret = mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
status = 1;
}
if (ret < 0) {
retStr += " \"fail\" >\r\n \r\n";
return retStr;
}
if (status == 0) {
ilgalstatus = "on";
} else if (status == 1) {
ilgalstatus = "off";
} else {
ilgalstatus = "error";
}
} else {
retStr += "\"fail\" />\r\n \r\n";
return retStr;
}
retStr += "\"ok\" >\r\n";
retStr += " \r\n";
retStr += " \"" + actionTXT + "\"\r\n";
retStr += " \r\n \r\n ";
return retStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcLightBatchControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private boolean airconTestMode = false;
private boolean [] airconTestModeOnOff = {false, true, false, true, false, true, false, true, false, true, false};
private String getTextSysAirconMode(byte in)
{
if( in == DataClasses.KnxSystemAircon.MODE.Auto)
return "auto";
else if( in == DataClasses.KnxSystemAircon.MODE.Cold)
return "cool";
else if( in == DataClasses.KnxSystemAircon.MODE.Dry)
return "dehum";
else if( in == DataClasses.KnxSystemAircon.MODE.Venti)
return "blow";
else if( in == DataClasses.KnxSystemAircon.MODE.Heat)
return "heat";
else
return "null";
}
private String iCMDProcSysairconControl(Element ele) {
try {
String target= "null", tid= "null", msgno= "null", devnum = "null",ctraction = "null", ilgalstatus = "null";
String retStr = CheckiCMDProc("remote_access_sysaircon");
if (retStr != null) return retStr;
NodeList items = ele.getElementsByTagName("target");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("name")) target = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("id")) tid = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("msg_no")) msgno = attr.getNodeValue();
}
}
// 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
if (NewServerUse()) {
String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, target, ele);
if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED) && !ServerCheckResult.equals(WEB_USER_AUTH_PASSED)) return ServerCheckResult;
}
NodeList itemsParam = ele.getElementsByTagName("params");
Node itemParam = itemsParam.item(0);
if (itemParam != null) {
NamedNodeMap attrsParam = itemParam.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("dev_num")) devnum = attr.getNodeValue();
if (attr.getNodeName().equalsIgnoreCase("ctrl_action")) {
ctraction = attr.getNodeValue();
}
}
}
NodeList itemsaction = ele.getElementsByTagName("action");
Node itemaction = itemsaction.item(0);
Node text = itemaction.getFirstChild();
String actionTXT = text.getNodeValue();
retStr = XMLHeader + " \r\n \r\n";
return retStr;
} else {
for (int i = 0; i < nCount; i++) {
String sOnOff = "off";
if( airconTestMode == true )
{
if( airconTestModeOnOff[i] == true )sOnOff = "on";
strResultStatus += " \r\n";
//strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
else {
if (airconAPI.data.Device.Aircon[i].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
sOnOff = "on";
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
}
}
}
else
{
// 개별 상태 조회
if (airconTestMode == false && ret < 0) {
retStr += " \"fail\" >\r\n \r\n";
return retStr;
} else {
int reqDevNum = Integer.parseInt(devnum);
String sOnOff = "off";
if( airconTestMode == true )
{
if( airconTestModeOnOff[reqDevNum-1] == true )sOnOff = "on";
strResultStatus += " \r\n";
//strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
else {
if (airconAPI.data.Device.Aircon[reqDevNum-1].OnOff == DataClasses.KnxSystemAircon.ONOFF.AirconON)
sOnOff = "on";
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
}
}
}
else if (actionTXT.equalsIgnoreCase("control")) {
// 에어컨 제어
String[] CtrList;
CtrList = ctraction.split("/");
for( int k = 0 ; k < CtrList.length; k++)
{
Log.d(TAG, "[yskim] iCMDProcSysairconControl() iCMDProcSysairconControl : CtrList[k] : " + k + " CtrList[k] : " + CtrList[k]);
}
strResultStatus = "";
int ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
if (devnum.equalsIgnoreCase("all")) {
// 일괄제어는 Off 밖에 없음
if( airconTestMode == true )
{
for (int i = 0; i < nCount; i++) {
String sOnOff = "off";
//CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
if(CtrList[0].equalsIgnoreCase("off"))
{
airconTestModeOnOff[i] = false;
}
else
{
airconTestModeOnOff[i] = true;
sOnOff = "on";
}
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
}
else
{
for (int i = 0; i < nCount; i++) {
String sOnOff = "off";
//CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
byte hOnOff = 0x00;
if(CtrList[0].equalsIgnoreCase("off"))
{
hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
sOnOff = "off";
}
else
{
hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
sOnOff = "on";
}
double setTemp = airconAPI.data.Device.Aircon[i].SetTemp;
byte volume = airconAPI.data.Device.Aircon[i].Volume;
byte mode = airconAPI.data.Device.Aircon[i].Mode;
int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
ret = airconAPI.SetEachRoomStatus((byte)i, hMode, setTemp);
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
}
}
else
{
// 개별 제어
int nDevNum = Integer.parseInt(devnum);
if( airconTestMode == true )
{
String sOnOff = "off";
//CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
if(CtrList[0].equalsIgnoreCase("off"))
{
airconTestModeOnOff[nDevNum-1] = false;
}
else
{
airconTestModeOnOff[nDevNum-1] = true;
sOnOff = "on";
}
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
else
{
String sOnOff = "off";
//CtrList[1] = cool , CtrList[2] = 1 (바람세기) ,CtrList[3] = 설정온도 ,CtrList[4] = 현재온도 ,
byte hOnOff = 0x00;
if(CtrList[0].equalsIgnoreCase("off"))
{
hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconOFF;
sOnOff = "off";
}
else
{
hOnOff = DataClasses.KnxSystemAircon.ONOFF.AirconON;
sOnOff = "on";
}
//String [] aMode = {"auto","cool","dehum","blow","heat"};
byte mode = 0x00;
if(CtrList[1].equalsIgnoreCase("auto"))
mode = DataClasses.KnxSystemAircon.MODE.Auto;
else if(CtrList[1].equalsIgnoreCase("cool"))
mode = DataClasses.KnxSystemAircon.MODE.Cold;
else if(CtrList[1].equalsIgnoreCase("dehum"))
mode = DataClasses.KnxSystemAircon.MODE.Dry;
else if(CtrList[1].equalsIgnoreCase("blow"))
mode = DataClasses.KnxSystemAircon.MODE.Venti;
else if(CtrList[1].equalsIgnoreCase("heat"))
mode = DataClasses.KnxSystemAircon.MODE.Heat;
else
mode = airconAPI.data.Device.Aircon[nDevNum-1].Mode;
byte volume = 0x00;
if(CtrList[2].equalsIgnoreCase(mTextWindType[0]))
volume = DataClasses.KnxSystemAircon.VOLUME.Auto;
else if(CtrList[2].equalsIgnoreCase(mTextWindType[1]))
volume = DataClasses.KnxSystemAircon.VOLUME.Weak;
else if(CtrList[2].equalsIgnoreCase(mTextWindType[2]))
volume = DataClasses.KnxSystemAircon.VOLUME.Medium;
else if(CtrList[2].equalsIgnoreCase(mTextWindType[3]))
volume = DataClasses.KnxSystemAircon.VOLUME.Strong;
else
volume = airconAPI.data.Device.Aircon[nDevNum-1].Volume;
double setTemp = 0;
if( CtrList[3].equalsIgnoreCase("null"))
setTemp = airconAPI.data.Device.Aircon[nDevNum-1].SetTemp;
else
setTemp = Double.parseDouble(CtrList[3]);
int hMode = (int) (hOnOff+(volume<<2)+(mode<<4));
ret = airconAPI.SetEachRoomStatus((byte)(nDevNum-1), hMode, setTemp);
if( ret >= 0 ) {
ret = (byte) airconAPI.Refresh((byte) 0xFF, false);
}
double curTemp = airconAPI.data.Device.Aircon[nDevNum-1].NowTemp;
strResultStatus += " \r\n";
strResultStatus += " \r\n";
}
}
}
else {
retStr += "\"fail\" />\r\n \r\n";
return retStr;
}
retStr += "\"ok\" >\r\n";
retStr += " \r\n";
retStr += " \""+actionTXT+"\"\r\n";
retStr += strResultStatus;
retStr += " \r\n";
retStr += " ";
return retStr;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcSysairconControl(Document ele)");
e.printStackTrace();
return null;
}
}
private String iCMDProcEntireLightControl(Document ele) {
try {
String retStr = CheckiCMDProc("remote_entire_access_light_control");
if (retStr != null) return retStr;
else
retStr = XMLHeader + " \r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
if (mSdbAPI == null) {
Log.w(TAG, "[iCMDProcEntireLightControl] mSdbAPI is null!!!");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong)) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho))) {
items = ele.getElementsByTagName("sel_ctrlinfo");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("dev_num"))
sDevice_Num = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
sSelCtrl_Action = trimquotation(attr.getNodeValue());
}
Log.d(TAG, "[iCMDProcEntireLightControl] sDevice_Num [" + sDevice_Num + "], sSelCtrl_Action [" + sSelCtrl_Action + "]");
int result = -1; // 조명 제어 결과
boolean bLivingLightSel = false; // 거실조명 선택 여부
// ============================== 선택된 조명 ==============================
String[] sel_devNum = null;
if (sDevice_Num != null && sDevice_Num.contains("light")) {
if (sDevice_Num.contains("/"))
sel_devNum = sDevice_Num.replaceAll("light", "").split("/");
else {
sel_devNum = new String[1];
sel_devNum[0] = sDevice_Num.replaceAll("light", "");
}
}
if (sel_devNum == null) sel_devNum = new String[0];
for (int i = 0; i < sel_devNum.length; i++) {
if (sel_devNum[i].equals("1")) {
bLivingLightSel = true;
Log.d(TAG, "[iCMDProcEntireLightControl] == Selected Living EM ==");
if (sSelCtrl_Action != null) {
if (sSelCtrl_Action.equalsIgnoreCase("off")) {
result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
} else {
int nColor = 0;
if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
if (nColor > 0) {
result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
}
}
// 거실조명 제어 결과
if (result < 0) {
Log.w(TAG, "[iCMDProcEntireLightControl] SEL Living Light Control FAIL !!!");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
}
} else {
Log.d(TAG, "[iCMDProcEntireLightControl] == Selected EM idx == [" + (Integer.parseInt(sel_devNum[i]) - 2) + "]");
if (sSelCtrl_Action != null) {
if (sSelCtrl_Action.equalsIgnoreCase("off")) {
result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, false);
} else {
int nColor = 0;
if (sSelCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
else if (sSelCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
if (nColor > 0) {
result = mSdbAPI.SetLightOnOff((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, true);
result = mSdbAPI.SetLightDimming((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) 10); // 밝기 최대
result = mSdbAPI.SetLightColor((byte) (Integer.parseInt(sel_devNum[i]) - 2), (byte) 0xFF, (byte) nColor);
}
}
}
// 그 외 방 조명 제어 결과
if (result < 0) {
Log.w(TAG, "[iCMDProcEntireLightControl] SEL EM Light Control FAIL !!!");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
}
}
// ============================== 선택안된 조명 ==============================
items = ele.getElementsByTagName("unsel_ctrlinfo");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
sUnselCtrl_Action = trimquotation(attr.getNodeValue());
Log.d(TAG, "[iCMDProcEntireLightControl] sUnselCtrl_Action [" + sUnselCtrl_Action + "]");
}
if (!bLivingLightSel) {
Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected Living EM ==");
if (sUnselCtrl_Action != null) {
if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, false);
} else {
int nColor = 0;
if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
if (nColor > 0) {
result = mSdb_LivingRoomLightAPI.SetLightOnOff(define.DEVICE_ALL_OR_NOTHING, true);
result = mSdb_LivingRoomLightAPI.SetLightDimming(define.DEVICE_ALL_OR_NOTHING, (byte) 10); // 밝기 최대
result = mSdb_LivingRoomLightAPI.SetLightColor(define.DEVICE_ALL_OR_NOTHING, (byte) nColor);
}
}
}
if (result < 0) {
Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL Living Light Control FAIL !!!");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
}
ArrayList unsel_devNum = new ArrayList<>();
// Log.d(TAG, "[iCMDProcEntireLightControl] BadRoom_Em_Count [" + mSdbAPI.data.BadRoom_Em_Count + "]");
for (int i = 0; i < mSdbAPI.data.BadRoom_Em_Count; i++) {
unsel_devNum.add(i + 1);
}
for (int i = 0; i < unsel_devNum.size(); i++) {
for (int j = 0; j < sel_devNum.length; j++) {
if (unsel_devNum.get(i) == Integer.parseInt(sel_devNum[j]) - 1)
unsel_devNum.remove(i);
}
}
for (int i = 0; i < unsel_devNum.size(); i++) {
Log.d(TAG, "[iCMDProcEntireLightControl] == Unselected EM idx == [" + (unsel_devNum.get(i) - 1) + "]");
if (sUnselCtrl_Action.equalsIgnoreCase("off")) {
result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, false);
} else {
int nColor = 0;
if (sUnselCtrl_Action.equalsIgnoreCase("yellow")) nColor = 1;
else if (sUnselCtrl_Action.equalsIgnoreCase("white")) nColor = 10;
if (nColor > 0) {
result = mSdbAPI.SetLightOnOff((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, true);
result = mSdbAPI.SetLightDimming((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) 10); // 밝기 최대
result = mSdbAPI.SetLightColor((byte) (unsel_devNum.get(i) - 1), (byte) 0xFF, (byte) nColor);
}
}
if (result < 0) {
Log.w(TAG, "[iCMDProcEntireLightControl] UNSEL EM Light Control FAIL !!!");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
}
Log.i(TAG, "[iCMDProcEntireLightControl] === Entire Light Control SUCCESS !!! ===");
retStr += " result=\"ok\">\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
} else {
Log.w(TAG, "[iCMDProcEntireLightControl] sDong [" + sDong + "], sHo [" + sHo + "], addc.Dong [" + addc.Dong + "], addc.Ho [" + addc.Ho + "]");
retStr += " result=\"fail\" >\r\n";
retStr += " \r\n";
retStr += " \r\n";
return retStr;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcEntireLightControl(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
// 월패드에 원격제어 사용 여부를 확인하다.
private String CheckiCMDProc(String CMDStr) {
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
try {
boolean bRemoteCtrlEnabled = mWallpadStatusData.GetRemoteControl();
mWallpadStatusData.closeDB();
if (!bRemoteCtrlEnabled) {
String retXML = XMLHeader + "\r\n" +
" \r\n";
return retXML;
}
return null;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
mWallpadStatusData.closeDB();
return null;
} catch (Exception e) {
mWallpadStatusData.closeDB();
Log.e(TAG, "[Exception] CheckiCMDProc(String CMDStr)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
//메인으로 공지 해야 할 노티 사항을 처리
public String ProcEventNotify(Element ele) {
try {
NodeList items = ele.getElementsByTagName("event");
Node item = items.item(0);
Node text = item.getFirstChild();
String eventTXT = trimquotation(text.getNodeValue());
if (eventTXT.equalsIgnoreCase("news_arrival")) {
// 새로운 공지사항 존재
wakeupLCD();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
getApplicationContext().sendBroadcast(intent);
} else if (eventTXT.equalsIgnoreCase("box_arrival")) {
// 택배 도착
wakeupLCD();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
intent.putExtra(define.NOTIBR_CONTENT, "parcel_in");
intent.putExtra("REMAIN_CNT", 1);
getApplicationContext().sendBroadcast(intent);
} else if (eventTXT.equalsIgnoreCase("box_delivered")) {
// 택배 반출
wakeupLCD();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEPARCEL);
intent.putExtra(define.NOTIBR_CONTENT, "customer_receive");
intent.putExtra("REMAIN_CNT", 0);
getApplicationContext().sendBroadcast(intent);
} else if (eventTXT.equalsIgnoreCase("car_arrival")) {
// 등록된 차량 도착
wakeupLCD();
// 팝업을 띄우도록 하자
Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
Common.CarInOoutEventBR(getApplicationContext(), "car_in", "");
} else if (eventTXT.equalsIgnoreCase("elevator_arrived")) {
// 내려가는 방향의 엘리베이터가 도착함
if (ElevatorDown != null) {
ElevatorDown.TimeOutCancel();
ElevatorDown.ClearElevator();
}
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_DOWN);
getApplicationContext().sendBroadcast(intent);
} else if (eventTXT.equalsIgnoreCase("elevator_arrived_up")) {
// 올라가는 방향의 엘리베이터가 도착함
if (ElevatorUp != null) {
ElevatorUp.TimeOutCancel();
ElevatorUp.ClearElevator();
}
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ELE_ARRIVAL_UP);
getApplicationContext().sendBroadcast(intent);
} else {
}
String returnStr = XMLHeader + "\r\n" +
" \"" + eventTXT + "\" \r\n" + " \r\n ";
return returnStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcEventNotify(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String GetAttributeVal(Node node, String attname) {
NamedNodeMap attrs = node.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase(attname)) return attr.getNodeValue();
}
return null;
}
public class imageFileFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (name.endsWith(".jpg") || name.endsWith(".JPG") || name.endsWith(".jpeg") || name.endsWith(".JPEG") || name.endsWith(".png") || name.endsWith(".PNG") || name.endsWith(".gif") || name.endsWith(".GIF"))
return true;
else return false;
}
}
public String ProcCheckEpiceUpload(Document ele) {
try {
String returnStr = XMLHeader + "\r\n";
NodeList items = ele.getElementsByTagName("filename");
Node item = items.item(0);
Node text = item.getFirstChild();
String filename = trimquotation(text.getNodeValue());
Log.i(TAG, "[ProcCheckEpiceUpload] filename [" + filename + "]");
String duplicate = null;
Log.i(TAG, "[ProcCheckEpiceUpload] E-Frame Location [" + define.ALBUM_PICTURE_LOCATION + "]");
File dirInternal = new File(define.ALBUM_PICTURE_LOCATION);
if (!dirInternal.exists()) dirInternal.mkdir();
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
AddressSet addr = SetData.getAddressMGR();
if (!dirInternal.exists()) {
returnStr += " \r\n" +
" \r\n" +
" \r\n";
return returnStr;
}
imageFileFilter jpegfilter = new imageFileFilter();
String[] subfile = dirInternal.list(jpegfilter);
Log.i(TAG, "[ProcCheckEpiceUpload] File path [" + define.ALBUM_PICTURE_LOCATION + filename + "]");
File checkFile = new File(define.ALBUM_PICTURE_LOCATION + filename);
if (checkFile.exists()) duplicate = "exist";
else duplicate = "new";
if (subfile != null) {
returnStr += " \r\n" +
" \r\n" +
" \r\n";
}
SetData.closeDB();
return returnStr;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcCheckEpiceUpload(Document ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private void playNotifySound(int nSoundID) {
try {
PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
Log.i(TAG, "[playNotifySound] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
if (getCompareBSPVersion()) {
if (!checkLCDOnByCMD()) mIOInterface.ctrlLcdWakeUp();
} else {
if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
}
boolean NeedPlay = false;
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
if (nSoundID == WpadSound.SND.mode.CAR_ARRIVED) {
NeedPlay = SetData.GetCarSoundOfEventAlarm();
} else {
NeedPlay = SetData.GetSoundOutputOfEventAlarm();
}
SetData.closeDB();
if (NeedPlay) Sound().PlayMent(nSoundID);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] playNotifySound(int nSoundID)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void wakeupLCD() {
try {
// PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
// Log.i(TAG, "[wakeupLCD] mPowerManager.isScreenOn() = " + mPowerManager.isScreenOn());
// if (!mPowerManager.isScreenOn()) mIOInterface.ctrlLcdWakeUp();
WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
int AlarmStatus = WsDB.GetAlarmStatus();
WsDB.closeDB();
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.GUARD_OUT || AlarmStatus == WallpadStatusData.GUARD_OUT_WAIT) {
Log.w(TAG, "[wakeupLCD] wakeupLCD denied!!! === AlarmStatus [" + AlarmStatus + "]");
return; // 방범 설정되어 있는 경우 알림 팝업이 출력되지 않으므로 LCD ON 하지 않음
} else {
Log.d(TAG, "[wakeupLCD] wakdupLCD!!!");
mIOInterface.ctrlLcdWakeUp();
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] wakeupLCD()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* LCD backlight off시 센서값 keyevent가 발생하지 않는 증상 해결을 위한 임시코드
* 우선 IHN-1020B-I에만 적용 후, 결과를 보고 다른 일체형 월패드에도 적용 예정
* Jeff, 2020.09.07
*
* @return true: LCD backlight On, false: LCD backlight Off
*/
public boolean checkLCDOnByCMD() {
try {
Runtime mRuntime = Runtime.getRuntime();
Process mProcess;
String cmd = "getprop persist.sys.lcdcon";
mProcess = mRuntime.exec(cmd);
BufferedReader br = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
String line;
String strResult = null;
while ((line = br.readLine()) != null) {
strResult = line;
}
if (strResult != null) {
if (strResult.equals("0")) {
Log.e(TAG, "[checkLCDOnByCMD] LCD On");
return true;
} else if (strResult.equals("1")) {
Log.e(TAG, "[checkLCDOnByCMD] LCD Off");
return false;
} else {
Log.e(TAG, "[checkLCDOnByCMD] Unknown value [" + strResult + "], return false!!!");
return false;
}
} else
return false;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] checkLCDOnByCMD()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
/**
* 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
* BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
*
* @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
*/
public boolean getCompareBSPVersion() {
try {
StringBuilder strBSPVersion = new StringBuilder();
StringBuffer sysInfoBuffer = new StringBuffer();
sysInfoBuffer.append(Build.DISPLAY);
strBSPVersion.append(sysInfoBuffer.toString());
String result = strBSPVersion.toString();
Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
Date date = simpleDateFormat.parse(result);
Date standardDate = simpleDateFormat.parse("2020.09.18"); // 비교 기준 BSP 버전
if (date.compareTo(standardDate) >= 0) {
Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
return true;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getCompareBSPVersion()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return false;
}
public String ProcUpdateWeather(Document ele) {
String resultstr = XMLHeader + " \r\n ";
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("location")) nowloc = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("loc_code"))
nowlcode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("pub_date")) nowdate = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("text")) nowtext = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("code")) nowcode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("temperature"))
nowtemp = attr.getNodeValue();
}
items = ele.getElementsByTagName("week");
String weekdate = "", weektext = "", weekcode = "", weeklow = "", weekhigh = "", weekam = "", weekpm = "";
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
WeatherTable Weathertbl = DBMGR.GetWeatherTableController();
Weathertbl.InitWeatherTable();
for (int i = 0; i < items.getLength(); i++) {
item = items.item(i);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("date")) weekdate = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("text"))
weektext = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("code"))
weekcode = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("low")) weeklow = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("high"))
weekhigh = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("am")) weekam = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("pm")) weekpm = attr.getNodeValue();
}
if (i == 0) {
nowlo = weeklow;
nowhigh = weekhigh;
}
Weathertbl.AddWeatherData(weekdate, weektext, weekcode, weeklow, weekhigh, weekam, weekpm);
}
//WeatherTable weadertbl = new DBMGR.GetWeatherTableController();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEWEATHER);
intent.putExtra(define.NOTIBR_CONTENT, nowcode + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
getApplicationContext().sendBroadcast(intent);
String WeatherVer = nowdate.substring(0, 4) + "." + nowdate.substring(4, 6) + "." + nowdate.substring(6, 8) + "." + nowdate.substring(8, 10);
DBMGR.SetWeatherVer(WeatherVer + define.DEVCTR_DATA_SPLITER + nowloc + define.DEVCTR_DATA_SPLITER + nowlcode + define.DEVCTR_DATA_SPLITER + nowcode + define.DEVCTR_DATA_SPLITER + nowtext + define.DEVCTR_DATA_SPLITER + nowtemp + define.DEVCTR_DATA_SPLITER + nowlo + define.DEVCTR_DATA_SPLITER + nowhigh);
//air
items = ele.getElementsByTagName("air");
String airpm10 = "", airpm25 = "", airco2 = "", airozone = "", air_index = "";
item = items.item(0);
if (item != null) {
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("pm10")) airpm10 = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("pm25"))
airpm25 = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("co2"))
airco2 = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("ozone"))
airozone = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("air_index"))
air_index = attr.getNodeValue();
}
Intent intentAir = new Intent();
intentAir.setAction(define.NOTIFY_ACNAME);
intentAir.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATEAIR);
getApplicationContext().sendBroadcast(intentAir);
DBMGR.SetAirData(airpm10 + define.DEVCTR_DATA_SPLITER + airpm25 + define.DEVCTR_DATA_SPLITER + airco2 + define.DEVCTR_DATA_SPLITER + airozone + define.DEVCTR_DATA_SPLITER + air_index);
}
DBMGR.closeDB();
return resultstr += "\"ok\"/> \r\n ";
}
//iMAP update_news 처리
public String ProcUpdateNews(Document ele) {
NodeList items = ele.getElementsByTagName("ver_news");
Node item = items.item(0);
String strNewsVer = item.getTextContent();
strNewsVer = trimquotation(strNewsVer);
String retXML = XMLHeader + "\r\n" +
" \"" + strNewsVer + "\"\r\n\r\n";
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
String NotiVer = DBMGR.GetNoticeVer();
int noticeCNT = DBMGR.GetNoticeCNT();
if (!NotiVer.substring(0, 11).equals(strNewsVer.substring(0, 11))) {
String[] spdt = strNewsVer.split("[.]");
noticeCNT += Integer.parseInt(spdt[spdt.length - 1]);
} else {
String[] spdt = strNewsVer.split("[.]");
int newcnt = Integer.parseInt(spdt[spdt.length - 1]);
spdt = NotiVer.split("[.]");
newcnt -= Integer.parseInt(spdt[spdt.length - 1]);
noticeCNT += newcnt;
}
Log.d(TAG, "[ProcUpdateNews] NotiVer [" + NotiVer + "], News Version [" + strNewsVer + "]");
DBMGR.SetNoticeVer(strNewsVer);
DBMGR.SetNoticeCNT(noticeCNT);
DBMGR.closeDB();
if (NotiVer.compareTo(strNewsVer) != 0) {
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_UPDATENOTICE);
intent.putExtra(define.NOTIBR_CONTENT, strNewsVer);
getApplicationContext().sendBroadcast(intent);
}
return retXML;
}
//iMAP check_lobby_passwd 처리
public String CheckPassword(Document doc) {
NodeList items = doc.getElementsByTagName("inpasswd");
Node item = items.item(0);
Node text = item.getFirstChild();
String passwd = trimquotation(text.getNodeValue());
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
String settedpasswd = DBMGR.GetUserPW();
DBMGR.closeDB();
String retString = XMLHeader;
Common.DebugLog("================ CheckPassword ================ ");
Common.DebugLog("Saved Password :" + settedpasswd);
Common.DebugLog("Input Password :" + passwd);
Common.DebugLog("================ CheckPassword ================ ");
if (settedpasswd.equals(passwd)) {
retString += "\r\n";
} else {
retString += "\r\n" + passwd + "\r\n";
}
retString += "";
return retString;
}
//schedule_renew 처리
protected String ProcSchduleRenew(Document doc) {
String retXML = XMLHeader + " \r\n " +
" \r\n \r\n ";
WallpadScheduleData schedulDB = null;
try {
NodeList items = doc.getElementsByTagName("renew_info");
schedulDB = new WallpadScheduleData(getApplicationContext());
for (int i = 0; i < items.getLength(); i++) {
Node item = items.item(i);
WallpadScheduleData.ScheduleData SCdata = new WallpadScheduleData.ScheduleData();
NamedNodeMap attrsParam = item.getAttributes();
String Type = "none";
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
String name = attr.getNodeName();
String Val = attr.getNodeValue();
if (attr.getNodeName().equalsIgnoreCase("rn_num"))
SCdata.inqnum = Integer.parseInt(attr.getNodeValue());
else if (name.equalsIgnoreCase("rn_type"))
Type = Val;
else if (name.equalsIgnoreCase("rn_t_type"))
SCdata.inqttype = Val;
else if (name.equalsIgnoreCase("rn_c_type"))
SCdata.inqctype = Val;
else if (name.equalsIgnoreCase("rn_a_type"))
SCdata.inqatype = Val;
else if (name.equalsIgnoreCase("rn_i_type"))
SCdata.inqitype = Val;
else if (name.equalsIgnoreCase("rn_year"))
SCdata.inqyear = Integer.parseInt(Val);
else if (name.equalsIgnoreCase("rn_month"))
SCdata.inqmonth = Integer.parseInt(Val);
else if (name.equalsIgnoreCase("rn_day"))
SCdata.inqday = Integer.parseInt(Val);
else if (name.equalsIgnoreCase("rn_hour"))
SCdata.inqhour = Integer.parseInt(Val);
else if (name.equalsIgnoreCase("rn_message"))
SCdata.inqmsg = Val;
}
if (Type.equals("delete")) {
schedulDB.DeleteSchedule(SCdata);
} else if (Type.equals("add")) {
schedulDB.AddSchedule(SCdata);
} else if (Type.equals("change")) {
schedulDB.UpdateSchedule(SCdata);
}
}
schedulDB.closeDB();
// yskim 2014.11.17 일정관리 단지 연동 메세지가 들어올때 처리구분 우선 삭제
// Intent intent = new Intent();
// intent.setAction(define.NOTIFY_ACNAME);
// intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
// intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SCHEDULER);
// getApplicationContext().sendBroadcast(intent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
if (schedulDB != null) schedulDB.closeDB();
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
if (schedulDB != null) schedulDB.closeDB();
}
return retXML;
}
//schedule_inquiry 처리
@SuppressWarnings("unused")
public String ProcSchduleInquiry(Document doc) {
WallpadScheduleData schedulDB = null;
String retXML;
int QYear = 0;
int QMonth = 0;
try {
NodeList items = doc.getElementsByTagName("inquiry_time");
schedulDB = new WallpadScheduleData(getApplicationContext());
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("year"))
QYear = Integer.parseInt(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("month"))
QMonth = Integer.parseInt(attr.getNodeValue());
}
List SCData = schedulDB.NewGetScheduleData(QYear, QMonth);
retXML = XMLHeader + "\r\n" +
" \r\n" +
" \r\n" +
" " + SCData.size() + "\r\n";
if (SCData != null) {
if (SCData.size() > 0) {
for (int i = 0; i < SCData.size(); i++) {
WallpadScheduleData.ScheduleData SCINQDATA = SCData.get(i);
retXML += "\r\n";
}
}
retXML += "\r\n";
} else {
retXML = XMLHeader + "\r\n" +
" \r\n" +
" \r\n" +
" 0 \r\n\r\n";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + "\r\n" +
" \r\n" +
" \r\n" +
" 0 \r\n\r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + "\r\n" +
" \r\n" +
" \r\n" +
" 0 \r\n\r\n";
}
schedulDB.closeDB();
return retXML;
}
public String ProcUpdateSchedule(Element ele, String type) {
String retXML = "";
return retXML;
}
public final String WALLPAD_MAIN_LAUNCHER_PACKAGE = "kr.co.icontrols.icwallpadmain";
public final String WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY = "kr.co.icontrols.icwallpadmain.MainActivity";
private void setDefaultLauncher() {
try {
PackageManager pm = getPackageManager();
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
filter.addCategory(Intent.CATEGORY_DEFAULT);
Context context = getApplicationContext();
ComponentName component = new ComponentName(WALLPAD_MAIN_LAUNCHER_PACKAGE, WALLPAD_MAIN_LAUNCHER_PACKAGE_ACTIVITY);
ComponentName[] components = new ComponentName[]{new ComponentName("com.android.launcher", "com.android.launcher2.Launcher"), component};
pm.clearPackagePreferredActivities("com.android.launcher");
pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_EMPTY, components, component);
Log.d(TAG, "$$$$$$$$$ Default Launcher icwallpadmain !!!! ");
try {
Thread.sleep(300);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
// 리셋코드 추가
//try{mGleInterface.sendResetSignal();}catch(Exception e){e.printStackTrace();}
try {
PowerManager powerMg = (PowerManager) getSystemService(Context.POWER_SERVICE);
powerMg.reboot(null);
Log.d(TAG, "$$$$$$$$$ PowerManager reboot !!!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
Log.d(TAG, "$$$$$$$$$ Reset !!!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public String ProcDeviceReset(Element ele) {
String retXML = XMLHeader + "\r\n" +
"\r\n";
NodeList resettype = ele.getElementsByTagName("guidemap");
Node resettypeItem = resettype.item(0);
String type = GetAttributeVal(resettypeItem, "type");
if (type != null) {
if (type.equals("now")) {
setDefaultLauncher();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
getApplicationContext().sendBroadcast(intent);
} else if (type.equals("disable")) {
WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
SetReset.SetResetSchedule(WallpadStatusData.RESET_FREE, 0, 0);
SetReset.closeDB();
} else if (type.equals("week") || type.equals("month")) {
int Resettype = type.equals("week") ? WallpadStatusData.RESET_WEEK : WallpadStatusData.RESET_MONTH;
NodeList periodList = ele.getElementsByTagName("period");
Node perioditem = periodList.item(0);
int cycle = Integer.parseInt(GetAttributeVal(perioditem, "cycle"));
int time = Integer.parseInt(GetAttributeVal(perioditem, "time"));
WallpadStatusData SetReset = new WallpadStatusData(getApplicationContext());
SetReset.SetResetSchedule(Resettype, cycle, time);
SetReset.closeDB();
}
}
// yskim 2014. 리셋 관련 스케줄러 호출 우선 삭제
// Intent intent = new Intent();
// intent.setAction(define.NOTIFY_ACNAME);
// intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_SCHEDULEUPDATED);
// intent.putExtra("ITEM", MainActivity.ScheduleManager.SCHEDULE_TYPE_SYSRESET);
// getApplicationContext().sendBroadcast(intent);
return retXML;
}
public String ProcDeviceLiveCheck() {
String retXML = XMLHeader + "\r\n";
return retXML;
}
public String ProcPairingHdevSyncAlarm(Element ele) {
String retXML = XMLHeader + "\r\n";
return retXML;
}
public String ProcPairingHdevSyncSecurity(Element ele) {
String retXML = XMLHeader + "\r\n";
return retXML;
}
public String ProcParkInformation(Element ele) {
try {
Log.d(TAG, "[ProcParkInformation] ========== START ==========");
String retXML = XMLHeader + " \r\n";
String strName = null, strDong = null, strHo = null, strCarMove = null, strCarNo = null, strCarLocation = null, strMsg = null;
NodeList items = ele.getElementsByTagName("destination");
Node item = items.item(0);
Node text;
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("name"))
strName = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_high"))
strDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_low"))
strHo = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("move_info");
item = items.item(0);
text = item.getFirstChild();
strCarMove = trimquotation(text.getNodeValue());
items = ele.getElementsByTagName("params");
item = items.item(0);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("car_num"))
strCarNo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("loc_info"))
strCarLocation = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("message"))
strMsg = trimquotation(attr.getNodeValue());
}
if (strName != null && strDong != null && strHo != null && strCarMove != null && strCarNo != null && strCarLocation != null && strMsg != null)
Log.d(TAG, "[ProcParkInformation] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCarMove [" + strCarMove + "], strCarNo [" + strCarNo + "], strCarLocation [" + strCarLocation + "], strMsg [" + strMsg + "]");
try {
int iTempDong = Integer.parseInt(AddrDong);
String sTempDong = Integer.toString(iTempDong);
int iTempHo = Integer.parseInt(AddrHo);
String sTempHo = Integer.toString(iTempHo);
if ((strName != null && strName.equalsIgnoreCase("homedev") == true) && (strDong != null && strDong.equalsIgnoreCase(sTempDong) == true) && (strHo != null && strHo.equalsIgnoreCase(sTempHo) == true)) {
Log.d(TAG, "ProcParkInformation Input EMData is Correct");
} else {
Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
retXML = XMLHeader + " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
return retXML;
}
//DB정보 업데이트!
WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
CarDB.UpdateParkInfo(strCarMove, strCarNo, strCarLocation, strMsg);
CarDB.closeDB();
//DB정보 업데이트!
if (strCarMove.equalsIgnoreCase("in")) {
// playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
// 팝업을 띄우도록 하자
wakeupLCD();
if (strMsg != null && strMsg.equalsIgnoreCase("guest")) {
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.ARRIVED_CAR);
iIntent.putExtra(Common.BR_CAR_EVENT_GUEST, true);
getApplicationContext().sendBroadcast(iIntent);
} else {
Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
}
Log.d(TAG, "[ProcParkInformation] Common.CarInOoutEventBR ");
Common.CarInOoutEventBR(getApplicationContext(), "car_in", strCarNo);
}
if ((MainActivity.bUseofNot_ParkingInfo == true) && (MainActivity.nParkingSystemType == Common.PARKING_SYSTEM_IES_100)) {
if (strCarMove.equalsIgnoreCase("park")) {
//주차정보 얻어오도록 intent 알림
SendGetParkingInfoIntent();
}
} else {
//주차정보 얻어오도록 intent 알림
SendGetParkingInfoIntent();
//20분 후에 한번 더 주차정보 얻어오도록 intent 전송
SendParkingInfoIntentAfter20min.sendEmptyMessageDelayed(0, (1000 * 60 * 20));
}
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] ProcParkInformation(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
/**
* 스마트키 이벤트 수신시 처리
**/
public String ProcSmartKeyEvent(Element ele) {
Log.d(TAG, "[ProcSmartKeyEvent] ========== START ==========");
String retXML = XMLHeader + " \r\n";
String strName = null, strDong = null, strHo = null, strCnt = null;
String strEventType = null, strEventTriggerType = null, strEventUID = null, strEventSN = null, strEventSitecode = null, strEventDong = null, strEventHo = null;
String strEventCardNo = null, strEventIssueCnt = null, strEventCardType = null, strEventLocation = null;
NodeList items = ele.getElementsByTagName("destination");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("name"))
strName = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_high"))
strDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_low"))
strHo = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("event_info");
item = items.item(0);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("info_cnt"))
strCnt = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("event");
item = items.item(0);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("event_type"))
strEventType = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("trigger_type"))
strEventTriggerType = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("uid"))
strEventUID = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("sn"))
strEventSN = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("sitecode"))
strEventSitecode = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("dong"))
strEventDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
strEventHo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("card_num"))
strEventCardNo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("issue_cnt"))
strEventIssueCnt = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("card_type"))
strEventCardType = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("location"))
strEventLocation = trimquotation(attr.getNodeValue());
}
if (strName != null && strDong != null && strHo != null && strCnt != null)
Log.i(TAG, "[ProcSmartKeyEvent] strName [" + strName + "], strDong [" + strDong + "], strHo [" + strHo + "], strCnt [" + strCnt + "]");
Log.i(TAG, "[ProcSmartKeyEvent] strEventType [" + strEventType + "], strEventTriggerType [" + strEventTriggerType + "], strEventUID [" + strEventUID + "], strEventSN [" + strEventSN + "], strEventSitecode [" + strEventSitecode + "], strEventDong [" + strEventDong + "], strEventHo [" + strEventHo + "]");
Log.i(TAG, "[ProcSmartKeyEvent] strEventCardNo [" + strEventCardNo + "], strEventIssueCnt [" + strEventIssueCnt + "], strEventCardType [" + strEventCardType + "], strEventLocation [" + strEventLocation + "]");
if ((strName != null && strName.equalsIgnoreCase("homedev")) && (strDong != null && strDong.equalsIgnoreCase(AddrDong)) && (strHo != null && strHo.equalsIgnoreCase(AddrHo))) {
Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Correct");
} else {
Log.d(TAG, "[ProcSmartKeyEvent] Input EMData is Wrong");
retXML = XMLHeader + " \r\n";
return retXML;
}
//데이터가 null인지 확인
if ((strEventType == null) || (strEventDong == null) || (strEventHo == null) || (strEventLocation == null) || (strEventCardNo == null)) {
return retXML;
}
if (strEventType.equalsIgnoreCase("emergency")) { // 비상알람이 맞으면 아래 사항 처리
if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
wakeupLCD();
// 팝업을 띄우도록 하자
String CardNum = "";
try {
int iEvent_Dong = Integer.parseInt(strEventDong);
CardNum += String.format("%04d", iEvent_Dong);
int iEvent_Ho = Integer.parseInt(strEventHo);
CardNum += String.format("%04d", iEvent_Ho);
int iEvent_CardNum = Integer.parseInt(strEventCardNo);
CardNum += String.format("%03d", iEvent_CardNum);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
return retXML;
}
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, Common.BR_MAIN_NOTI.SMARTKEY_ALARM_BR);
iIntent.putExtra("LOCATION", strEventLocation);
iIntent.putExtra("CARD_NO", CardNum);
getApplicationContext().sendBroadcast(iIntent);
}
}
} else if (strEventType.equalsIgnoreCase("position")) { // 위치인식의 경우 밴드위치인식 알림 팝업
if ((strEventDong.equalsIgnoreCase(AddrDong)) && (strEventHo.equalsIgnoreCase(AddrHo))) {
if ((strEventTriggerType.equalsIgnoreCase("zigbee")) || (strEventTriggerType.equalsIgnoreCase("ble"))) {
int nCardNum;
try {
nCardNum = Integer.parseInt(strEventCardNo);
Log.d(TAG, "[ProcSmartKeyEvent] nCardNum [" + nCardNum + "]");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
return retXML;
}
WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
boolean bBandUse = deviceSet.getBandLocationUsage();
deviceSet.closeDB();
if (bBandUse) { // 밴드위치인식 사용 설정인 경우에만 팝업 출력
wakeupLCD();
Intent iIntent = new Intent();
iIntent.setAction(BR_MAIN_NOTI.ACNAME_MAIN_NOTI);
iIntent.putExtra(BR_MAIN_NOTI.KIND, BR_MAIN_NOTI.UI_BANDLOCATION_ALARM);
iIntent.putExtra(BR_MAIN_NOTI.CARD_NUM, nCardNum);
getApplicationContext().sendBroadcast(iIntent);
}
}
}
}
return retXML;
}
public String ProcParkInformation_cham_upis(Element ele) {
Log.d(TAG, "ProcParkInformation_cham_upis START");
String retXML = XMLHeader + " \r\n";
String infoName = null;
String infoDong = null;
String infoHo = null;
String infoCarMove = null;
String infoCarnum = null;
String infoCarLocation = null;
String infoMessage = null;
NodeList items = ele.getElementsByTagName("home_info");
Node item = items.item(0);
Node text;
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("dong"))
infoDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
infoHo = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("park_info");
item = items.item(0);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("car_info"))
infoCarnum = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("location_2"))
infoCarLocation = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("message"))
infoMessage = trimquotation(attr.getNodeValue());
}
Log.d(TAG, "ProcParkInformation infoName :" + infoName);
if (infoDong != null)
Log.d(TAG, "ProcParkInformation infoDong :" + infoDong);
Log.d(TAG, "ProcParkInformation infoHo :" + infoHo);
Log.d(TAG, "ProcParkInformation infoCarMove :" + infoCarMove);
Log.d(TAG, "ProcParkInformation infoCarnum :" + infoCarnum);
Log.d(TAG, "ProcParkInformation infoCarLocation :" + infoCarLocation);
Log.d(TAG, "ProcParkInformation infoMessage :" + infoMessage);
if ((infoDong != null && infoDong.equalsIgnoreCase(AddrDong) == true) &&
(infoHo != null && infoHo.equalsIgnoreCase(AddrHo) == true)) {
Log.d(TAG, "ProcParkInformation Input EMData is Correct");
} else {
Log.d(TAG, "ProcParkInformation Input EMData is Wrong");
retXML = XMLHeader + " \r\n";
return retXML;
}
infoCarMove = "park";
//DB정보 업데이트!
WallpadCarEventInfo CarDB = new WallpadCarEventInfo(getApplicationContext());
CarDB.UpdateParkInfo(infoCarMove, infoCarnum, infoCarLocation, infoMessage);
CarDB.closeDB();
//DB정보 업데이트!
Intent iIntent = new Intent();
iIntent.setAction(define.NOTIFY_ACNAME);
iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
this.sendBroadcast(iIntent);
/*
if( infoCarMove.equals("IN") || infoCarMove.equals("in"))
{
playNotifySound(WpadSound.SND.mode.CAR_ARRIVED);
// 팝업을 띄우도록 하자
Common.SendBRMainNoti(getApplicationContext(), Common.BR_MAIN_NOTI.ARRIVED_CAR);
}
*/
return retXML;
}
public String ProcGetSmartKeyInfo(Element ele) {
List SyncData = new ArrayList();
List NewData = new ArrayList();
String retXML = XMLHeader + " \r\n";
NodeList items = ele.getElementsByTagName("info_type");
Node item = items.item(0);
Node text = item.getFirstChild();
String sInfo_type = trimquotation(text.getNodeValue());
String sCard_info = null;
String sMessage = null;
if (sInfo_type.equalsIgnoreCase("uid")) //uid 정보로 다른정보를 요청
{
items = ele.getElementsByTagName("uid_info");
item = items.item(0);
text = item.getFirstChild();
sCard_info = trimquotation(text.getNodeValue());
//==============================================//
items = ele.getElementsByTagName("message");
item = items.item(0);
text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
//==============================================//
//쿼리문 작성
WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
for (int i = 0; i < SyncData.size(); i++) {
if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
NewData.add(SyncData.get(i));
}
}
wallpadSmartKeyRegData.closeDB();
} else if (sInfo_type.equalsIgnoreCase("sn")) //s/n 정보로 다른정보를 요청
{
items = ele.getElementsByTagName("sn_info");
item = items.item(0);
text = item.getFirstChild();
sCard_info = trimquotation(text.getNodeValue());
//==============================================//
items = ele.getElementsByTagName("message");
item = items.item(0);
text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
//==============================================//
//쿼리문 작성
WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
for (int i = 0; i < SyncData.size(); i++) {
if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
NewData.add(SyncData.get(i));
}
}
wallpadSmartKeyRegData.closeDB();
} else if (sInfo_type.equalsIgnoreCase("uid_all")) // 해당 uid카드가 속해있는 그룹의 모든 카드정보 요청
{
items = ele.getElementsByTagName("uid_info");
item = items.item(0);
text = item.getFirstChild();
sCard_info = trimquotation(text.getNodeValue());
//==============================================//
items = ele.getElementsByTagName("message");
item = items.item(0);
text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
//==============================================//
//쿼리문 작성
WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
for (int i = 0; i < SyncData.size(); i++) {
if (SyncData.get(i).Uid.equalsIgnoreCase(sCard_info) == true) {
NewData.add(SyncData.get(i));
}
}
if (NewData.size() > 0) {
NewData = SyncData;
}
wallpadSmartKeyRegData.closeDB();
} else if (sInfo_type.equalsIgnoreCase("sn_all")) // 해당 sn카드가 속해있는 그룹의 모든 카드정보 요청
{
items = ele.getElementsByTagName("sn_info");
item = items.item(0);
text = item.getFirstChild();
sCard_info = trimquotation(text.getNodeValue());
//==============================================//
items = ele.getElementsByTagName("message");
item = items.item(0);
text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
//==============================================//
//쿼리문 작성
WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
for (int i = 0; i < SyncData.size(); i++) {
if (SyncData.get(i).SerialNumber.equalsIgnoreCase(sCard_info) == true) {
NewData.add(SyncData.get(i));
}
}
if (NewData.size() > 0) {
NewData = SyncData;
}
wallpadSmartKeyRegData.closeDB();
} else if (sInfo_type.equalsIgnoreCase("hkey")) {
String dong = "";
String ho = "";
String Num = "all";
//==============================================//
items = ele.getElementsByTagName("message");
item = items.item(0);
text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
//==============================================//
items = ele.getElementsByTagName("hkey_info");
item = items.item(0);
if (item == null)
return retXML = XMLHeader + " \r\n";
NamedNodeMap attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("dong"))
dong = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("ho"))
ho = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("num"))
Num = attr.getNodeValue();
}
if (!((dong.equalsIgnoreCase(AddrDong) == true) && (ho.equalsIgnoreCase(AddrHo)))) {
Log.d(TAG, "ProcGetSmartKeyInfo : Wrong Dong or Ho :" + dong + "-" + ho);
return retXML = XMLHeader + " \r\n";
}
//쿼리문 작성
int intNum = 0;
WallpadSmartKeyRegData wallpadSmartKeyRegData = new WallpadSmartKeyRegData(getApplicationContext());
SyncData = wallpadSmartKeyRegData.GetSmartKeyRegData();
for (int i = 0; i < SyncData.size(); i++) {
if (Num.equalsIgnoreCase("all") == true) {
NewData.add(SyncData.get(i));
} else {
try {
intNum = Integer.parseInt(Num);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return retXML = XMLHeader + " \r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return retXML = XMLHeader + " \r\n";
}
if (SyncData.get(i).id == intNum) {
NewData.add(SyncData.get(i));
}
}
}
wallpadSmartKeyRegData.closeDB();
} else if (sInfo_type.equalsIgnoreCase("dkey")) {
return retXML = XMLHeader + "\r\n ";
} else if (sInfo_type.equalsIgnoreCase("mkey")) {
return retXML = XMLHeader + "\r\n ";
}
if (NewData.size() == 0) {
retXML = XMLHeader + " \r\n";
retXML += " \"hkey\"\r\n";
retXML += " \r\n";
retXML += " \r\n";
retXML += " \r\n";
return retXML;
}
retXML += " \"hkey\"\r\n";
retXML += " \r\n";
for (int i = 0; i < NewData.size(); i++) {
Date date = new Date(NewData.get(i).RegDateCal.getTimeInMillis());
SimpleDateFormat sFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
String strFormat = sFormat.format(date);
retXML += " \r\n";
}
retXML += " \r\n";
return retXML;
}
public void ProcMobileDevice_AuthNumber(Element ele) {
String sDong = null;
String sHo = null;
String sIP = null;
String sType = null;
String sDevice_Name = null;
String sTwinID = null;
String sAuthNumber = null;
try {
NodeList items = ele.getElementsByTagName("home_info");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("dong"))
sDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
sHo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ip"))
sIP = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("type"))
sType = trimquotation(attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) && (sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
items = ele.getElementsByTagName("device_info");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("alias"))
sDevice_Name = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
sTwinID = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("auth_number"))
sAuthNumber = trimquotation(attr.getNodeValue());
}
/**데이터 전달**/
Log.d(TAG, "sDevice_Name :" + sDevice_Name);
Log.d(TAG, "sTwinID :" + sTwinID);
Log.d(TAG, "sAuthNumber :" + sAuthNumber);
Intent intent = new Intent();
intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
intent.putExtra("KIND", WallpadMobileDeviceData.AUTH_NUMBER);
intent.putExtra("AuthNumber", sAuthNumber);
if (NewServerUse()) {
getApplicationContext().sendBroadcast(intent);
}
} else {
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public String ProcMobileDevice_ADD_Finish(Element ele) {
String retXML = "";
String sDong = null;
String sHo = null;
String sIP = null;
String sType = null;
String sDevice_Name = null;
String sTwinID = null;
try {
NodeList items = ele.getElementsByTagName("home_info");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("dong"))
sDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
sHo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ip"))
sIP = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("type"))
sType = trimquotation(attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
(sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
(sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
items = ele.getElementsByTagName("device_info");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("alias"))
sDevice_Name = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
sTwinID = trimquotation(attr.getNodeValue());
}
/**데이터 전달**/
Log.d(TAG, "sDevice_Name :" + sDevice_Name);
Log.d(TAG, "sTwinID :" + sTwinID);
Intent intent = new Intent();
intent.setAction(WallpadMobileDeviceData.MobileDeviceAdd_BR);
intent.putExtra("KIND", WallpadMobileDeviceData.ADD_FINISH);
if (NewServerUse()) {
getApplicationContext().sendBroadcast(intent);
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
String tempType = "main";
//DB에 저장 필요
WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
if (wallpadMobileDeviceData.GetMobileDeviceData().size() >= 100) // 모바일 기기 최대 사용자 수 100개로 늘림
{
wallpadMobileDeviceData.closeDB();
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
wallpadMobileDeviceData.Register(sTwinID, sDevice_Name);
wallpadMobileDeviceData.closeDB();
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
retXML += " \r\n";
retXML += " \r\n";
return retXML;
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public void ProcMobileDevice_Delete(Element ele) {
String sDong = null;
String sHo = null;
String sIP = null;
String sType = null;
String sDevice_Name = null;
String sTwinID = null;
Log.d(TAG, "ProcMobileDevice_Delete");
try {
NodeList items = ele.getElementsByTagName("home_info");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("dong"))
sDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
sHo = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ip"))
sIP = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("type"))
sType = trimquotation(attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) &&
(sHo != null && sHo.equalsIgnoreCase(addc.Ho) == true) &&
(sIP != null && sIP.equalsIgnoreCase(addc.IPAddress) == true)) {
if (NewServerUse()) {
WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
items = ele.getElementsByTagName("device_info");
for (int i = 0; i < items.getLength(); i++) {
item = items.item(i);
attrsParam = item.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("alias"))
sDevice_Name = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
sTwinID = trimquotation(attr.getNodeValue());
}
Log.d(TAG, "sDevice_Name :" + sDevice_Name);
Log.d(TAG, "sTwinID :" + sTwinID);
wallpadMobileDeviceData.DeleteEachUid(sTwinID); //DB에서 삭제
}
wallpadMobileDeviceData.closeDB();
Intent intent = new Intent();
intent.setAction(WallpadMobileDeviceData.MobileDeviceDel_BR);
getApplicationContext().sendBroadcast(intent);
}
} else {
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public String ProcGetAppVersionInfo() {
String retXML = "";
MainDatabaseManager mDBM = new MainDatabaseManager(getApplicationContext(), null, null);
int AppCount;
AppCount = MainDatabaseManager.SETTING_ITEM_APP_WALLPADAPPUPDATER - MainDatabaseManager.SETTING_ITEM_APP_BASE + 1;
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
for (int i = 0; i < AppCount; i++) {
String getString[] = mDBM.getAppVersionData(MainDatabaseManager.SETTING_ITEM_APP_BASE + i);
if (getString != null) {
retXML += " \r\n";
}
}
retXML += " \r\n";
return retXML;
}
public String ProcIgateInitInfo(Element ele) {
String retXML = "";
String ctrl_baudrate = "";
String ctrl_open = "";
String ctrl_framecheck = "";
String ctrl_message = "";
String eth_mode = "";
String eth_ip = "";
String eth_mac = "";
String eth_gw = "";
String eth_sm = "";
String noti_send = "";
String noti_level = "";
String noti_ip = "";
String noti_port = "";
try {
NodeList items = ele.getElementsByTagName("ctrl_param");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("ctrl_baudrate"))
ctrl_baudrate = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ctrl_open"))
ctrl_open = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ctrl_framecheck"))
ctrl_framecheck = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ctrl_message"))
ctrl_message = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("eth_param");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("eth_mode"))
eth_mode = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("eth_ip"))
eth_ip = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("eth_mac"))
eth_mac = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("eth_gw"))
eth_gw = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("eth_sm"))
eth_sm = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("noti_param");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("noti_send"))
noti_send = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("noti_level"))
noti_level = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("noti_ip"))
noti_ip = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("noti_port"))
noti_port = trimquotation(attr.getNodeValue());
}
wallpaddbmgr WallpadDBMGR = null;
WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
int RowCount_GatewayData = WallpadDBMGR.RowCountLH_GatewayData();
if (RowCount_GatewayData > 100) {
WallpadDBMGR.DeleteLH_GatewayData("50");
}
WallpadDBMGR.InsertLH_GatewayData(ctrl_baudrate, ctrl_open, ctrl_framecheck, ctrl_message, eth_mode, eth_ip, eth_mac, eth_gw, eth_sm, noti_send, noti_level, noti_ip, noti_port);
WallpadDBMGR.closeDB();
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcElecCarChargeEventInfo(Element ele) {
Log.i(TAG, "[ProcElecCarChargeEventInfo] ========== START ==========");
String retXML = "";
String sName = "", sId_High = "", sId_Low = "", sCard_Num = "", sCar_Num = "", sCharger_Num = "", sCharger_Loc = "", sCharging_Status = "", sCharger_sort = "", sCharging_Ratio = "";
String sStart_Time = "", sRemain_Time = "", sMessage = "";
try {
NodeList items = ele.getElementsByTagName("destination");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("name"))
sName = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_high"))
sId_High = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_low"))
sId_Low = trimquotation(attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((sName.equalsIgnoreCase("homedev")) && (sId_High.equalsIgnoreCase(addc.Dong)) && (sId_Low.equalsIgnoreCase(addc.Ho))) {
items = ele.getElementsByTagName("charging_info");
item = items.item(0);
attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (!((attr.getNodeName().equalsIgnoreCase("card_num")) ||
(attr.getNodeName().equalsIgnoreCase("car_num")) ||
(attr.getNodeName().equalsIgnoreCase("charger_num")) ||
(attr.getNodeName().equalsIgnoreCase("charger_loc")) ||
(attr.getNodeName().equalsIgnoreCase("charging_status")) ||
(attr.getNodeName().equalsIgnoreCase("charger_sort")) ||
(attr.getNodeName().equalsIgnoreCase("charging_ratio")) ||
(attr.getNodeName().equalsIgnoreCase("start_time")) ||
(attr.getNodeName().equalsIgnoreCase("remain_time")) ||
(attr.getNodeName().equalsIgnoreCase("c_msg"))
)) {
Log.w(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
if (attr.getNodeName().equalsIgnoreCase("card_num"))
sCard_Num = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("car_num"))
sCar_Num = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("charger_num"))
sCharger_Num = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("charger_loc"))
sCharger_Loc = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("charging_status")) {
sCharging_Status = trimquotation(attr.getNodeValue());
if (!((sCharging_Status.equalsIgnoreCase("start")) ||
(sCharging_Status.equalsIgnoreCase("charging")) ||
(sCharging_Status.equalsIgnoreCase("full")) ||
(sCharging_Status.equalsIgnoreCase("charged")) ||
(sCharging_Status.equalsIgnoreCase("stop")) ||
(sCharging_Status.equalsIgnoreCase("service_out")) ||
(sCharging_Status.equalsIgnoreCase("check")) ||
(sCharging_Status.equalsIgnoreCase("commerror"))
)) {
Log.w(TAG, "sCharging_Status is wrong :" + sCharging_Status);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} else if (attr.getNodeName().equalsIgnoreCase("charger_sort")) {
sCharger_sort = trimquotation(attr.getNodeValue());
if (!((sCharger_sort.equalsIgnoreCase("slow")) ||
(sCharger_sort.equalsIgnoreCase("fast")) ||
(sCharger_sort.equalsIgnoreCase("no_info"))
)) {
Log.d(TAG, "sCharger_sort is wrong :" + sCharger_sort);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} else if (attr.getNodeName().equalsIgnoreCase("charging_ratio"))
sCharging_Ratio = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("start_time"))
sStart_Time = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("remain_time"))
sRemain_Time = trimquotation(attr.getNodeValue());
}
items = ele.getElementsByTagName("message");
item = items.item(0);
Node text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
/**데이터 전달**/
Log.d(TAG, "[ProcElecCarChargeEventInfo] sCard_Num [" + sCard_Num + "], sCharger_Num [" + sCharger_Num + "], sCharger_Loc [" + sCharger_Loc + "], sCharging_Status [" + sCharging_Status + "]");
Log.d(TAG, "[ProcElecCarChargeEventInfo] sCharger_sort [" + sCharger_sort + "], sCharging_Ratio [" + sCharging_Ratio + "], sStart_Time [" + sStart_Time + "], sRemain_Time [" + sRemain_Time + "], sMessage [" + sMessage + "]");
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_ELEC_CHARGE);
intent.putExtra("sCard_Num", sCard_Num);
intent.putExtra("sCar_Num", sCar_Num);
intent.putExtra("sCharger_Num", sCharger_Num);
intent.putExtra("sCharger_Loc", sCharger_Loc);
intent.putExtra("sCharging_Status", sCharging_Status);
intent.putExtra("sCharger_sort", sCharger_sort);
intent.putExtra("sCharging_Ratio", sCharging_Ratio);
intent.putExtra("sStart_Time", sStart_Time);
intent.putExtra("sRemain_Time", sRemain_Time);
intent.putExtra("sMessage", sMessage);
WallpadDeviceSet devDB = null;
devDB = new WallpadDeviceSet(getApplicationContext());
int retInt = -1;
retInt = devDB.GetDeviceSetted("전기차충전");
devDB.closeDB();
if (retInt == WallpadDeviceSet.DEV_DATA_ENABLE) {
getApplicationContext().sendBroadcast(intent);
}
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
retXML += " \r\n";
return retXML;
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcEnergyTargetInfoAlarm(Element ele) {
String retXML = "";
String sName = "";
String sId_High = "";
String sId_Low = "";
String vName[];
String vTarget[];
String vTarget_Cost[];
String vUsed[];
String vUsed_Cost[];
String vPredict[];
String vPredict_Cost[];
String vAlarm_info[];
String vRead_Date[];
String vRead_Day[];
String vV_Msg[];
String sMessage = "";
try {
NodeList items = ele.getElementsByTagName("source");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("name"))
sName = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_high"))
sId_High = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("id_low"))
sId_Low = trimquotation(attr.getNodeValue());
}
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
if ((sName.equalsIgnoreCase("home") == true) &&
(sId_High.equalsIgnoreCase(addc.Dong) == true) &&
(sId_Low.equalsIgnoreCase(addc.Ho) == true)) {
items = ele.getElementsByTagName("valuelist");
Log.d(TAG, "items.getLength() :" + items.getLength());
vName = new String[items.getLength()];
vTarget = new String[items.getLength()];
vTarget_Cost = new String[items.getLength()];
vUsed = new String[items.getLength()];
vUsed_Cost = new String[items.getLength()];
vPredict = new String[items.getLength()];
vPredict_Cost = new String[items.getLength()];
vAlarm_info = new String[items.getLength()];
vRead_Date = new String[items.getLength()];
vRead_Day = new String[items.getLength()];
vV_Msg = new String[items.getLength()];
for (int j = 0; j < items.getLength(); j++) {
Log.d(TAG, "j :" + j);
item = items.item(j);
attrsParam = item.getAttributes();
Log.d(TAG, "attrsParam :" + attrsParam);
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (!((attr.getNodeName().equalsIgnoreCase("name") == true) ||
(attr.getNodeName().equalsIgnoreCase("target") == true) ||
(attr.getNodeName().equalsIgnoreCase("target_cost") == true) ||
(attr.getNodeName().equalsIgnoreCase("used") == true) ||
(attr.getNodeName().equalsIgnoreCase("used_cost") == true) ||
(attr.getNodeName().equalsIgnoreCase("predict") == true) ||
(attr.getNodeName().equalsIgnoreCase("predict_cost") == true) ||
(attr.getNodeName().equalsIgnoreCase("alarm_info") == true) ||
(attr.getNodeName().equalsIgnoreCase("read_date") == true) ||
(attr.getNodeName().equalsIgnoreCase("read_day") == true) ||
(attr.getNodeName().equalsIgnoreCase("v_msg") == true)
)) {
Log.d(TAG, "attr.getNodeName() is wrong :" + attr.getNodeName());
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
if (attr.getNodeName().equalsIgnoreCase("name")) {
vName[j] = trimquotation(attr.getNodeValue());
if (!((vName[j].equalsIgnoreCase("elect") == true) ||
(vName[j].equalsIgnoreCase("water") == true) ||
(vName[j].equalsIgnoreCase("gas") == true) ||
(vName[j].equalsIgnoreCase("heating") == true) ||
(vName[j].equalsIgnoreCase("hotwater") == true)
)) {
Log.d(TAG, "vName[j] is wrong :" + vName[j]);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} else if (attr.getNodeName().equalsIgnoreCase("target"))
vTarget[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("target_cost"))
vTarget_Cost[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("used"))
vUsed[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("used_cost"))
vUsed_Cost[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("predict"))
vPredict[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("predict_cost"))
vPredict_Cost[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("alarm_info")) {
vAlarm_info[j] = trimquotation(attr.getNodeValue());
if (!((vAlarm_info[j].equalsIgnoreCase("near") == true) ||
(vAlarm_info[j].equalsIgnoreCase("reach") == true) ||
(vAlarm_info[j].equalsIgnoreCase("over") == true)
)) {
Log.d(TAG, "vAlarm_info[j] is wrong :" + vAlarm_info[j]);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} else if (attr.getNodeName().equalsIgnoreCase("read_date")) {
vRead_Date[j] = trimquotation(attr.getNodeValue());
if (!((vRead_Date[j].equalsIgnoreCase("read_day") == true) ||
(vRead_Date[j].equalsIgnoreCase("last_day") == true)
)) {
Log.d(TAG, "vRead_Date[j] is wrong :" + vRead_Date[j]);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} else if (attr.getNodeName().equalsIgnoreCase("read_day"))
vRead_Day[j] = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("v_msg"))
vV_Msg[j] = trimquotation(attr.getNodeValue());
}
}
items = ele.getElementsByTagName("message");
item = items.item(0);
Node text = item.getFirstChild();
sMessage = trimquotation(text.getNodeValue());
/**데이터 전달**/
for (int i = 0; i < vName.length; i++) {
Log.d(TAG, "vName[" + i + "]: " + vName[i]);
Log.d(TAG, "vTarget" + i + "]: " + vTarget[i]);
Log.d(TAG, "vTarget_Cost[" + i + "]: " + vTarget_Cost[i]);
Log.d(TAG, "vUsed[" + i + "]: " + vUsed[i]);
Log.d(TAG, "vUsed_Cost[" + i + "]: " + vUsed_Cost[i]);
Log.d(TAG, "vPredict[" + i + "]: " + vPredict[i]);
Log.d(TAG, "vPredict_Cost[" + i + "]: " + vPredict_Cost[i]);
Log.d(TAG, "vAlarm_info[" + i + "]: " + vAlarm_info[i]);
Log.d(TAG, "vRead_Date[" + i + "]: " + vRead_Date[i]);
Log.d(TAG, "vRead_Day[" + i + "]: " + vRead_Day[i]);
Log.d(TAG, "vV_Msg[" + i + "]: " + vV_Msg[i]);
}
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_ENERGY_TARGET_INFO_ALARM_FROM_SERVER);
for (int i = 0; i < vName.length; i++) {
if (vName[i].equals("elect")) {
intent.putExtra("elect_target", vTarget[i]);
intent.putExtra("elect_used", vUsed[i]);
intent.putExtra("elect_info", vAlarm_info[i]);
} else if (vName[i].equals("water")) {
intent.putExtra("water_target", vTarget[i]);
intent.putExtra("water_used", vUsed[i]);
intent.putExtra("water_info", vAlarm_info[i]);
} else if (vName[i].equals("gas")) {
intent.putExtra("gas_target", vTarget[i]);
intent.putExtra("gas_used", vUsed[i]);
intent.putExtra("gas_info", vAlarm_info[i]);
} else if (vName[i].equals("heating")) {
intent.putExtra("heating_target", vTarget[i]);
intent.putExtra("heating_used", vUsed[i]);
intent.putExtra("heating_info", vAlarm_info[i]);
} else if (vName[i].equals("hotwater")) {
intent.putExtra("hotwater_target", vTarget[i]);
intent.putExtra("hotwater_used", vUsed[i]);
intent.putExtra("hotwater_info", vAlarm_info[i]);
}
}
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
for (int i = 0; i < vName.length; i++) {
retXML += " \r\n";
}
retXML += " \"null\"\r\n";
retXML += " \r\n";
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
String[] MetringDB = devSet.GetSettingData("에너지관리서버");
devSet.closeDB();
if (MetringDB != null) {
try {
String devInfo = MetringDB[1];
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] MetringInfo = devInfo.split("_");
// MetringInfo[1] -> 회로수
// MetringInfo[3] -> 에너지관리서버 사용여부 사용함 or 사용안함
// MetringInfo[4] -> IP
// MetringInfo[5] -> IP정보
// MetringInfo[6] -> 검침일사용자설정
// MetringInfo[7] -> 사용함 또는 사용안함
if (MetringInfo[3].equals("사용함") == true) {
getApplicationContext().sendBroadcast(intent);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
} else {
}
return retXML;
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcCheckCallOption() {
int[] resultDB = {0, 0};
String retXML = "";
String sOption = "sip";
String sMessage = "null";
try {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
resultDB = devSet.Get_Handicapped_Mode();
devSet.closeDB();
if (resultDB[0] == 0) {
//장애인모드 사용 안함
} else if (resultDB[0] == 1) {
//장애인모드 사용함
}
switch (resultDB[1]) {
case 0: //일반모드
sOption = "sip";
break;
case 1: //청각장애인
sOption = "deaf";
break;
case 2: //시각장애인
sOption = "blind";
break;
default:
break;
}
if (resultDB[1] == -999) // 해당 if문은 존재하지 않는 경우인데 통화불가능 상태를 위하여 임시로 만들어 놓은 코드임
{
//본 구문에 들어올수 없음
sOption = "none";
}
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
retXML += " \"" + sMessage + "\"\r\n";
retXML += " \r\n";
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcChatSequence(Element ele) {
String retXML = "";
String sFrom = "error";
String sTo = "error";
String sContact = "error";
String sSequence = "error";
String sStatus = "error";
String sMessage = "error";
String reply_Sequence = "error";
String reply_Status = "error";
String reply_Message = "null";
try {
NodeList items = ele.getElementsByTagName("sequence");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
sSequence = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("status");
item = items.item(0);
attrsParam = item.getAttributes();
sStatus = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("message");
item = items.item(0);
attrsParam = item.getAttributes();
sMessage = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("from");
item = items.item(0);
attrsParam = item.getAttributes();
sFrom = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("to");
item = items.item(0);
attrsParam = item.getAttributes();
sTo = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("contact");
item = items.item(0);
attrsParam = item.getAttributes();
sContact = trimquotation(item.getTextContent());
///////////////////////////////////////////////
if (!((sSequence.equalsIgnoreCase("try") == true) ||
(sSequence.equalsIgnoreCase("start") == true) ||
(sSequence.equalsIgnoreCase("quit") == true) ||
(sSequence.equalsIgnoreCase("cancel") == true) ||
(sSequence.equalsIgnoreCase("ok") == true) ||
(sSequence.equalsIgnoreCase("busy") == true) ||
(sSequence.equalsIgnoreCase("busy_sip") == true) ||
(sSequence.equalsIgnoreCase("reject") == true)
)) {
Log.e(TAG, "sSequence is invalid. sSequence:" + sSequence);
retXML = XMLHeader + " \r\n";
retXML += " \"" + reply_Message + "\"\r\n";
retXML += " \r\n";
return retXML;
}
if (!((sStatus.equalsIgnoreCase("idle") == true) ||
(sStatus.equalsIgnoreCase("ringing") == true) ||
(sStatus.equalsIgnoreCase("talking") == true)
)) {
Log.e(TAG, "sStatus is invalid. sStatus:" + sStatus);
retXML = XMLHeader + " \r\n";
retXML += " \"" + reply_Message + "\"\r\n";
retXML += " \r\n";
return retXML;
}
//입력값 처리 필요!!
//김용성 과장님 작업필요
//sFrom, sTo, sContact error가 아닌 경우는 정보가 없는 경우 입니다.
//확인 하시고 위 정보 확인해주세요.
Log.d(TAG, "sFrom:" + sFrom);
Log.d(TAG, "sTo:" + sTo);
Log.d(TAG, "Contact:" + sContact);
Log.d(TAG, "sSequence:" + sSequence);
Log.d(TAG, "sStatus:" + sStatus);
if (sSequence.equalsIgnoreCase("try") == true) {
//채팅 요청
} else if (sSequence.equalsIgnoreCase("start") == true) {
//채팅 시작
} else if (sSequence.equalsIgnoreCase("quit") == true) {
//채팅 종료
} else if (sSequence.equalsIgnoreCase("cancel") == true) {
//취소
} else if (sSequence.equalsIgnoreCase("ok") == true) {
//요청확인
} else if (sSequence.equalsIgnoreCase("busy") == true) {
//통화중
} else if (sSequence.equalsIgnoreCase("busy_sip") == true) {
//SIP 통화중
} else if (sSequence.equalsIgnoreCase("reject") == true) {
//거절
}
if (sStatus.equalsIgnoreCase("idle") == true) {
//대기
} else if (sStatus.equalsIgnoreCase("ringing") == true) {
//연결중
} else if (sStatus.equalsIgnoreCase("talking") == true) {
//통화중
}
//응답값 입력 필요!!
//김용성 과장님 작업필요
reply_Message = "null";
retXML = XMLHeader + " \r\n";
retXML += " \"" + reply_Message + "\"\r\n";
retXML += " \r\n";
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \"" + reply_Message + "\"\r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \"" + reply_Message + "\"\r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcChatMessage(Element ele) {
String retXML = "";
String sChatMessage = "error";
String sMessage = "error";
try {
NodeList items = ele.getElementsByTagName("chat");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
sChatMessage = trimquotation(item.getTextContent());
///////////////////////////////////////////////
items = ele.getElementsByTagName("message");
item = items.item(0);
attrsParam = item.getAttributes();
sMessage = trimquotation(item.getTextContent());
///////////////////////////////////////////////
//test
Log.d(TAG, "sChatMessage is " + sChatMessage);
Log.d(TAG, "sMessage is " + sMessage);
//test
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_HANDICAPPED_CHAT_MESSAGE);
intent.putExtra("CHAT_MESSAGE", sChatMessage);
intent.putExtra("ADD_MESSAGE", sMessage);
getApplicationContext().sendBroadcast(intent);
retXML = XMLHeader + " \r\n";
retXML += " \"" + "null" + "\"\r\n";
retXML += " \r\n";
return retXML;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
public String ProcEvacuationLadderOpen(Element ele) {
String retXML = "";
try {
String sDong = null;
String sHo = null;
NodeList items = ele.getElementsByTagName("home_info");
Node item = items.item(0);
NamedNodeMap attrsParam = item.getAttributes();
for (int i = 0; i < attrsParam.getLength(); i++) {
Node attr = attrsParam.item(i);
if (attr.getNodeName().equalsIgnoreCase("dong"))
sDong = trimquotation(attr.getNodeValue());
else if (attr.getNodeName().equalsIgnoreCase("ho"))
sHo = trimquotation(attr.getNodeValue());
}
WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
int ladderDownSend = deviceSet.getEscapeLadderDownSend();
deviceSet.closeDB();
Log.d(TAG, "[ProcEvacuationLadderOpen] ladderDownSend [" + ladderDownSend + "]");
WallpadStatusData DBMGR = null;
DBMGR = new WallpadStatusData(getApplicationContext());
AddressSet addc = DBMGR.getAddressMGR(); //DB에서 동호 정보 받아옴
DBMGR.closeDB();
String myIP = addc.IPAddress;
String DestStair = null; // 피난사다리 열림 정보 전송 목적지 (윗집 or 아랫집)
String[] SplitedString = myIP.split("\\.");
if (SplitedString != null) {
if (SplitedString.length == 4) {
int temp = Integer.parseInt(SplitedString[2]);
if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
temp = temp - 1;
else if (ladderDownSend == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
temp = temp + 1;
String tempDestStairIP = SplitedString[0] + "." + SplitedString[1] + "." + temp + "." + SplitedString[3];
Log.d(TAG, "[ProcEvacuationLadderOpen] DestStair IP address : " + tempDestStairIP);
temp = (temp * 100) + Integer.parseInt(SplitedString[3]);
DestStair = String.valueOf(temp);
}
}
if ((sDong != null && sDong.equalsIgnoreCase(addc.Dong) == true) && (sHo != null && sHo.equalsIgnoreCase(DestStair) == true)) {
/**
* 피난사다리 전송방향이 윗집인 경우, 아랫집에서 피난사다리가 열렸다고 알림을 받음.
* 피난사다리 전송방향이 아랫집인 경우, 윗집에서 피난사다리가 열렸다고 알림을 받음.
* 피난사다리 사용유무를 체크하여 intent를 발송 또는 피난사다리 비상화면으로 전환되야 함.
* **/
WallpadDeviceSet devset;
devset = new WallpadDeviceSet(getApplicationContext());
int StatusVal = devset.GetDeviceSetted("피난사다리");
devset.closeDB();
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
/**
* 피난사다리 알림!!!
* **/
ReceiveNetworkLadderBr(ladderDownSend);
}
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
private void ReceiveNetworkLadderBr(int val) {
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
int Menu_Start_Option = 1;
WallpadStatusData wdb = new WallpadStatusData(getApplicationContext());
int AlarmStatus = wdb.GetAlarmStatus();
wdb.closeDB();
boolean MgrAppRun = false;
final String packageNameMgr = "com.artncore.managersetting";
MgrAppRun = GetForegroundAPP().equals(packageNameMgr);
if (MgrAppRun)
return;
if (AlarmStatus == WallpadStatusData.ALARM_ARISE || AlarmStatus == WallpadStatusData.ALARM_STOP)
return;
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
int StatusVal = devset.GetDeviceSetted("피난사다리");
devset.closeDB();
if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
Common.SendAppFinishReqBR(getApplicationContext());
Intent newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_UPPER)
newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
else if (val == WallpadDeviceSet.ESCAPELADDER_DOWN_SEND_BELOW)
newintent.putExtra("MENU_DETAIL_INFO", "upladder_Open");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(newintent);
}
}
/**
* 스마트 분전반 상태 응답(서버 요청에 대한 응답)
*
* @param ele Element Xml 데이터
* @return String 타입의 응답 메시지 생성
**/
public String SmartLightDetailInfo(Element ele) {
iMAPSmartLightInfo imapSmartLightInfo = new iMAPSmartLightInfo(mWallPadAPI, getApplicationContext());
return imapSmartLightInfo.SmartLightDetailInfo(ele);
}
/**
* KNX 시스템 상태 응답(서버 요청에 대한 응답)
*
* @param ele Element Xml 데이터
* @return String 타입의 응답 메시지 생성
**/
public String KNXDeviceDetailInfo(Element ele) {
iMAPKNXDeviceInfo imapKNXDeviceInfo = new iMAPKNXDeviceInfo(mWallPadAPI, getApplicationContext());
return imapKNXDeviceInfo.KNXDeviceDetailInfo(ele);
}
public String ProcSetServerChange(Element ele) {
String retXML = "";
String versionTXT = null;
try {
boolean bRet = false;
NodeList items = ele.getElementsByTagName("ver_server");
Node item = items.item(0);
Node text = item.getFirstChild();
versionTXT = trimquotation(text.getNodeValue());
if (versionTXT.equalsIgnoreCase("1.0")) {
bRet = true;
} else if (versionTXT.indexOf("2.") >= 0) {
bRet = true;
}
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
if (SetData != null && bRet == true) {
SetData.SetServerVer(versionTXT);
SetData.closeDB();
}
if (bRet == true) {
try {
iMapSverReload tSock = new iMapSverReload();
tSock.start();
} catch (IOException e) {
Log.e(TAG, "[IOException] ProcSetServerChange(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 버전 체크해서
// 응답하고 나서
// 수신부 쓰레드 재 로딩..
if (versionTXT != null && bRet == true) {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} else {
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
retXML = XMLHeader + " \r\n";
retXML += " \r\n";
return retXML;
}
}
/**
* 현관 열림 명령을 내린다.
*
* @return (String) - > success : 성공, fail : 실패
*/
private String Device_DoorOpen(final int address) {
Log.i(TAG, "[Device_DoorOpen] - Start");
final ModbusClient modbusClient = new ModbusClient("10.0.215.2", 502);
modbusClient.setConnectionTimeout(5000);
try {
new Thread() {
public void run() {
try {
modbusClient.Connect();
modbusClient.WriteSingleCoil(address, true);
Thread.sleep(600);
modbusClient.WriteSingleCoil(address, false);
modbusClient.Disconnect();
} catch (IOException | ModbusException | InterruptedException e) {
e.printStackTrace();
try {
modbusClient.Disconnect();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}.start();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return "fail";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return "fail";
}
Log.i(TAG, "[Device_DoorOpen] - OK");
return "ok";
}
/**
* 현관 문열림 요청에 대한 응답
* @return String 타입의 응답 메시지 생성
**/
private long mLastClickTime = 0;
private final long MIN_CLICK_INTERVAL = 3000;
public String ProcFrontOpen() {
String oepn_result;
long currentClickTime = SystemClock.uptimeMillis();
long elapsedTime = currentClickTime - mLastClickTime;
mLastClickTime = currentClickTime;
// 연속으로 문열림 요청이 들어오는 경우를 방지하기 위한 처리. 3초안에 문열림 요청이 다시 들어오면 무시하고, fail 처리함.
if (elapsedTime < MIN_CLICK_INTERVAL) {
mLastClickTime = 0;
oepn_result = "fail";
}else{
oepn_result = Device_DoorOpen(19);
}
String retXML = XMLHeader + "\r\n \"null\"\r\n\r\n\r\n";
return retXML;
}
// 메인 서버 소켓 클래스
public class iMapSverReload extends Thread {
ServerSocket svr;
public iMapSverReload() throws IOException {
/////////////////////////////////////////////////////////////////////
// 신형 단지서버 사용 유무를 가져온다.
/////////////////////////////////////////////////////////////////////
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
if (SetData != null) {
String serverVesionInfo = SetData.GetServerVer();
SetData.closeDB();
if (serverVesionInfo == null || serverVesionInfo.equalsIgnoreCase("1.0")) {
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
boolean retValue = devset.SetSubDevListItem(false, define.DEVICE_ID_NEW_DANJI_SERVER);
devset.closeDB();
} else {
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
boolean retValue = devset.SetSubDevListItem(true, define.DEVICE_ID_NEW_DANJI_SERVER);
devset.closeDB();
}
}
try {
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
mNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
wallpadDeviceSet.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
mNewDanjiServer = false;
} catch (Exception e) {
Log.e(TAG, "[iMapSverSocket] - GetNewDanjiServer ExceptionError !!!");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
mNewDanjiServer = false;
}
Log.d(TAG, " iMapSverReload - mNewDanjiServer :" + mNewDanjiServer);
// 단지서버2.0은 로컬 단지과리서버 하나로 운영이 됨
// 신형 단지서버로 설정이 되어 있으면 관리PC IP를 10.0.1.1로 변경 해주어야 함
// 관리 PC IP도 변경하도록 한다.
if (mNewDanjiServer == true) {
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
wallpadStatusData.SetManagePC(Common.DEFAULT_SERVER_IP, Common.DEFAULT_SERVER_PORT);
wallpadStatusData.closeDB();
} else {
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
wallpadStatusData.SetManagePC(Common.DEFAULT_MANAGER_PC_IP, Common.DEFAULT_MANAGER_PC_PORT);
wallpadStatusData.closeDB();
}
Log.d(TAG, "$$$$$$$$$$$$$$ mNewDanjiServer : " + mNewDanjiServer);
}
public void run() {
try {
try {
Thread.sleep(400);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
SvrSock.destoryThread();
for (int i = 0; i < 20; i++) {
if (SvrSock.isAlive() == false) {
Log.d(TAG, " Receive Socket Reload i = : " + i);
break;
} else {
Log.d(TAG, " is Live Socket Reload i = : " + i);
}
try {
Thread.sleep(100);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
SvrSock = new iMapSverSocket();
SvrSock.start();
// 서버 교체 중에 처음으로 보내는 하트 비트 메세지
try {
Thread.sleep(3000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
try {
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_STARTHEARTBEAT);
getApplicationContext().sendBroadcast(intent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
} catch (IOException e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
public static final int SCHEDULE_START_HEARTBEAT = 30000;
public static final int SCHEDULE_CHANGE_HEARTBEAT = 30001;
public static final int SCHEDULE_START_STATUSBEAT = 30002;
public static final int SCHEDULE_CHANGE_STATUSBEAT = 30003;
public static final int SCHEDULE_START_CALLAPP = 30004;
public static final String SCHEDULE_ACTION_HEARTBEAT = "HEARTBEAT";
public static final String SCHEDULE_ACTION_STATUSBEAT = "STATUSBEAT";
public class SchedulerThread extends Thread {
boolean doRun;
AddressSet addr;
String AddressStr;
String IPaddr;
String VerBSP = "";
String VerAPP;
String VerSetting;
String VerNews;
String VerWeather;
int heartbeatP = 5; //DBMGR.GetHeartbeatPeriod();
List ScheduleList = new ArrayList();
private jni mGleInterface = null;
private final int LIVE_SIGNAL_TIME = 20;
private int m_LiveSignalCount = 0;
private int m_MainAppLiveCount = 0;
Handler ScheDuleHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case SCHEDULE_START_HEARTBEAT: {
Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_HEARTBEAT");
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
heartbeatP = DBMGR.GetHeartbeatPeriod();
DBMGR.closeDB();
reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
doSchedule(SCHEDULE_ACTION_HEARTBEAT);
}
break;
case SCHEDULE_CHANGE_HEARTBEAT:
Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_HEARTBEAT");
synchronized (ScheduleList) {
ScheduleData CheckData;
for (int i = 0; i < ScheduleList.size(); i++) {
CheckData = ScheduleList.get(i);
if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_HEARTBEAT)) {
Calendar cal = new GregorianCalendar();
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
heartbeatP = DBMGR.GetHeartbeatPeriod();
DBMGR.closeDB();
cal.add(Calendar.MINUTE, heartbeatP);
CheckData.TData = cal;
ScheduleList.set(i, CheckData);
doSchedule(SCHEDULE_ACTION_HEARTBEAT);
return;
}
}
}
reg_schedule(heartbeatP, SCHEDULE_ACTION_HEARTBEAT);
doSchedule(SCHEDULE_ACTION_HEARTBEAT);
break;
case SCHEDULE_START_STATUSBEAT:
Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_STATUSBEAT");
doSchedule(SCHEDULE_ACTION_STATUSBEAT);
break;
case SCHEDULE_CHANGE_STATUSBEAT:
Common.DebugLog("ScheDuleHandler ------ SCHEDULE_CHANGE_STATUSBEAT");
synchronized (ScheduleList) {
ScheduleData CheckData;
for (int i = 0; i < ScheduleList.size(); i++) {
CheckData = ScheduleList.get(i);
if (CheckData.ActionSTR.equals(SCHEDULE_ACTION_STATUSBEAT)) {
Calendar cal = new GregorianCalendar();
cal.add(Calendar.MINUTE, heartbeatP);
CheckData.TData = cal;
ScheduleList.set(i, CheckData);
doSchedule(SCHEDULE_ACTION_STATUSBEAT);
return;
}
}
}
break;
case SCHEDULE_START_CALLAPP:
// Common.DebugLog("ScheDuleHandler ------ SCHEDULE_START_CALLAPP");
// Bundle bundle = new Bundle();
// bundle.putInt (ITEM_CALL_TYPE, CALL_TYPE_INCOMMING);
// Intent intent = new Intent ("com.artncore.apps.ic_wallpad.CallInterface")
// .putExtra(ITEM_MENU_TYPE, FRAG_CALL)
// .putExtra(ITEM_CALL_DATA, bundle);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// iMAPstartActivity(intent);
break;
}
}
};
Handler GetHandler() {
return ScheDuleHandler;
}
public class ScheduleData {
Calendar TData;
String ActionSTR;
public ScheduleData(Calendar tdata, String ActionStr) {
TData = tdata;
ActionSTR = ActionStr;
}
}
public SchedulerThread() {
doRun = true;
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
addr = DBMGR.getAddressMGR();
VerAPP = DBMGR.GetAPPVer();
VerSetting = DBMGR.GetSettingVer();
VerNews = DBMGR.GetNoticeVer();
VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
DBMGR.closeDB();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
try {
mGleInterface = new jni();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e("iMapServer", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
}
}
if (VerAPP.equals(WallpadStatusData.APP_VER_DEFAULT)) {
VerAPP = GetAppVersion();
}
AddressStr = addr.Dong + "동" + addr.Ho + "호";
IPaddr = addr.IPAddress;
ScheDulerHandler = ScheDuleHandler;
}
public void reg_schedule(int min, String Action) {
for (int i = 0; i < ScheduleList.size(); i++) {
ScheduleData scdata = ScheduleList.get(i);
if (scdata.ActionSTR.equals(Action)) {
ScheduleList.remove(i);
break;
}
}
Calendar cal = new GregorianCalendar();
cal.add(Calendar.MINUTE, min);
ScheduleData regData = new ScheduleData(cal, Action);
synchronized (ScheduleList) {
ScheduleList.add(regData);
}
}
private void doSchedule(String doing) {
String[] doingData = doing.split(";");
if (doingData[0].equals(SCHEDULE_ACTION_HEARTBEAT)) {
try {
String SendingStr = MakeHeartbeat();
SendToServer(SendingStr);
Calendar cal = new GregorianCalendar();
String timedata = String.format("%04d", cal.get(Calendar.YEAR)) + "." + String.format("%02d", cal.get(Calendar.MONTH) + 1) + "." + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)) + "." + String.format("%02d", cal.get(Calendar.HOUR_OF_DAY)) + "." + String.format("%02d", cal.get(Calendar.MINUTE)) + "." + String.format("%02d", cal.get(Calendar.SECOND));
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
DBMGR.SetLastHeartbeat(timedata);
heartbeatP = DBMGR.GetHeartbeatPeriod();
DBMGR.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
} else if (doingData[0].equals("UPDATETIME")) {
} else if (doingData[0].equals(SCHEDULE_ACTION_STATUSBEAT)) {
// 제어기기 초기화 되기 전에 상태비트를 보내는것 스킵한다.
if (!Common.getDeviceServeiceLoadComplite()) return;
String SendingStr = MakeStatusReport();
if (SendingStr == null) return;
SendToServer(SendingStr);
Calendar cal = new GregorianCalendar();
String timedata = String.format("%04d", cal.get(Calendar.YEAR)) + "." + String.format("%02d", cal.get(Calendar.MONTH) + 1) + "." + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)) + "." + String.format("%02d", cal.get(Calendar.HOUR_OF_DAY)) + "." + String.format("%02d", cal.get(Calendar.MINUTE)) + "." + String.format("%02d", cal.get(Calendar.SECOND));
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
DBMGR.SetLastStatusbeat(timedata);
DBMGR.closeDB();
int StatusP = 720;
try {
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
String[] StatusVal = devset.GetSettingData("statusbeat_time");
devset.closeDB();
if (StatusVal == null) StatusP = 720;
else StatusP = Integer.parseInt(StatusVal[1]);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
reg_schedule(StatusP, SCHEDULE_ACTION_STATUSBEAT);
}
}
private String MakeHeartbeat() {
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
VerWeather = DBMGR.GetWeatherVer().split(define.DEVCTR_DATA_SPLITER)[0];
VerNews = DBMGR.GetNoticeVer();
VerSetting = DBMGR.GetSettingVer();
String VerServer = DBMGR.GetServerVer();
DBMGR.closeDB();
if (VerServer == null) {
Log.d(TAG, "VerServer null");
VerServer = "1.0";
}
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int nDistributionPanelType = wallpadDeviceSet.Get_DistributionPannelType_Info();
wallpadDeviceSet.closeDB();
if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
// 스마트 분전반
WallPadSmartLight wallPadSmartLight = new WallPadSmartLight(getApplicationContext());
WallPadSmartLight.AlarmClass alarmClass = wallPadSmartLight.GetHeartBeatAlarmStatus();
String retStr = XMLHeader +
"\r\n" +
"\"" + Build.DISPLAY + "\"\r\n" +
"\"" + GetAppVersion() + "\"\r\n" +
"\"" + VerSetting + "\"\r\n" +
"\"" + VerNews + "\"\r\n" +
"\"" + VerWeather + "\"\r\n" +
"\"0000.00.00.00\"\r\n" +
"\"2727.00.01.07\"\r\n" +
"\"0000.00.77.77\"\r\n" +
"\"0000.00.01.133\"\r\n" +
"" + VerServer + "\r\n" +
"" + alarmClass.GetAlarm() + "\r\n" +
"" + alarmClass.GetAlarmDevice() + "\r\n" +
"\r\n";
return retStr;
} else if (nDistributionPanelType == Version.DISTRIBUTION_MODEL.KNX_DIST) {
// TODO KNX 분전반
// String retStr = XMLHeader+
// "\r\n"+
// " \""+Build.DISPLAY+"\" \r\n"+
// " \""+GetAppVersion()+"\" \r\n"+
// "\""+VerSetting+"\"\r\n"+
// " \""+VerNews+"\" \r\n"+
// " \""+VerWeather+"\" \r\n"+
// " \"0000.00.00.00\" \r\n"+
// " \"2727.00.01.07\" \r\n"+
// " \"0000.00.77.77\" \r\n"+
// " \"0000.00.01.133\" \r\n"+
// "" + VerServer + "\r\n"+
// "\r\n" +
// "\r\n" +
// "\r\n" +
// "\r\n" +
// "\r\n" +
// "\r\n" +
// "\r\n";
String retStr = XMLHeader +
"\r\n" +
"\"" + Build.DISPLAY + "\"\r\n" +
"\"" + GetAppVersion() + "\"\r\n" +
"\"" + VerSetting + "\"\r\n" +
"\"" + VerNews + "\"\r\n" +
"\"" + VerWeather + "\"\r\n" +
"\"0000.00.00.00\"\r\n" +
"\"2727.00.01.07\"\r\n" +
"\"0000.00.77.77\"\r\n" +
"\"0000.00.01.133\"\r\n" +
"" + VerServer + "\r\n" +
"\r\n";
return retStr;
} else {
String retStr = XMLHeader +
"\r\n" +
"\"" + Build.DISPLAY + "\"\r\n" +
"\"" + GetAppVersion() + "\"\r\n" +
"\"" + VerSetting + "\"\r\n" +
"\"" + VerNews + "\"\r\n" +
"\"" + VerWeather + "\"\r\n" +
"\"0000.00.00.00\"\r\n" +
"\"2727.00.01.07\"\r\n" +
"\"0000.00.77.77\"\r\n" +
"\"0000.00.01.133\"\r\n" +
"" + VerServer + "\r\n" +
"\r\n";
return retStr;
}
}
public String GetAppVersion() {
PackageInfo pi = null;
try {
pi = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
return pi.versionName;
}
boolean isAlawaysrun = true;
public void run() {
while (/*doRun*/ isAlawaysrun) {
//Common.DebugLog("SchedulerThread ------ 10Sec");
CheckHeartBeat();
CheckStatusBeat();
CheckWallPadLiveSignal();
LiveCheckRebooting();
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
//다른층의 디바이스 정보를 받아와서 미리 가지고 있어야 한다.
if(skipCount==0) {
sendMsgToActivity(1234);
Log.d(TAG, "sendMsgToActivity!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11");
}
skipCount++;
if(skipCount==18) skipCount = 0 ;
}
try {
Thread.sleep(10000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
}
public void SetLive() {
m_MainAppLiveCount++;
}
private int CheckTime30Sec = 0;
private void LiveCheckRebooting() {
try {
CheckTime30Sec++;
if (CheckTime30Sec % 20 == 0) {
// if (Version.getModelType() == Version.MODEL_TYPE.IHN_750 || Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D) {
// // 10초마다 수행되는 함수이니....
// // 200초 정도 메인 쓰레드에서 응답이 없으면 리셋 처리하도록 한다.
// if (m_MainAppLiveCount == 0) {
// //리셋
// if( Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_C || Version.getModelType() == Version.MODEL_TYPE.IHN_1030_D )
// {
// Log.d(TAG, "Main App Down Reset IHN_1020B_C , IHN_1030_D");
// PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
// pm.userActivity(8, true);
// }
// else
// {
// Log.d(TAG, "Main App Down Reset IHN_750");
// WallPadInterface wpdifc = new WallPadInterface();
// wpdifc.WachdogSystemReset();
// }
// }
// }
CheckTime30Sec = 0;
}
if (CheckTime30Sec >= 30000) {
CheckTime30Sec = 0;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void CheckWallPadLiveSignal() {
try {
int nTime = LIVE_SIGNAL_TIME / 10;
m_LiveSignalCount++;
if (m_LiveSignalCount >= nTime) {
m_LiveSignalCount = 0;
Common.SendBRLiveChecker(getApplicationContext(), BR_MAIN_LIVE_CHECKER.IMAP_SERVER);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e("imapServer", "CheckWallPadLiveSignal Exeption :" + e);
}
}
protected void CheckStatusBeat() {
try {
WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
String statusbeatdata = WPD.GetLastStatusbeat();
WPD.closeDB();
int StatusP = 720;
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
String[] StatusVal = devset.GetSettingData("statusbeat_time");
if (StatusVal == null) StatusP = 720;
else
StatusP = Integer.parseInt(StatusVal[1]);
devset.closeDB();
if (CheckTime(statusbeatdata, StatusP)) doSchedule(SCHEDULE_ACTION_STATUSBEAT);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
protected void CheckHeartBeat() {
try {
WallpadStatusData WPD = new WallpadStatusData(getApplicationContext());
String heartbeatdata = WPD.GetLastHeartbeat();
int heartbeatPer = WPD.GetHeartbeatPeriod();
WPD.closeDB();
if (CheckTime(heartbeatdata, heartbeatPer)) doSchedule(SCHEDULE_ACTION_HEARTBEAT);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
protected boolean CheckTime(String CheckT, int period) {
Calendar last = new GregorianCalendar();
String[] timedata = CheckT.split("[.]");
last.set(Calendar.YEAR, Integer.parseInt(timedata[0]));
last.set(Calendar.MONTH, Integer.parseInt(timedata[1]) - 1);
last.set(Calendar.DAY_OF_MONTH, Integer.parseInt(timedata[2]));
last.set(Calendar.HOUR_OF_DAY, Integer.parseInt(timedata[3]));
last.set(Calendar.MINUTE, Integer.parseInt(timedata[4]));
last.add(Calendar.MINUTE, period);
Calendar checkCal = new GregorianCalendar();
//Common.DebugLog("CheckTime : " + checkCal.getTime().toString() + " , last :" + last.getTime().toString() + " , period : " + period );
if (checkCal.after(last)) // 현재시간과 마지막으로 하트비트를 보낸시간을 체크
return true;
return false;
}
}
class SendMSGToSVR extends Thread {
String sendmsg;
public SendMSGToSVR(String msg) {
sendmsg = msg;
}
public void run() {
Socket sock = null;
DataOutputStream outstream = null;
try {
// 신형 단지서버 사용 유무를 가져온다.
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
boolean bNewDanjiServer = wallpadDeviceSet.GetNewDanjiServer();
wallpadDeviceSet.closeDB();
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
SVRIP = DBMGR.GetServerIP();
port = DBMGR.GetServerPort();
DBMGR.closeDB();
/////////////////////////////////////////////////////////////////////
// 소켓 생성시 신형단지서버 미사용중일 경우 기존 코드로,
// 사용중일 경우 암호화 소켓을 생성한다.
/////////////////////////////////////////////////////////////////////
if (!bNewDanjiServer) {
sock = new Socket(SVRIP, port);
} else {
int setport = port + 1000;
Log.i(TAG, "[SendMSGToSVR] Use SslClient !!! (ip:" + SVRIP + " , port:" + setport + ")");
SSLClient sslClientSocket = new SSLClient(SVRIP, setport);
sock = sslClientSocket.getSocket();
}
/////////////////////////////////////////////////////////////////////
if (sock != null) {
sock.setSoLinger(true, 1000);
outstream = new DataOutputStream(sock.getOutputStream());
byte[] outBF = sendmsg.getBytes("euc-kr");
outstream.write(outBF);
outstream.flush();
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
} finally {
if (outstream != null) {
try {
outstream.close();
} catch (IOException e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
outstream = null;
if (sock != null) {
try {
sock.close();
} catch (IOException e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
sock = null;
}
}
}
private void SendToServer(String msg) {
SendMSGToSVR msan = new SendMSGToSVR(msg);
msan.start();
}
boolean StatusBeatRequested = false;
private String MakeStatusReport() {
try {
String ServiceType = StatusBeatRequested ? "requested" : "notice";
StatusBeatRequested = false;
String RetData = XMLHeader + " \r\n";
WallpadDevStatus SettManager = new WallpadDevStatus(getApplicationContext());
String[] typeList = SettManager.GetTypeList();
if (typeList == null || typeList.length == 0) {
DefaultProcauscultateReq(SettManager);
typeList = SettManager.GetTypeList();
}
SettManager.closeDB();
String[] ControlList;
String Vender = "null";
String devid = "null";
String Model = "null";
String subunitcnt = "null";
String statusRate = "null";
String statusType = "null";
String message = "null";
int itemCNT = 0;
int totalGroup = 0;
int totalItem = 0;
String ControlDEVList;
String ContentList = " ";
if (typeList != null) {
for (int i = 0; i < typeList.length; i++) {
if (typeList[i].equals("ctrl_device")) {
SettManager = new WallpadDevStatus(getApplicationContext());
ControlList = SettManager.GetSettingGroupData("ctrl_device");
SettManager.closeDB();
ControlDEVList = "";
if (ControlList != null) {
for (int k = 0; k < ControlList.length; k++) {
if (ControlList[k].equals("light")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int[] lightinfo = devSet.Get_Light_info();
devSet.closeDB();
if (lightinfo[0] == 1) {
if (lightinfo[1] == WallpadDeviceSet.LIGHT_TYPE_LIVING) {
subunitcnt = String.valueOf(lightinfo[2]);
LightAPI lightCTR = mWallPadAPI.Get_LightController();
devid = "0x11";
Vender = "null";
Model = "null";
if (lightCTR != null) {
lightCTR.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", lightCTR.TRInfo.RecentSuccess, (lightCTR.TRInfo.RecentSuccess + lightCTR.TRInfo.RecentFail));
double surate = lightCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
}
} else {
subunitcnt = String.valueOf(lightinfo[2]);
MultiSwitchAPI MultiSW = mWallPadAPI.Get_MultiSwitchController();
if (MultiSW != null) {
MultiSW.Refresh((byte) 0xFF, false);
byte Bdevid = 0x51;
for (int j = 0; j < MultiSW.data.DeviceCnt; j++) {
devid = String.format("0x%02X", Bdevid + j);
Vender = "null";
Model = "null";
MultiSW.TRInfo.GetTransactionList(j);
statusRate = String.format("%d/%d", MultiSW.TRInfo.RecentSuccess, (MultiSW.TRInfo.RecentSuccess + MultiSW.TRInfo.RecentFail));
double surate = MultiSW.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
ControlDEVList += " \r\n";
itemCNT++;
}
}
}
} else {
Vender = "null";
devid = "null";
Model = "null";
subunitcnt = "null";
statusRate = "null";
message = "null";
}
} else if (ControlList[k].equals("thermostat")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int ret = devSet.Get_Temper_Info();
devSet.closeDB();
if (ret == 1) {
// 난방 종류를 얻어온다.
int HeatingKind = mWallPadAPI.GetHeatingKind();
HeatingV1API heatingV1API = null;
HeatingV2API heatingV2API = null;
// 종류별 API를 로딩한다.
if (HeatingKind == 1) {
heatingV1API = mWallPadAPI.Get_HeatingV1Controller();
if (heatingV1API != null) {
subunitcnt = String.valueOf(heatingV1API.data.Device.RoomCount);
devid = "0x21";
Vender = "null";
Model = "null";
heatingV1API.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", heatingV1API.TRInfo.RecentSuccess, (heatingV1API.TRInfo.RecentSuccess + heatingV1API.TRInfo.RecentFail));
double surate = heatingV1API.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
}
} else if (HeatingKind == 2) {
heatingV2API = mWallPadAPI.Get_HeatingV2Controller();
if (heatingV2API != null) {
subunitcnt = String.valueOf(heatingV2API.data.Device.info.RoomCount);
devid = "0x28";
Vender = "null";
Model = "null";
heatingV2API.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", heatingV2API.TRInfo.RecentSuccess, (heatingV2API.TRInfo.RecentSuccess + heatingV2API.TRInfo.RecentFail));
double surate = heatingV2API.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
}
} else {
subunitcnt = "null";
devid = "null";
Vender = "null";
Model = "null";
statusRate = "0/0";
statusType = "bad";
message = "null";
}
ControlDEVList += " \r\n";
itemCNT++;
} else {
}
} else if (ControlList[k].equals("gas")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
if (devSet.Get_GAS_Info() == 1) {
//여기서 신우전자확인이 더 필요함
GasAPI GasCTR = null;//mWallPadAPI.Get_GasController();
CooktopAPI HybridCookTopCTR = null;
subunitcnt = "1";
devid = "0x31";
Vender = "null";
Model = "null";
if (mWallPadAPI.GetGasKind() == 2) {
HybridCookTopCTR = mWallPadAPI.Get_CookTopController();
if (HybridCookTopCTR != null) {
HybridCookTopCTR.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", HybridCookTopCTR.TRInfo.RecentSuccess, (HybridCookTopCTR.TRInfo.RecentSuccess + HybridCookTopCTR.TRInfo.RecentFail));
double surate = HybridCookTopCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
}
} else {
GasCTR = mWallPadAPI.Get_GasController();
if (GasCTR != null) {
GasCTR.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", GasCTR.TRInfo.RecentSuccess, (GasCTR.TRInfo.RecentSuccess + GasCTR.TRInfo.RecentFail));
double surate = GasCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
}
}
} else {
}
devSet.closeDB();
} else if (ControlList[k].equals("doorlock")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int[] doorlockInfo = devSet.Get_DoorLock_Info();
if (doorlockInfo[0] == 1) {
DLockAPI DoorCTR = mWallPadAPI.Get_DLockController();
subunitcnt = "1";
devid = "0x41";
Vender = "null";
Model = "null";
if (DoorCTR != null) {
DoorCTR.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", DoorCTR.TRInfo.RecentSuccess, (DoorCTR.TRInfo.RecentSuccess + DoorCTR.TRInfo.RecentFail));
double surate = DoorCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
}
} else {
}
devSet.closeDB();
} else if (ControlList[k].equals("ventil")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int[] ventilInfo = devSet.Get_Ventil_Info();
if (ventilInfo[0] == 1) {
VentiAPI VentilCTR = mWallPadAPI.Get_VentiController();
subunitcnt = "1";
devid = "0x61";
Vender = "null";
Model = "null";
if (VentilCTR != null) {
VentilCTR.TRInfo.GetTransactionList(0);
statusRate = String.format("%d/%d", VentilCTR.TRInfo.RecentSuccess, (VentilCTR.TRInfo.RecentSuccess + VentilCTR.TRInfo.RecentFail));
double surate = VentilCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
}
} else {
}
devSet.closeDB();
} else if (ControlList[k].equals("aircon")) {
} else if (ControlList[k].equals("curtain")) {
}
}
if (itemCNT > 0) {
ContentList += "\r\n";
ContentList += ControlDEVList;
ContentList += "\r\n";
totalGroup++;
totalItem += itemCNT;
}
}
} else if (typeList[i].equals("talk_device")) {
SettManager = new WallpadDevStatus(getApplicationContext());
ControlList = SettManager.GetSettingGroupData("talk_device");
SettManager.closeDB();
itemCNT = 0;
ControlDEVList = "";
PhonNRemocon testAPI = mWallPadAPI.Get_PhonNRemoconController();
if (testAPI != null)
testAPI.GetVersion();
if (ControlList != null) {
for (int k = 0; k < ControlList.length; k++) {
if (ControlList[k].equals("kitchen_tv") && testAPI != null) {
ControlDEVList += " \r\n";
itemCNT++;
//addResult("Bath TV : Maker - "+testAPI.BathPhone_Maker+"Model Name : "+testAPI.BathPhone_Name+" Ver : "+testAPI.BathPhone_Ver);
//addResult("Remocon : Maker - "+testAPI.Remocon_Maker+"Model Name : "+testAPI.Remocon_Name+" Ver : "+testAPI.Remocon_Ver);
} else if (ControlList[k].equals("bath_phone") && testAPI != null) {
ControlDEVList += " \r\n";
itemCNT++;
} else if (ControlList[k].equals("subhome_dev")) {
}
}
if (itemCNT > 0) {
ContentList += "\r\n";
ContentList += ControlDEVList;
ContentList += "\r\n";
totalGroup++;
totalItem += itemCNT;
}
}
} else if (typeList[i].equals("sensor")) {
SettManager = new WallpadDevStatus(getApplicationContext());
ControlList = SettManager.GetSettingGroupData("sensor");
SettManager.closeDB();
itemCNT = 0;
ControlDEVList = "";
if (ControlList != null) {
for (int k = 0; k < ControlList.length; k++) {
if (ControlList[k].equals("magnetic")) {
WallPadInterface wpifc = new WallPadInterface();
int MagSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MAG0_STATE, 0);
String SenStateCom;
String SenStateType;
if (MagSen == 1) {
SenStateCom = "1/1";
SenStateType = "";
} else {
SenStateCom = "0/1";
SenStateType = "perfect";
}
ControlDEVList += " \r\n";
itemCNT++;
} else if (ControlList[k].equals("bugout")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int sensor = devSet.Get_Sensor_Set();
devSet.closeDB();
if ((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0) {
WallPadInterface wpifc = new WallPadInterface();
int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
String SenStateCom;
String SenStateType;
if (outSen == 1) {
SenStateCom = "1/1";
SenStateType = "bad";
} else {
SenStateCom = "0/1";
SenStateType = "perfect";
}
ControlDEVList += " \r\n";
itemCNT++;
}
} else if (ControlList[k].equals("bugin")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int sensor = devSet.Get_Sensor_Set();
devSet.closeDB();
if ((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0) {
WallPadInterface wpifc = new WallPadInterface();
int InSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
String SenStateCom;
String SenStateType;
if (InSen == 1) {
SenStateCom = "1/1";
SenStateType = "bad";
} else {
SenStateCom = "0/1";
SenStateType = "perfect";
}
ControlDEVList += " \r\n";
itemCNT++;
}
} else if (ControlList[k].equals("fire")) {
//SensorList+= "\r\n";
} else if (ControlList[k].equals("gas")) {
//SensorList+= "\r\n";
}
}
if (itemCNT > 0) {
ContentList += "\r\n";
ContentList += ControlDEVList;
ContentList += "\r\n";
totalGroup++;
totalItem += itemCNT;
}
}
} else if (typeList[i].equals("extended")) {
SettManager = new WallpadDevStatus(getApplicationContext());
ControlList = SettManager.GetSettingGroupData("extended");
SettManager.closeDB();
itemCNT = 0;
ControlDEVList = "";
if (ControlList != null) {
for (int k = 0; k < ControlList.length; k++) {
if (ControlList[k].equals("gateway")) {
} else if (ControlList[k].equals("handy")) {
} else if (ControlList[k].equals("smartswitch")) {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
int[] BatchInfo = devSet.Get_BatchSW_Info();
devSet.closeDB();
if (BatchInfo[0] == 1 && BatchInfo[1] == WallpadDeviceSet.BATCH_TYPE_SMART) {
SmartSwitchPolAPI SmartSWCTR = mWallPadAPI.Get_SmartSwitchPolController();
SmartSWCTR.TRInfo.GetTransactionList(0);
subunitcnt = "1";
statusRate = String.format("%d/%d", SmartSWCTR.TRInfo.RecentSuccess, (SmartSWCTR.TRInfo.RecentSuccess + SmartSWCTR.TRInfo.RecentFail));
double surate = SmartSWCTR.TRInfo.GetSuccessRate(false);
statusType = surate > 70 ? "good" : surate > 30 ? "notgood" : "bad";
message = "null";
ControlDEVList += " \r\n";
itemCNT++;
} else {
}
} else if (ControlList[k].equals("energymeter")) {
}
}
if (itemCNT > 0) {
ContentList += "\r\n";
ContentList += ControlDEVList;
ContentList += "\r\n";
totalGroup++;
totalItem += itemCNT;
}
}
}
}
SettManager.closeDB();
ContentList += " \r\n";
RetData += " \r\n";
RetData += ContentList;
String LogSet;
LogSet = "\r\n";
RetData += LogSet;
try {
WallpadStatusData WsDB = new WallpadStatusData(getApplicationContext());
String[] ResetData = WsDB.GetResetSchedule();
WsDB.closeDB();
if (!ResetData[0].equals("NONE")) {
int type = Integer.parseInt(ResetData[0]);
if (type == WallpadStatusData.RESET_MONTH)
LogSet = "\r\n";
else if (type == WallpadStatusData.RESET_WEEK)
LogSet = "\r\n";
else
LogSet = "\r\n";
} else
LogSet = "\r\n";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
LogSet = "\r\n";
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
LogSet = "\r\n";
}
RetData += LogSet;
RetData += "\r\n\r\n";
}
return RetData;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private String getKNXDeviceStatus(int device) {
WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
String status = knxHeartbeat.getStatus();
Log.d(TAG, "[getKNXDeviceCauseCnt] status [" + status + "]");
return status;
}
private String getKNXDeviceCause(int device) {
WallPadKNX wallPadKNX = new WallPadKNX(getApplicationContext());
WallPadKNX.KNX_HEARTBEAT knxHeartbeat = wallPadKNX.GetHeartBeatAlarmStatus(device);
String cause = knxHeartbeat.getCause();
Log.d(TAG, "[getKNXDeviceCause] cause [" + cause + "]");
return cause;
}
//mWallPadAPI
// private String TAG = "*yskim*";
//private IGW200dAPI iGW200dAPI = null;
/**
* (임시코드) GW 초기생성시 Connect 에 시간이 걸리며,
* WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에,
* 본 딜레이 코드를 임시로 적용한다.
*/
@SuppressLint("HandlerLeak")
protected Handler IGW200APICheckHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
if (mWallPadAPI != null) {
Common.DebugLog("handleMessage what 0 ");
if (mWallPadAPI.Check_Connect())
IGW200APICheckHandler.sendEmptyMessageDelayed(1, 10);
else IGW200APICheckHandler.sendEmptyMessageDelayed(0, 10);
}
} else if (msg.what == 1) {
Common.DebugLog("handleMessage what 1 ");
setIGE200Interface();
}
}
};
public void setIGE200Interface() {
try {
Common.DebugLog("setIGE200Interface");
mIGW200 = new IGW200(this, mWallPadAPI);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] setIGE200Interface()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* (임시코드) GW 초기생성시 Connect 에 시간이 걸리며,
* WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에,
* 본 딜레이 코드를 임시로 적용한다.
*/
@SuppressLint("HandlerLeak")
protected Handler IGW300APICheckHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
if (mWallPadAPI != null) {
Common.DebugLog("handleMessage what 0 ");
if (mWallPadAPI.Check_Connect())
IGW300APICheckHandler.sendEmptyMessageDelayed(1, 10);
else IGW300APICheckHandler.sendEmptyMessageDelayed(0, 10);
}
} else if (msg.what == 1) {
Common.DebugLog("handleMessage what 1 ");
setIGE300Interface();
}
}
};
public void setIGE300Interface() {
try {
Common.DebugLog("setIGE300Interface");
mIGW300 = new IGW300(this, mWallPadAPI);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] setIGE300Interface()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 외출모드 연동
private void ModeRunCtrlWorking(boolean WallpadUI, boolean BedMode) {
try {
bSmartSwitch485ComebackMode = false;
String[] mOutModeTextContents = {"엘리베이터호출", "일괄소등", "가스닫기", "난방외출모드", "환기끄기", "쿡탑콘센트차단"};
WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
String outLinkCtrl = wd.GetOutModeLinkDevice();
if (BedMode == true)
outLinkCtrl = wd.GetInBedLinkDevice();
wd.closeDB();
// 엘레비에터 호출은 외출 실행시 바로 실행이 되어야 하므로....화면에서 외출모드 실행시에는 바로 실행하도록 하고 여기서는 다른제어기기에서 바로 외출모드 실행이 될 때 처리 되도록 한다.
if (WallpadUI == false) {
if (outLinkCtrl.indexOf(mOutModeTextContents[0]) >= 0) // 엘리베이터 호출
{
Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[0]);
CallElevatorBtn(false);
}
}
if (outLinkCtrl.indexOf(mOutModeTextContents[1]) >= 0) // 일괄소등 처리
{
Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[1]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, false);
}
if ((outLinkCtrl.indexOf(mOutModeTextContents[2]) >= 0) || (outLinkCtrl.indexOf(mOutModeTextContents[5]) >= 0)) // 가스 닫기
{
Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[2]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.GAS, false);
}
if (outLinkCtrl.indexOf(mOutModeTextContents[3]) >= 0 || outLinkCtrl.indexOf("난방일시정지") >= 0) // 난방 외출모드
{
Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[3]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, true);
}
if (outLinkCtrl.indexOf(mOutModeTextContents[4]) >= 0) // 환기끄기
{
Log.d("YSKIM", "OutModeCtrlWorking : " + mOutModeTextContents[4]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, false);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e("YSKIM", e.toString());
}
}
// 대외 현장 외출방범 모드일때 스마트 스위치로 이미 제어기기 연동 복귀 처리한경우.
// 사용자가 월패드에서 다시 방범 복귀 처리를 하는경우에 제어기기를 또 복귀 처리를 할 수 있기 때문에 방지 처리
private boolean bSmartSwitch485ComebackMode = false;
private void ModeReleaseCtrlWorking(boolean bBedMode) {
try {
if (bSmartSwitch485ComebackMode == true) return;
String[] mCombackHomeTextContents = {"일괄소등해제", "환기동작", "난방외출모드해제", "웰컴조명"};
WallpadStatusData wd = new WallpadStatusData(getApplicationContext());
String ComeBackLinkCtrl = wd.GetComeBackLinkDevice();
if (bBedMode == true) ComeBackLinkCtrl = wd.GetOutBedLinkDevice();
wd.closeDB();
if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[0]) >= 0) {
// 일괄소등 해제
Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[0]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.ALL_LIGHT, true);
}
if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[1]) >= 0) {
// 환기동작
Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[1]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.VENTI, true);
}
if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[2]) >= 0 || ComeBackLinkCtrl.indexOf("난방일시정지해제") >= 0) {
// 난방 외출모드 해제
Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[2]);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.HEATING, false);
}
if (ComeBackLinkCtrl.indexOf(mCombackHomeTextContents[3]) >= 0) {
// 웰컴조명 켜기
Log.d(TAG, "[ModeReleaseCtrlWorking] ComeBackCtrlWorking : " + mCombackHomeTextContents[3]);
// 웰컴조명 Handler 실행
WelcomeLightHandler.sendEmptyMessageDelayed(0, 2000);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "Exception] ModeReleaseCtrlWorking(boolean bBedMode)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private Handler WelcomeLightHandler = new Handler() {
int LightOnCount = 0;
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
try {
if (LightOnCount == 0) {
Log.d("TAG", "[WelcomeLightHandler] - START !!!");
}
// 일괄소등 해제이면
if (mWallPadAPI.GetBatchSwitchStatus() == 1) {
Log.d(TAG, "WELCOME LIGHT HANDLER - DO ON !!!");
WelcomeLightHandler.sendEmptyMessageDelayed(1, 50);
} else {
WelcomeLightHandler.sendEmptyMessageDelayed(0, 100);
LightOnCount++;
Log.d("TAG", "[WelcomeLightHandler] - WAIT : " + LightOnCount);
if (LightOnCount > 10) {
Log.d("TAG", "[WelcomeLightHandler] - OVER 10 TIME !!!");
LightOnCount = 0;
WelcomeLightHandler.sendEmptyMessageDelayed(2, 100); // 10회 초과시 중지.
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e1) {
Log.e(TAG, "[WelcomeLightHandler] - MSG 0 EXCEPTION !!!");
//e1.printStackTrace();
LogUtil.errorLogInfo("", TAG, e1);
}
} else if (msg.what == 1) {
try {
Log.d("TAG", "[WelcomeLightHandler] - Run Light On !!! : " + LightOnCount);
mWallPadAPI.DeviceBatchControl(WallPadAPI.DEV_BATCH_CTRL__TYPE.WELCOME_LIGHT, true);
LightOnCount = 0;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e1) {
Log.e(TAG, "[WelcomeLightHandler] - MSG 1 EXCEPTION !!!");
//e1.printStackTrace();
LogUtil.errorLogInfo("", TAG, e1);
}
} else if (msg.what == 2) {
// Do Nothing
Log.d("TAG", "[WelcomeLightHandler] - STOP !!!");
WelcomeLightHandler.removeMessages(0);
}
}
};
//방범 및 알람 상태 확인 Resume 시 처리
private void CheckMainStatus() {
//try {Thread.sleep(100);}catch (RuntimeException re) {LogUtil.errorLogInfo("", TAG, re);}catch (Exception e){e.printStackTrace();}
try {
final String packageName = "com.artncore.apps.ic_wallpad";
final String packageNameMgr = "kr.co.icontrols.wallpadoutmoderun";
//CallAppRun = getForegroundAPK().equals(packageName);
boolean OutModeRunAppRun = GetForegroundAPP().equals(packageNameMgr);
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
int alarmstate = SetData.GetAlarmStatus();
SetData.closeDB();
Log.d("iMap", "CheckMainStatus Check status : " + alarmstate);
if (alarmstate == WallpadStatusData.ALARM_NONE) {
Log.d("iMap", "CheckMainStatus Check status : ALARM_NONE");
return;
} else if (alarmstate == WallpadStatusData.ALARM_ARISE) {
if (GetForegroundAPP().equals("kr.co.icontrols.wallpademergency")) return;
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41, base + 51};
int Menu_Start_Id = 0;
SetData = new WallpadStatusData(getApplicationContext());
int alarmtype = SetData.GetAlarmType();
SetData.closeDB();
switch (alarmtype) {
case WallpadStatusData.ALARM_ALERT:
Menu_Start_Id = Menu_Id_List[1];
break;
case WallpadStatusData.ALARM_EMM:
Menu_Start_Id = Menu_Id_List[0];
break;
case WallpadStatusData.ALARM_EVAC:
Menu_Start_Id = Menu_Id_List[3];
break;
case WallpadStatusData.ALARM_INVADE:
Menu_Start_Id = Menu_Id_List[2];
break;
case WallpadStatusData.ALARM_HEATING_LEAK:
Menu_Start_Id = Menu_Id_List[4];
break;
default:
Menu_Start_Id = Menu_Id_List[1];
break;
}
if (Menu_Start_Id > 0) {
/*
* 비상어플이 실행중인 상태에서 통화 등의 이유로 비상화면이 종료된 경우,
* 해당 동작이 종료되면 메인어플에서 비상상태를 검사하여 비상어플을 실행시킨다.
* 이때, 비상어플이 비상발생 iMAP 메시지를 재전송하는 일이 없도록 하기 위해
* "RESUME"을 전달한다.
*/
Intent newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", 1); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "재로딩");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(newintent);
return;
}
} else if (alarmstate == WallpadStatusData.GUARD_OUT) {
if (OutModeRunAppRun == true) {
Log.d(TAG, "already outmoderun app running !!!!");
return;
}
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
int sensor = devset.Get_Sensor_Set();
devset.closeDB();
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
int Menu_Start_Id = 0;
int Menu_Start_Option = 1;
if (sensor > 0) {
WallPadInterface wpifc = new WallPadInterface();
int[] SensorInfoDB;
int inSen = 0;
int outSen = 0;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
if (SensorInfoDB[0] == 1) {
// 내부동체가 사용함이면 상태 검사
inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
}
if (SensorInfoDB[1] == 1) {
// 외부동체가 사용함이면 상태 검사
outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
}
// int inSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTIN_STATE, 0);
// int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0 || inSen > 0)) ||
((sensor & WallpadDeviceSet.SET_OUT_TO_IN_MOTION) > 0 && outSen > 0) ||
((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
Intent newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", (outSen > 0) ? "bugout" : "bugin");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(newintent);
return;
}
}
base = 8000;
Menu_Id_List = new int[]{base + 11};
Menu_Start_Id = base + 11;
Menu_Start_Option = -1;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
intent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
intent.setComponent(new ComponentName("kr.co.icontrols.wallpadoutmoderun", "kr.co.icontrols.wallpadoutmoderun.MainActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else if (alarmstate == WallpadStatusData.GUARD_IN) {
WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
int sensor = devset.Get_Sensor_Set();
devset.closeDB();
int base = 7000;
int[] Menu_Id_List = {base + 11, base + 21, base + 31, base + 41};
int Menu_Start_Option = 1;
if (sensor > 0) {
WallPadInterface wpifc = new WallPadInterface();
int[] SensorInfoDB;
int outSen = 0;
SensorInfoDB = Common.GetInSensorUseOfNotFromDB(getApplicationContext());
if (SensorInfoDB[1] == 1) {
// 외부동체가 사용함이면 상태 검사
outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
}
// int outSen = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_MOTOUT_STATE, 0);
if (((sensor & WallpadDeviceSet.SET_IN_MOTION) > 0 && (outSen > 0)) ||
((sensor & WallpadDeviceSet.SET_OUT_MOTION) > 0 && outSen > 0)) {
Intent newintent = new Intent(Intent.ACTION_MAIN);
newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
newintent.putExtra("MENU_START_ID", Menu_Id_List[2]); // KEY : MENU_START_ID
newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
newintent.putExtra("MENU_DETAIL_INFO", "bugout");
newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
newintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(newintent);
return;
}
}
} else if (alarmstate == WallpadStatusData.ALARM_STOP) {
WallPadInterface wpifc = new WallPadInterface();
wpifc.DoControl(WallPadInterface.IOCTL_BTNEMR_LED_TRIGGER, 1);
return;
} else if (alarmstate == WallpadStatusData.GUARD_OUT_WAIT) {
int base = 4000;
int Menu_Start_Id = 0;
int[] Menu_Id_List = new int[]{base + 11, base + 21};
Menu_Start_Id = base + 11;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
intent.putExtra("MENU_START_ID", Menu_Start_Id); // KEY : MENU_START_ID
intent.putExtra("MENU_START_OPTION", 1000); // KEY : MENU_START_OPTION
intent.setComponent(new ComponentName("kr.co.icontrols.wallpadsecurity", "kr.co.icontrols.wallpadsecurity.MainActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] CheckMainStatus()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
// WallpadDeviceSet devset = new WallpadDeviceSet(getApplicationContext());
// int StatusVal = devset.GetDeviceSetted("피난사다리");
// if (StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
// {
// WallPadInterface wpifc = new WallPadInterface();
// int fleeSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EXIT_STATE, 0);
//
// if (fleeSensor > 0)
// {
// int base = 7000;
// int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
// int Menu_Start_Option = 1;
// Intent newintent = new Intent(Intent.ACTION_MAIN);
// newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
// newintent.putExtra("MENU_START_ID", Menu_Id_List[3]); // KEY : MENU_START_ID
// newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
// newintent.putExtra("MENU_DETAIL_INFO", "ladder_Open");
// newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
// newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// startActivity(newintent);
// devset.closeDB();
// return;
// }
// }
//
// StatusVal = devset.GetDeviceSetted("알람발생");
// if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE)
// {
// WallPadInterface wpifc = new WallPadInterface();
// int AlarmSensor = wpifc.DoControl(WallPadInterface.IOCTL_SENSOR_EMR_STATE, 0);
//
// if (AlarmSensor > 0)
// {
// int base = 7000;
// int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
// int Menu_Start_Option = 1;
// Intent newintent = new Intent(Intent.ACTION_MAIN);
// newintent.putExtra("MENU_ID_LIST", Menu_Id_List); // KEY : MENU_ID_LIST
// newintent.putExtra("MENU_START_ID", Menu_Id_List[1]); // KEY : MENU_START_ID
// newintent.putExtra("MENU_START_OPTION", Menu_Start_Option); // KEY : MENU_START_OPTION
// newintent.putExtra("MENU_DETAIL_INFO", "emergency");
// newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
// newintent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// startActivity(newintent);
// devset.closeDB();
// return;
// }
//
// }
// devset.closeDB();
}
/**
* 관리자용 일괄소등 원격제어 사용여부 (송파 위례 아이파크 현장에서 일괄소등 제어기능 추가 요청으로 인함)
*
* @return (boolean) 해당기능 사용여부 (true:사용함 , false:사용하지 않음)
*/
public boolean GetUseIlgalControlForAdmin() {
WallpadDeviceSet devSet = new WallpadDeviceSet(getApplicationContext());
String[] MetringDB = devSet.GetSettingData("관리자용일괄소등원격제어");
devSet.closeDB();
boolean result = false;
if (MetringDB != null) {
try {
String devInfo = MetringDB[1];
devInfo = devInfo.replace('(', '_');
devInfo = devInfo.replace(':', '_');
devInfo = devInfo.replace(')', '_');
String[] MetringInfo = devInfo.split("_");
if (MetringInfo[3].equals("사용함") == true) {
result = true;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
return result;
}
class SendLHGWCheck extends Thread {
private iMAP_hn_config_read m_HnGWConfigRead = null;
private iMAPEmptyMessage m_HnGWEmptyMsg = null;
private boolean retSucces = false;
private int retryCount = 0;
public SendLHGWCheck() {
m_HnGWConfigRead = new iMAP_hn_config_read(getApplicationContext());
m_HnGWEmptyMsg = new iMAPEmptyMessage(getApplicationContext());
retryCount = 0;
}
public void run() {
try {
try {
Thread.sleep(2000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
for (int i = 0; i < 10; i++) {
m_HnGWConfigRead.DoWork();
m_HnGWConfigRead.SetRetCtr(new RetProci() {
@Override
public void ProcSuccess() {
retSucces = true;
Log.d(TAG, "HN GW Confing Read ProcSuccess retryCount : " + retryCount);
}
@Override
public void ProcError() {
}
@Override
public void ProcDoing() {
// TODO Auto-generated method stub
}
});
if (retSucces == true)
break;
retryCount++;
try {
Thread.sleep(3000);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
LogUtil.errorLogInfo("", TAG, e);
}
}
m_HnGWEmptyMsg.DoWork();
m_HnGWEmptyMsg.SetRetCtr(new RetProci() {
@Override
public void ProcSuccess() {
Log.d(TAG, "HN GW EmptyMsg Send ProcSuccess ");
}
@Override
public void ProcError() {
Log.d(TAG, "HN GW EmptyMsg Send ProcError ");
}
@Override
public void ProcDoing() {
// TODO Auto-generated method stub
Log.d(TAG, "HN GW EmptyMsg Send ProcDoing ");
}
});
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
//Reset Handler
private Handler mResetHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
Log.d(TAG, "[mResetHandler] Reset Check Handler Start");
Log.d(TAG, "[mResetHandler] ResetCount :" + ResetCount);
if (GetForegroundAPP().equals(PackageName_WallPadMain)) {
Log.d(TAG, "[mResetHandler] WallPadMain is Foreground!!!");
if (NowMainStatus == false) {
Log.d(TAG, "[mResetHandler] ResetCount will be 1");
ResetCount = 1;
}
ResetCount++;
NowMainStatus = true;
if (ResetCount == 30) {
mResetHandler.sendEmptyMessageDelayed(1, 10);
} else {
mResetHandler.sendEmptyMessageDelayed(0, 1000);
}
} else {
if (NowMainStatus == true) {
Log.d(TAG, "[mResetHandler] ResetCount will be 1");
ResetCount = 1;
}
ResetCount++;
NowMainStatus = false;
if (ResetCount == 180) {
// 3분
mResetHandler.sendEmptyMessageDelayed(1, 10);
} else {
mResetHandler.sendEmptyMessageDelayed(0, 1000);
}
}
} else if (msg.what == 1) {
Log.d(TAG, "[mResetHandler] Do Reset!!!");
setDefaultLauncher();
Intent intent = new Intent();
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
getApplicationContext().sendBroadcast(intent);
}
}
};
// 통화주체를 다루는 enum
public enum CALLOWNER {
NONE,
WALLPAD,
SUB_WALLPAD,
KITCHEN_TV,
BATH_PHONE,
BATH_TV,
UNIVERSAL_DEVICE,
ERROR;
}
public enum CALLEVENTTYPE {
RECEIVE_CALL, // 호출 수신 (호출 수신)
TRYING_CALL, // 호출 시도중 (호출 발신)
RECEIVE_CALL_2ND, // 멀티콜 수신 (호출 수신)
RECEIVE_CALL_ACK, // 호출응답 수신 (호출 발신)
REQUEST_FRONT_MONITORING, // 호출응답 수신 (호출 발신)
REQUEST_RESIDENCE_CALL, // 이웃통화 요청 수신 (호출 발신)
CONNECT_CALL, // 통화 시작
TERMINATE_CALL, // 통화 종료
CANCEL_CALL, // 호출 취소
CANCEL_CALL_2ND, // 멀티콜 호출 취소
REJECT_CALL, // 호출수신 거절
REJECT_BUSY_CALL, // 통화중 호출수신 거절
FORWARD_CALL, // 착신전환 설정
CALLERID, // Caller ID
TIMEOUT_1STCALL, // 1st Call Timeout
TIMEOUT_2NDCALL, // 2nd Call Timeout
TIMEOUT_3RDCALL, // 3rd Call Timeout
MOIP_VIDEO_SET, // MoIP 영상통화 설정
DOOR_OPEN, // 문열림 설정
PSTN_RING, // PSTN ARS동작을 위해, UI에서 Ring을 카운트 하기위한 이벤트
PSTN_DTMF, // PSTN DTMF 수신
DETECT_STRANGER, // 거동수상자 발생
NONE;
public static CALLEVENTTYPE getCALLEVENTTYPE(String value) {
try {
if (value.equals(RECEIVE_CALL.toString())) {
return RECEIVE_CALL;
} else if (value.equals(TRYING_CALL.toString())) {
return TRYING_CALL;
} else if (value.equals(RECEIVE_CALL_2ND.toString())) {
return RECEIVE_CALL_2ND;
} else if (value.equals(RECEIVE_CALL_ACK.toString())) {
return RECEIVE_CALL_ACK;
} else if (value.equals(REQUEST_FRONT_MONITORING.toString())) {
return REQUEST_FRONT_MONITORING;
} else if (value.equals(CONNECT_CALL.toString())) {
return CONNECT_CALL;
} else if (value.equals(TERMINATE_CALL.toString())) {
return TERMINATE_CALL;
} else if (value.equals(CANCEL_CALL.toString())) {
return CANCEL_CALL;
} else if (value.equals(REJECT_CALL.toString())) {
return REJECT_CALL;
} else if (value.equals(REJECT_BUSY_CALL.toString())) {
return REJECT_BUSY_CALL;
} else if (value.equals(FORWARD_CALL.toString())) {
return FORWARD_CALL;
} else if (value.equals(CALLERID.toString())) {
return CALLERID;
} else if (value.equals(TIMEOUT_1STCALL.toString())) {
return TIMEOUT_1STCALL;
} else if (value.equals(TIMEOUT_2NDCALL.toString())) {
return TIMEOUT_2NDCALL;
} else if (value.equals(TIMEOUT_3RDCALL.toString())) {
return TIMEOUT_3RDCALL;
} else if (value.equals(MOIP_VIDEO_SET.toString())) {
return MOIP_VIDEO_SET;
} else if (value.equals(DOOR_OPEN.toString())) {
return DOOR_OPEN;
} else if (value.equals(PSTN_RING.toString())) {
return PSTN_RING;
} else if (value.equals(PSTN_DTMF.toString())) {
return PSTN_DTMF;
} else if (value.equals(DETECT_STRANGER.toString())) {
return DETECT_STRANGER;
} else if (value.equals(NONE.toString())) {
return NONE;
} else {
return null;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", "", re);
return null;
} catch (Exception e) {
Log.e("iMapServer", "[Exception] getCALLEVENTTYPE()");
//e.printStackTrace();
LogUtil.errorLogInfo("", "", e);
return null;
}
}
}
public enum CALLTYPE {
NONE,
FRONT,
RESIDENCE,
LOBBY,
GUARD,
PSTN,
IHUB,
ERROR,
}
public static class CALLTRIGGER {
public static String CALLOWNER = "CALLOWNER";
public static String CALLEVENTTYPE = "CALLEVENTTYPE";
public static String CALLTYPE = "CALLTYPE";
public static String REMOTEINFO = "REMOTEINFO"; //add KSJ 2021.11.02
public enum SOURCE {
USER,
CALL_RECEIVE,
SUBPHONE
}
public enum TYPE {
MENU,
FRONT,
LOBBY,
GUARD,
RESIDENCE,
PSTN
}
}
String strWallPadCallPakageName = "kr.co.icontrols.wallpadcall";
int TAB_TALKFRONT = 130011;
public void runCallMainActivity(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType, int nAlramStatus) {
try {
Log.i(TAG, "[runCallMainActivity] bWallPadCallLive [" + bWallPadCallLive + "], eCallOwner [" + eCallOwner + "], eEventType [" + eEventType + "], eCallType [" + eCallType + "], nAlramStatus [" + nAlramStatus + "]");
if (!bWallPadCallLive) {
sendLCDBacklightStatus(true);
// 통화어플을 실행시킨다.
if (nAlramStatus != WallpadStatusData.GUARD_OUT)
Common.SendAppFinishReqBR(getApplicationContext());
ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
Intent mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.putExtra(CALLTRIGGER.CALLOWNER, eCallOwner.toString());
mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setComponent(mComponentName);
startActivity(mIntent);
playFrontBell(eCallOwner, eEventType, eCallType);
} else {
Log.w(TAG, "[runCallMainActivity] WallPadCall is already running!!");
// if (getUseSmartDoorCam()) {
// sendHandlerMsgDelayed(HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL, 0, 0, 3000);
// }
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] runCallMainActivity()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
//add KSJ 2021.11.02
public void runCallMainActivity_moip(CALLEVENTTYPE eEventType, CALLTYPE eCallType, String strIP) {
try {
if (!bWallPadCallLive || m_bWallpadCallScreen) {
// 통화어플을 실행시킨다.
Log.w(TAG, "[runCallMainActivity_moip] ########## START ##########");
sendLCDBacklightStatus(true);
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int nAlramStatus = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
if (nAlramStatus != WallpadStatusData.GUARD_OUT)
Common.SendAppFinishReqBR(getApplicationContext());
if(m_bWallpadCallScreen)
Thread.sleep(1000); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
ComponentName mComponentName = new ComponentName("kr.co.icontrols.wallpadcall", "kr.co.icontrols.wallpadcall.MainActivity");
Intent mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.putExtra(CALLTRIGGER.CALLOWNER, CALLOWNER.NONE.toString());
mIntent.putExtra(CALLTRIGGER.CALLEVENTTYPE, eEventType.toString());
mIntent.putExtra(CALLTRIGGER.CALLTYPE, eCallType.toString());
mIntent.putExtra(CALLTRIGGER.REMOTEINFO, strIP);
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mIntent.setComponent(mComponentName);
startActivity(mIntent);
Thread.sleep(500); // Call app이 실행되는 시간을 기다려준다. (빨리 띄우면 이벤트를 수신 못함)
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
Log.w(TAG, "[runCallMainActivity_moip] m_CallAppRunDelay " + m_CallAppRunDelay);
m_CallAppRunDelay = false;
}
}, 3000);
} else {
Log.w(TAG, "[runCallMainActivity_moip] WallPadCall is already running!!");
m_CallAppRunDelay = false;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] runCallMainActivity()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
//~add KSJ
private String getTopActivity() {
try {
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List mTaskInfo = mActivityManager.getRunningTasks(1);
// LOG_INFO("[isMainActivityTop] getClassName = " + mTaskInfo.get(0).topActivity.getClassName());
ComponentName mComponentName = mTaskInfo.get(0).topActivity;
// LOG_INFO("[isMainActivityTop] getPackageName = " + mComponentName.getPackageName());
return mComponentName.getPackageName();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] getTopActivity()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private void playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType) {
try {
if (eCallOwner == CALLOWNER.NONE && eEventType == CALLEVENTTYPE.RECEIVE_CALL && eCallType == CALLTYPE.FRONT) {
WallPadInterface Wiface = new WallPadInterface();
Wiface.DoControl(WallPadInterface.IOCTL_DOOR_POWERONOFF, 1);
Wiface.DoControl(WallPadInterface.IOCTL_DOOR_DINGDONG, 1);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] playFrontBell(CALLOWNER eCallOwner, CALLEVENTTYPE eEventType, CALLTYPE eCallType)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private class AfterTransactionTodoListData {
String Title;
int Valueint;
String ValueString;
private AfterTransactionTodoListData(String title, int valueint, String valueString) {
Title = title;
Valueint = valueint;
ValueString = valueString;
}
}
/**
* 주차정보 주차서버로부터 얻어오도록하는 intent 전송
**/
public void SendGetParkingInfoIntent() {
Intent iIntent = new Intent();
iIntent.setAction(define.NOTIFY_ACNAME);
iIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_GET_CAR_PARKING);
this.sendBroadcast(iIntent);
}
/**
* 주차정보 주차서버로부터 얻어오도록 하는 intent 전송(20분 후 전송)
**/
public Handler SendParkingInfoIntentAfter20min = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
SendGetParkingInfoIntent();
}
}
};
/**
* RF현관카메라에서 외출모드 시도 시 음원출력에 대한 sleep을 handler처리로 변경함
**/
public Handler mWallPadOutmodeSleepHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
if (msg.what == 0) {
mWallPadAPI.SetDevService_DoorCamUseOnOff(false);
}
}
};
// Handler
public final class HANDLERMSG {
public final static int APP_RUN_GLOBALSCREEN_TRUE = 100;
public final static int APP_RUN_GLOBALSCREEN_FALSE = 110;
public final static int ENABLE_APP_RUN_WALLPADCALL = 200;
public final static int CALLAPP_FINISHING_END = 300;
public final static int FRONTCAM_PLAY_DINGDONG = 400;
}
public Handler iMAPServerHandler = new Handler(Looper.getMainLooper()) {
public void handleMessage(Message msg) {
Log.v(TAG, "[iMAPServerHandler] what [" + msg.what + "], arg1 [" + msg.arg1 + "], arg2 [" + msg.arg2 + "]");
switch (msg.what) {
case HANDLERMSG.APP_RUN_GLOBALSCREEN_TRUE:
bGlobalScreenRun = true;
break;
case HANDLERMSG.APP_RUN_GLOBALSCREEN_FALSE:
bGlobalScreenRun = false;
break;
case HANDLERMSG.ENABLE_APP_RUN_WALLPADCALL:
break;
case HANDLERMSG.CALLAPP_FINISHING_END:
// bBlockCallEvent = false;
break;
case HANDLERMSG.FRONTCAM_PLAY_DINGDONG:
int time = Sound().PlayMent(SND.call.DINGDONG);
Log.d(TAG, "[iMAPServerHandler] time [" + time + "]");
if (time < 0) time = 2088;
mDingDongHandler.sendEmptyMessageDelayed(3, time + 300);
break;
default:
Log.v(TAG, "iMAPServerHandler : " + msg.what);
break;
}
}
};
public void sendHandlerMsg(int what, int arg1, int arg2) {
try {
Log.v(TAG, "[sendHandlerMsg] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "]");
Message HandleMsg = iMAPServerHandler.obtainMessage();
HandleMsg.what = what;
HandleMsg.arg1 = arg1;
HandleMsg.arg2 = arg2;
iMAPServerHandler.sendMessage(HandleMsg);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendHandlerMsg(msg)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public void sendHandlerMsgDelayed(int what, int arg1, int arg2, int delay) {
try {
Log.v(TAG, "[sendHandlerMsgDelayed] what [" + what + "], arg1 [" + arg1 + "], arg2 [" + arg2 + "], delay [" + delay + "]");
Message HandleMsg = iMAPServerHandler.obtainMessage();
HandleMsg.what = what;
HandleMsg.arg1 = arg1;
HandleMsg.arg2 = arg2;
iMAPServerHandler.sendMessageDelayed(HandleMsg, delay);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendHandlerMsgDelayed(msg)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
int mSensitivity = 0, mDuration = 0;
int MIN_SENSOR_SENSITIVITY = 1;
int MAX_SENSOR_SENSITIVITY = 5;
int MIN_SENSOR_DURATION = 30;
int MAX_SENSOR_DURATION = 250;
int DEFAULT_SENSOR_SENSITIVITY = 3;
int DEFAULT_SENSOR_DURATION = 60;
private final int COMPONENT_USE = 1;
/**
* 스마트현관카메라 사용여부 판별
*/
private boolean getUseSmartDoorCam() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
mWallpadDeviceSet.closeDB();
if (nFrontCam[0] == COMPONENT_USE) {
if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) {
Log.d(TAG, "[getUseSmartDoorCam] Use SMART_IOT_DOORCAM");
return true;
} else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) {
Log.d(TAG, "[getUseSmartDoorCam] Use HYOSUNG_SMART_DOORCAM");
return true;
} else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
Log.d(TAG, "[getUseSmartDoorCam] Use DAEWOO_SMART_DOORCAM");
return true;
} else if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) {
Log.d(TAG, "[getUseSmartDoorCam] Use DOORTYPE_SMARTKEY_EXTERNAL");
return true;
} else {
Log.w(TAG, "[getUseSmartDoorCam] Not Use SMART_DOOR_CAM");
return false;
}
} else {
Log.w(TAG, "[getUseSmartDoorCam] Not Use DOOR_CAM");
return false;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] getUseSmartDoorCam()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
private int getSmartDoorCamType() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
mWallpadDeviceSet.closeDB();
if (nFrontCam[0] == COMPONENT_USE) {
if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
return nFrontCam[1];
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getSmartDoorCamType()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return -1;
}
/**
* 방문객원격통화 솔루션 사용여부 판별
*/
private boolean getRemoteCallUseInfo() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
if (mWallpadDeviceSet != null) {
String[] astrRemoteCall = mWallpadDeviceSet.GetSettingData("방문객원격통화");
if (astrRemoteCall != null) {
if (astrRemoteCall[1].contains("사용함")) return true;
} else {
Log.d(TAG, "[getRemoteCallUseInfo] astrRemoteCall is null!!");
}
}
mWallpadDeviceSet.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getRemoteCallUseInfo()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return false;
}
/*
에너지 사용량 화면을 위한 실시간 검침기 정보 관리
*/
private RealTimeMeterAPI mRealTimeMeterAPI;
private DataClasses.RealTimeMeter mRealTimeMeterData = null;
private boolean DEBUG_REALMETER_DATA_LOG_ON = false;
public Thread saveRealmeterDataThread = null;
private void startRealtimemeterInfo() {
try {
// 영업샘플 모드 판단
if (Common.GetDeviceSampleMode(getApplicationContext())) {
Log.w(TAG, "[startRealtimemeterInfo] Business sample mode!!!");
} else {
Log.w(TAG, "[startRealtimemeterInfo] Normal working mode!!!");
// 실시간 검침기 사용유무 판단
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int[] naRealtimemtInfo = mWallpadDeviceSet.Get_RealTimeMetor_Info();
mWallpadDeviceSet.closeDB();
boolean bRealtimemeterUsage = false;
int nRealtimemeterCntDB = -99;
if (naRealtimemtInfo[0] == WallpadDeviceSet.DO_USE) {
// 실시간 검침 사용함
bRealtimemeterUsage = true;
nRealtimemeterCntDB = naRealtimemtInfo[1];
initRealtimemeterFunctionHandler.sendEmptyMessage(0);
} else {
// 실시간 검침 사용하지 않음
bRealtimemeterUsage = false;
}
Log.i(TAG, "[startRealtimemeterInfo] bRealtimemeterUsage [" + bRealtimemeterUsage + "], nRealtimemeterCntDB [" + nRealtimemeterCntDB + "]");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] startRealtimemeterInfo()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void startSmartIoTCamInfo() {
try {
// 영업샘플 모드 판단
if (Common.GetDeviceSampleMode(getApplicationContext())) {
Log.w(TAG, "[startSmartIoTCamInfo] Business sample mode!!!");
} else {
Log.w(TAG, "[startSmartIoTCamInfo] Normal working mode!!!");
if (getUseSmartDoorCam()) {
initSmartIoTFunctionHandler.sendEmptyMessage(0);
} else {
Log.w(TAG, "[startSmartIoTCamInfo] Not use smart door camera!!");
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] startSmartIoTCamInfo()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void startDistributionPanel() {
try {
// 영업샘플 모드 판단
if (Version.getModelType() == MODEL_TYPE.IHN_D101 || Version.getModelType() == MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == MODEL_TYPE.IHN_D101K || Version.getModelType() == MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
Log.i(TAG, "[startDistributionPanel] Normal working or Business sample mode!!!");
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int nResult = mWallpadDeviceSet.Get_DistributionPannelType_Info();
mWallpadDeviceSet.closeDB();
if (nResult == Version.DISTRIBUTION_MODEL.SMART_DIST)
initSmartDistributionPanelHandler.sendEmptyMessage(0);
if (nResult == Version.DISTRIBUTION_MODEL.KNX_DIST)
initKNXDistributionPanelHandler.sendEmptyMessage(0);
else Log.w(TAG, "[startDistributionPanel] Not supported!!! -> " + nResult);
} else {
Log.w(TAG, "[startDistributionPanel] Not supported!!!");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] startDistributionPanel()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// =================================================================================================
// [[ Device ]] region
// =================================================================================================
/**
* 디바이스 API 를 Load 한다.
*
* @param wpapi - 생성시 전달받은 WallPadAPI
* @return (int) - >=0 : 성공, <0 : 실패
*/
private int loadRealtimemeterAPI(WallPadAPI wpapi) {
// 1. Mode Check
if (Common.GetDeviceSampleMode(getApplicationContext())) {
Log.w(TAG, "[loadRealtimemeterAPI] Business sample mode!!");
return -1;
}
Log.i(TAG, "[loadRealtimemeterAPI] - Start");
// 2. wpapi Check
if (wpapi == null) {
Log.e(TAG, "[loadRealtimemeterAPI] - wpapi is null");
return -2;
}
// 3. Load API
Log.i(TAG, "[loadRealtimemeterAPI] - Step1 : RemoteMeter API Load...");
try {
mRealTimeMeterAPI = wpapi.Get_RealTimeMeterController();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return -100;
} catch (Exception e) {
Log.e(TAG, "[loadRealtimemeterAPI] - [Exception Error] wpapi.Get_RealTimeMeterController");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return -100;
}
if (mRealTimeMeterAPI == null) {
Log.e(TAG, "[loadRealtimemeterAPI] - mRealTimeMeterAPI is null");
return -4;
}
Log.i(TAG, "[loadRealtimemeterAPI] - OK");
return 0;
}
/**
* 제어기 상태를 가져온다.
*
* @param real - (boolean) true : 실시간 , false : 가장최근
* @return (int) - >=0 : 성공, <0 : 실패
*/
@SuppressWarnings("unused")
private int updateRealtimemeterData(boolean real) {
try {
// 1. Api Load Check
if (mRealTimeMeterAPI == null) {
Log.e(TAG, "[updateRealtimemeterData] - remoteMeterApi unload !!!");
return -1;
}
// 2. reflash
try {
int ret = mRealTimeMeterAPI.Refresh(real);
if (ret < 0) {
Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.Refresh - ret (" + ret + ")" + mRealTimeMeterAPI.ErrorCode.ErrStr());
return -2;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return -100;
} catch (Exception e) {
Log.e(TAG, "[updateRealtimemeterData] - [Exception Error] remoteMeterApi.Refresh(" + real + ")");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return -100;
}
// 3. Range Check
if (mRealTimeMeterAPI.data == null) {
Log.e(TAG, "[updateRealtimemeterData] - mRealTimeMeterAPI.mRealTimeMeterData is null !!!");
return -9;
}
if (mRealTimeMeterAPI.data.Elec.Now >= 1000000) {
Log.e(TAG, "[updateRealtimemeterData] - ElecNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Elec.Now + ")");
return -10;
}
if (mRealTimeMeterAPI.data.Water.Now >= 1000) {
Log.e(TAG, "[updateRealtimemeterData] - WaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Water.Now + ")");
return -11;
}
if (mRealTimeMeterAPI.data.HotWater.Now >= 1000) {
Log.e(TAG, "[updateRealtimemeterData] - HotWaterNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.HotWater.Now + ")");
return -12;
}
if (mRealTimeMeterAPI.data.Gas.Now >= 1000) {
Log.e(TAG, "[updateRealtimemeterData] - GasNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Gas.Now + ")");
return -13;
}
if (mRealTimeMeterAPI.data.Calorie.Now >= 1000) {
Log.e(TAG, "[updateRealtimemeterData] - CaloryNow mRealTimeMeterData Out of range !!! (" + mRealTimeMeterAPI.data.Calorie.Now + ")");
return -14;
}
// 4. Data Copy
mRealTimeMeterData = mRealTimeMeterAPI.data;
// 5. Debug msg
if (DEBUG_REALMETER_DATA_LOG_ON) {
Log.i(TAG, mRealTimeMeterData.ToDebugString());
Log.i(TAG, "[updateRealtimemeterData] - OK");
}
return 0;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return -99;
} catch (Exception e) {
Log.e(TAG, "[Exception] updateRealtimemeterData(boolean real)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return -99;
}
}
/**
* (임시코드) 실시간검침기 드라이버 초기생성시 Connect 에 시간이 걸리며,
* 실시간검침기 드라이버 초기화후 바로 API 를 가져올수 없기에,
* 본 딜레이 코드를 임시로 적용한다.
*/
@SuppressLint("HandlerLeak")
protected Handler initRealtimemeterFunctionHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "[initRealtimemeterFunctionHandler] msg.what [" + msg.what + "]");
if (msg.what == 0) {
if (loadRealtimemeterAPI(mWallPadAPI) >= 0) {
if (updateRealtimemeterData(false) == 0) {
initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(1, 10);
} else {
initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
}
} else {
Log.i(TAG, "mInitDriverCheckHandler --> mRealTimeMeterAPI == null");
initRealtimemeterFunctionHandler.sendEmptyMessageDelayed(0, 10000);
}
} else if (msg.what == 1) {
Log.i(TAG, "[initRealtimemeterFunctionHandler] succes addBrActionName");
if (mRealTimeMeterAPI != null) {
// Device_BrRegistration(true);
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
int[] setdata = mWallpadDeviceSet.Get_RealTimeMetor_Info();
mWallpadDeviceSet.closeDB();
if ((saveRealmeterDataThread == null) && (setdata[0] == 1)) {
saveRealmeterDataThread = new saveRealmeterData();
saveRealmeterDataThread.start();
}
// RemoveUsedData();
// ShowUsedDataGraph();
}
}
}
};
protected Handler initSmartDistributionPanelHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "[initSmartDistributionPanelHandler] msg.what [" + msg.what + "]");
if (msg.what == 0) {
if (mWallPadAPI.Check_Connect())
initSmartDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
else initSmartDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
} else if (msg.what == 1) {
Log.i(TAG, "[initSmartDistributionPanelHandler] mSdb_LivingRoomLightAPI Connect!!");
mSdbAPI = mWallPadAPI.Get_SdbController();
mSdb_LivingRoomLightAPI = mWallPadAPI.Get_Sdb_LivingRoomLightAPI();
mSdb_LivingRoomLightAPI.Refresh();
}
}
};
protected Handler initKNXDistributionPanelHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "[initKNXDistributionPanelHandler] msg.what [" + msg.what + "]");
if (msg.what == 0) {
if (mWallPadAPI.Check_Connect())
initKNXDistributionPanelHandler.sendEmptyMessageDelayed(1, 10);
else initKNXDistributionPanelHandler.sendEmptyMessageDelayed(0, 500);
} else if (msg.what == 1) {
Log.i(TAG, "[initKNXDistributionPanelHandler] mKnx_LivingRoomLightAPI Connect!!");
mKnxAPI = mWallPadAPI.Get_KnxController();
mKnx_LivingRoomLightAPI = mWallPadAPI.Get_Knx_LivingRoomLightAPI();
mKnx_LivingRoomLightAPI.Refresh();
}
}
};
protected Handler initSmartIoTFunctionHandler = new Handler() {
@SuppressLint("HandlerLeak")
@Override
public void handleMessage(Message msg) {
Log.i(TAG, "[initSmartIoTFunctionHandler] msg.what [" + msg.what + "]");
if (msg.what == 0) {
if (mWallPadAPI.Check_Connect())
initSmartIoTFunctionHandler.sendEmptyMessageDelayed(1, 10);
else initSmartIoTFunctionHandler.sendEmptyMessageDelayed(0, 500);
} else if (msg.what == 1) {
Log.i(TAG, "[initSmartIoTFunctionHandler] mSmartKeyRfDoorAPI Connect!!");
mSmartKeyRfDoorAPI = mWallPadAPI.Get_SmartKeyRfDoorController();
// 초기화를 위해 스마트 IoT 현관카메라의 상태를 정리한다. (초기값 전송-민감도: 5 / 감도유지시간: 5, 상태 Off, LED Off)
String ret = mSmartKeyRfDoorAPI.SetSensorConfig((byte) 0x05, getSmartDoorCamDuration());
Log.i(TAG, "[initSmartIoTFunctionHandler] ret [" + ret + "]");
// 거동수상자 녹화를 위한 자동 On 기능 비활성화
ctrlSmartIOTCamStatusMode(Common.SmartRFCamStatusMode.STATUS_AUTO_OFF);
ctrlSmartIOTCamLEDMode(Common.SmartRFCamLEDMode.LED_AUTO_OFF);
}
}
};
// 스마트현관카메라 MODE 제어
private void ctrlSmartIOTCamStatusMode(byte mode) {
try {
Log.d(TAG, "[ctrlSmartIOTCamStatusMode] mode [" + mode + "]");
if (mSmartKeyRfDoorAPI != null) {
int nResult = mSmartKeyRfDoorAPI.SetCAMERAmode(mode);
Log.d(TAG, "[ctrlSmartIOTCamStatusMode] nResult -> " + nResult);
} else Log.w(TAG, "[ctrlSmartIOTCamStatusMode] mSmartKeyRfDoorAPI is null!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] ctrlSmartIOTCamStatusMode(byte mode)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 스마트현관카메라 LED 상태 제어
private void ctrlSmartIOTCamLEDMode(byte mode) {
try {
Log.d(TAG, "[ctrlSmartIOTCamLEDMode] mode [" + mode + "]");
if (mSmartKeyRfDoorAPI != null) {
int nResult = mSmartKeyRfDoorAPI.SetLEDmode(mode);
Log.d(TAG, "[ctrlSmartIOTCamLEDMode] nResult -> " + nResult);
} else Log.w(TAG, "[ctrlSmartIOTCCamLEDMode] mSmartKeyRfDoorAPI is null!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] ctrlSmartIOTCamLEDMode(byte mode)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 현관카메라 거동수상자 감지시간
private byte getSmartDoorCamDuration() {
try {
WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(this);
byte duration = (byte) wallpadDeviceSet.Get_SmartDoorCam_Dutaion();
wallpadDeviceSet.closeDB();
Log.d(TAG, "[getSmartDoorCamDuration] duration [" + duration + "]");
return duration;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getSmartDoorCamDuration()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return (byte) 0x05;
}
// =================================================================================================
// [[ Thread ]] region
// =================================================================================================
/**
* 실시간검침 데이터를 DB에 저장하는 쓰레드.
* 10분에 한번씩 저장
*/
@SuppressLint("UseValueOf")
class saveRealmeterData extends Thread {
@Override
public void run() {
super.run();
Log.i(TAG, "[saveRealmeterData] ========== START ==========");
int ret;
wallpaddbmgr WallpadDBMGRforThread = null;
while (true) {
try {
Thread.sleep(1000 * 60 * 3); //3분마다
if (mRealTimeMeterAPI != null) {
ret = mRealTimeMeterAPI.Refresh(false);
if (ret == 0) {
Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is success");
Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.ElecAccrued :" + mRealTimeMeterAPI.data.Elec.Acc);
WallpadDBMGRforThread = new wallpaddbmgr(getApplicationContext());
WallpadDBMGRforThread.InsertRealTimeMeterData(
new Double(mRealTimeMeterAPI.data.Elec.Now).toString(),
new Double(mRealTimeMeterAPI.data.Elec.Acc).toString(),
new Double(mRealTimeMeterAPI.data.Water.Now).toString(),
new Double(mRealTimeMeterAPI.data.Water.Acc).toString(),
new Double(mRealTimeMeterAPI.data.Gas.Now).toString(),
new Double(mRealTimeMeterAPI.data.Gas.Acc).toString(),
new Double(mRealTimeMeterAPI.data.HotWater.Now).toString(),
new Double(mRealTimeMeterAPI.data.HotWater.Acc).toString(),
new Double(mRealTimeMeterAPI.data.Calorie.Now).toString(),
new Double(mRealTimeMeterAPI.data.Calorie.Acc).toString()
);
int tempInt = WallpadDBMGRforThread.RowCountRealTimeMeterData();
Log.i(TAG, "[saveRealmeterData] WallpadDBMGRforThread.RowCountRealTimeMeterData() :" + tempInt);
if (tempInt > 6000) {
WallpadDBMGRforThread.DeleteRealTimeMeterData("120");
}
WallpadDBMGRforThread.closeDB();
} else {
Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI.Refresh is fail");
}
} else {
Log.i(TAG, "[saveRealmeterData] mRealTimeMeterAPI is null");
}
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
if (WallpadDBMGRforThread != null) {
WallpadDBMGRforThread.closeDB();
}
Log.i(TAG, "saveRealmeterData extends Thread occurs exception Error");
//e1.printStackTrace();
LogUtil.errorLogInfo("", TAG, e1);
}
}
}
}
/**
* 단지서버 2.0 사용여부
*
* @return true - 단지서버 2.0 사용, false - 단지서버 1.0 사용
**/
public boolean NewServerUse() {
WallpadStatusData SetData = new WallpadStatusData(getApplicationContext());
if (SetData != null) {
String serverVesionInfo = SetData.GetServerVer();
SetData.closeDB();
if (!((serverVesionInfo == null) || (serverVesionInfo.equalsIgnoreCase("1.0")))) {
return true;
}
}
return false;
}
/**
* 단지서버2.0 적용시에만 사용한다.
* 원격 메시지 수신시 return String이 MOBILE_USER_AUTH_PASSED(모바일 앱) 또는 WEB_USER_AUTH_PASSED(단지 웹)인 경우에
* 기기의 ID(모바일 앱) 또는 비밀번호(단지 웹 , 숫자 6자리)를 확인한다.
* 각각의 인증정보가 일치하면 해당 String을 return하며, 그렇지 않으면 실패 응답 메시지(iMAP)을 return한다. (JEFF, 2019.07.26)
**/
String REMOTETYPE_SVR2MOBILEAUTH = "server2.0_new_auth";
String REMOTETYPE_SVR2WEB = "danji_web_control";
String MOBILE_USER_FREEPASS = "F6B253A39360F76356007356E79A3F82948582ADE31E3E77598FA127BFC69F36";
public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc) {
try {
// Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
// Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
NodeList mNodeList = doc.getElementsByTagName("device_info");
Node mNode = mNodeList.item(0);
if (mNode != null) {
String alias = "null", twinid = "null";
NamedNodeMap attrsParam = mNode.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("alias"))
alias = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
twinid = attr.getNodeValue();
}
//현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
Log.i(TAG, "[checkRemoteCtrlAuthentication] Passed by mobile user freepass!!");
return MOBILE_USER_AUTH_PASSED;
}
WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
mWallpadMobileDeviceData.closeDB();
if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
else {
//Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + mWallpadMobileDeviceData.isExistMobileDevice(twinid) + "]");
//닫은 DB에 접근하여서 수정.
Log.w(TAG, "[checkRemoteCtrlAuthentication] isExistMobileDevice [" + nCheckResult + "]");
strReplyMsg += " result=\"deny\">\r\n \r\n";
return strReplyMsg;
}
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
strReplyMsg += " result=\"fail\">\r\n \r\n";
return strReplyMsg;
}
} else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
NodeList mNodeList = doc.getElementsByTagName("password_info");
Node mNode = mNodeList.item(0);
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
mWallpadStatusData.closeDB();
Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW [" + strSavedWebCtrlPW + "]");
if (!checkPWValidation(strSavedWebCtrlPW)) {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
strReplyMsg += " result=\"deny\">\r\n \r\n";
return strReplyMsg;
}
if (mNode != null) {
String strReceivedPW = "000000";
NamedNodeMap attrsParam = mNode.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("password"))
strReceivedPW = attr.getNodeValue();
}
if (!checkPWValidation(strReceivedPW)) {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
strReplyMsg += " result=\"deny\">\r\n \r\n";
return strReplyMsg;
}
if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
return WEB_USER_AUTH_PASSED;
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
strReplyMsg += " result=\"deny\">\r\n \r\n";
return strReplyMsg;
}
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
strReplyMsg += " result=\"fail\">\r\n \r\n";
return strReplyMsg;
}
} else {
Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
strReplyMsg += " result=\"deny\">\r\n \r\n";
return strReplyMsg;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Document doc)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
public String checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele) {
try {
// Log.i(TAG, "[checkRemoteCtrlAuthentication] strReplyMsg [" + strReplyMsg +"]");
// Log.i(TAG, "[checkRemoteCtrlAuthentication] strTarget [" + strReplyMsg +"]");
if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2MOBILEAUTH)) {
NodeList mNodeList = ele.getElementsByTagName("device_info");
Node mNode = mNodeList.item(0);
if (mNode != null) {
String alias = "null", twinid = "null";
NamedNodeMap attrsParam = mNode.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("alias"))
alias = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
twinid = attr.getNodeValue();
}
//현장 초기 설치 시, 조명 일괄제어를 위하여 프리패스 UID를 추가함 ("icontrolscontrol9"를 SHA256해시한 값임)
if (twinid.equalsIgnoreCase(MOBILE_USER_FREEPASS)) {
Log.i(TAG, "[checkRemoteCtrlAuthentication] FREE PASS for All remote Control");
return MOBILE_USER_AUTH_PASSED;
}
WallpadMobileDeviceData mWallpadMobileDeviceData = new WallpadMobileDeviceData(getApplicationContext());
int nCheckResult = mWallpadMobileDeviceData.isExistMobileDevice(twinid);
mWallpadMobileDeviceData.closeDB();
if (nCheckResult > 0) return MOBILE_USER_AUTH_PASSED;
else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] not exist twinid [" + twinid + "]");
strReplyMsg += " \"none\" >\r\n \r\n";
return strReplyMsg;
}
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] itemParam is null");
strReplyMsg += " \"fail\" >\r\n \r\n";
return strReplyMsg;
}
} else if (strTarget.equalsIgnoreCase(REMOTETYPE_SVR2WEB)) {
NodeList mNodeList = ele.getElementsByTagName("password_info");
Node mNode = mNodeList.item(0);
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
String strSavedWebCtrlPW = mWallpadStatusData.GetWebCtrPW();
mWallpadStatusData.closeDB();
if (!checkPWValidation(strSavedWebCtrlPW)) {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strSavedWebCtrlPW is not valid!!");
strReplyMsg += " \"deny\" >\r\n \r\n";
return strReplyMsg;
}
if (mNode != null) {
String strReceivedPW = "000000";
NamedNodeMap attrsParam = mNode.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("password"))
strReceivedPW = attr.getNodeValue();
}
if (!checkPWValidation(strReceivedPW)) {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW is not valid!!");
strReplyMsg += " \"deny\" >\r\n \r\n";
return strReplyMsg;
}
if (strReceivedPW.equalsIgnoreCase(strSavedWebCtrlPW)) {
Log.i(TAG, "[checkRemoteCtrlAuthentication] WebctrlPW is correct!!");
return WEB_USER_AUTH_PASSED;
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] strReceivedPW [" + strReceivedPW + "]");
strReplyMsg += " \"deny\" >\r\n \r\n";
return strReplyMsg;
}
} else {
Log.w(TAG, "[checkRemoteCtrlAuthentication] mNode is null");
strReplyMsg += " \"fail\" >\r\n \r\n";
return strReplyMsg;
}
} else {
Log.e(TAG, "[checkRemoteCtrlAuthentication] strTarget is not match!! -> " + strTarget);
strReplyMsg += " \"deny\" >\r\n \r\n";
return strReplyMsg;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return null;
} catch (Exception e) {
Log.e(TAG, "[Exception] checkRemoteCtrlAuthentication(String strReplyMsg, String strTarget, Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
String[] astrPreventedPWs = {"000000", "123456", "234567", "345678", "456789", "567890", "987654", "876543", "765432", "654321", "543210", "012345", "2580", "0852"};
private boolean checkPWValidation(String strPW) {
try {
// null 확인
if (strPW == null) {
Log.w(TAG, "[checkPWValidation] strPW is null!!");
return false;
}
// 입력된 비밀번호 길이 확인
if (strPW.length() != 6) {
Log.w(TAG, "[checkPWValidation] strPW length : " + strPW.length());
return false;
}
// 사전 금지된 비밀번호 확인
for (int i = 0; i < astrPreventedPWs.length; i++) {
if (strPW.contains(astrPreventedPWs[i])) {
Log.w(TAG, "[checkPWValidation] Prevented PW : " + strPW);
return false;
}
}
/*// 연속된 비밀번호 확인
int nSerialNoCnt = 0;
int nCompareNo = 0;
int[] naPW = new int[strPW.length()];
for (int i = 0; i < naPW.length; i++)
{
naPW[i] = Integer.parseInt(String.valueOf(strPW.charAt(i)));
Log.w(TAG, "[checkPWValidation] naPW[" + i +"] = " + naPW[i]);
if (i ==0) {
nCompareNo = naPW[i];
nCompareNo++;
}
else if (0 < i && i < 6) {
if (nCompareNo == naPW[i]) nSerialNoCnt++;
nCompareNo++;
}
else {
Log.w(TAG, "[checkPWValidation] PW length is abnormal!! -> " + naPW.length);
}
}
if (nSerialNoCnt > 3) {
Log.w(TAG, "[checkPWValidation] PW contains serial number!! -> " + strPW);
return false;
}*/
// 동일한 번호 5회이상 입력 확인
int nSameNoCnt = 0;
for (int i = 0; i < strPW.length() - 1; i++) {
if (strPW.charAt(i) == strPW.charAt(i + 1)) {
nSameNoCnt++;
}
}
if (nSameNoCnt > 4) {
Log.w(TAG, "[checkPWValidation] PW contains the number repeated more than three!! -> " + strPW);
return false;
}
// 동, 호정보 확인
WallpadStatusData DBMGR = new WallpadStatusData(getApplicationContext());
wallpaddbmgr.AddressSet addr = DBMGR.getAddressMGR();
DBMGR.closeDB();
String strDong = addr.Dong;
String strHo = addr.Ho;
Log.d(TAG, "[checkPWValidation] dong : " + strDong + " / ho : " + strHo);
if (strPW.substring(0, 4).contains(strDong)) {
Log.w(TAG, "[checkPWValidation] PW contains wallpad dong info.!! -> " + strPW);
return false;
}
if (strPW.substring(0, 4).contains(strHo)) {
Log.w(TAG, "[checkPWValidation] PW contains wallpad ho info.!! -> " + strPW);
return false;
}
return true;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] checkPWValidation(String strPW)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
public String iCMDProcOnePass(Element ele) {
String[] strTarget = {"null", "null", "null"}; // name, id, msg_no
String[] strDeviceInfo = {"null", "null"}; // alias, twinid
String strAction = "null", strTargetLobbyIP = "null";
try {
// 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
String retStr = CheckiCMDProc("remote_access_onepass");
if (retStr != null)
return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
// 단지서버 2.0 사용여부 확인
if (!NewServerUse()) {
return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
}
// 메시지 송신지 구분
NodeList items = ele.getElementsByTagName("target");
Node item = items.item(0);
if (item != null) {
NamedNodeMap attrs = item.getAttributes();
for (int j = 0; j < attrs.getLength(); j++) {
Node attr = attrs.item(j);
if (attr.getNodeName().equalsIgnoreCase("name"))
strTarget[0] = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("id"))
strTarget[1] = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("msg_no"))
strTarget[2] = attr.getNodeValue();
}
}
// 단지서버 2.0 사용하는 경우, 모바일 인증 또는 단지 웹 제어 비밀번호 인증 필요 (JEFF, 2019.07.26)
if (NewServerUse()) {
String ServerCheckResult = checkRemoteCtrlAuthentication(retStr, strTarget[0], ele);
if (!ServerCheckResult.equals(MOBILE_USER_AUTH_PASSED)) {
if (ServerCheckResult.contains("fail"))
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
else if (ServerCheckResult.contains("deny"))
return makeReply_remote_access_onepass("deny", strTarget, strDeviceInfo, strAction);
else if (ServerCheckResult.contains("none"))
return makeReply_remote_access_onepass("none", strTarget, strDeviceInfo, strAction);
else
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
}
}
NodeList itemsDeviceParam = ele.getElementsByTagName("device_info");
Node itemDeviceParam = itemsDeviceParam.item(0);
if (itemDeviceParam != null) {
NamedNodeMap attrsParam = itemDeviceParam.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("alias"))
strDeviceInfo[0] = attr.getNodeValue();
else if (attr.getNodeName().equalsIgnoreCase("twinid"))
strDeviceInfo[1] = attr.getNodeValue();
}
} else {
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
}
// 명령어 구분
NodeList itemsaction = ele.getElementsByTagName("action");
Node itemaction = itemsaction.item(0);
Node text = itemaction.getFirstChild();
strAction = text.getNodeValue();
strAction = trimquotation(strAction);
// 문열림 타겟 로비폰 IP
NodeList itemsParam = ele.getElementsByTagName("params");
Node itemParam = itemsParam.item(0);
if (itemParam != null) {
NamedNodeMap attrsParam = itemParam.getAttributes();
for (int j = 0; j < attrsParam.getLength(); j++) {
Node attr = attrsParam.item(j);
if (attr.getNodeName().equalsIgnoreCase("ctrl_action"))
strTargetLobbyIP = attr.getNodeValue();
}
}
Log.i(TAG, "[iCMDProcOnePass] strTargetLobbyIP = " + strTargetLobbyIP);
if (strAction.equalsIgnoreCase("authorize_request")) {
sendLobbyOnePass(strTargetLobbyIP, "ok", strDeviceInfo[0]);
return makeReply_remote_access_onepass("ok", strTarget, strDeviceInfo, strAction);
} else {
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcOnePass(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return makeReply_remote_access_onepass("fail", strTarget, strDeviceInfo, strAction);
}
}
public String makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction) {
try {
String strReplyXml = XMLHeader;
strReplyXml += " \n";
strReplyXml += " \n";
strReplyXml += " \n";
strReplyXml += " \"" + strAction + "\"\n";
strReplyXml += " \n";
strReplyXml += "";
return strReplyXml;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return "ERROR";
} catch (Exception e) {
Log.e(TAG, "[Exception] makeReply_remote_access_onepass(String strResult, String[] strTarget, String[] strDeviceInfo, String strAction)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return "ERROR";
}
}
public void sendLobbyOnePass(String strTargetIP, String strAction, String strName) {
try {
Log.i(TAG, "[sendLobbyOnePass] strTargetIP [" + strTargetIP + "], strAction [" + strAction + "], strName [" + strName + "]");
iMAPLobbyOnePass miMAPLobbyOnePass = new iMAPLobbyOnePass(getApplicationContext());
miMAPLobbyOnePass.DoWork(strTargetIP, strAction, strName);
miMAPLobbyOnePass.SetRetCtr(new RetProci() {
@Override
public void ProcSuccess() {
Log.i(TAG, "[sendLobbyOnePass.ProcSuccess]");
}
@Override
public void ProcError() {
Log.i(TAG, "[sendLobbyOnePass.ProcError]");
}
@Override
public void ProcDoing() {
Log.i(TAG, "[sendLobbyOnePass.ProcDoing]");
}
});
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendLobbyOnePass(String strAction, String strName)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public String iCMDProcResidentSafety(Element ele) {
try {
// 원패스 사용여부 확인 (현재는 모바일 사용여부로 사용->추후 수정 필요)
String retStr = CheckiCMDProc("check_resident_safety");
if (retStr != null) return makeReply_check_resident_safety("deny", null, null, null);
// 단지서버 2.0 사용여부 확인
if (!NewServerUse()) {
return makeReply_check_resident_safety("deny", null, null, null);
}
// 거주자 안전 확인 사용 여부
if (!bEnableResidentSafetyCheck) {
return makeReply_check_resident_safety("deny", null, null, null);
}
String strSecurity = getSecurityMode();
String strTouch = getTimeStamp_ScreenTouched();
String strMagnetic = getTimeStamp_Magnetic();
return makeReply_check_resident_safety("ok", strSecurity, strTouch, strMagnetic);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return makeReply_check_resident_safety("fail", null, null, null);
} catch (Exception e) {
Log.e(TAG, "[Exception] iCMDProcResidentSafety(Element ele)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return makeReply_check_resident_safety("fail", null, null, null);
}
}
public String makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic) {
try {
String strReplyXml = XMLHeader;
strReplyXml += " \n";
if (strResult.equalsIgnoreCase("ok")) {
strReplyXml += " \"" + strSecurity + "\"\n";
strReplyXml += " \"" + strTouch + "\"\n";
strReplyXml += " \"" + magnetic + "\"\n";
}
strReplyXml += " \"null\"\n";
strReplyXml += " \n";
strReplyXml += "";
return strReplyXml;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return "ERROR";
} catch (Exception e) {
Log.e(TAG, "[Exception] makeReply_check_resident_safety(String strResult, String strSecurity, String strTouch, String magnetic)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return "ERROR";
}
}
private void saveBlackoutStatus(boolean bOccurred) {
try {
Log.i(TAG, "[saveBlackoutOccurred] ========== START ==========");
SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
SharedPreferences.Editor mEditor = mSharedPreferences.edit();
mEditor.putBoolean("status", bOccurred);
mEditor.commit();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] saveBlackoutStatus(boolean bOccurred)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private boolean getBlackoutStatus() {
try {
SharedPreferences mSharedPreferences = getSharedPreferences("BlackoutStatus", MODE_PRIVATE);
return mSharedPreferences.getBoolean("status", false);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] getBlackoutStatus()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
/**
* JEFF, 2019.12.25
* WallPadMain이 실행되면 매 1초마다 WallPadCall의 실행상태를 파악한다.
* WallPadMain에서 WallPadCall의 실행상태 확인을 요청하는 BR를 송신하고
* WallPadCall은 해당 BR이 수신되면 실행상태를 알리는 BR를 송신하여 이에 응답한다.
* WallPadMain은 이 응답 BR의 수신여부를 판단하여 WallPadCall의 실행여부를 판단한다.
*/
int MAX_WALLPADCALL_LIVE_CNT = 2;
int nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT; // MAX_WALLPADCALL_LIVE_CNT회 이상 응답이 없으면 WallPadCall이 종료된것으로 판단한다.
public static boolean bWallPadCallLive = false; // WallPadCall의 Live 상태를 나타낸다.
public static boolean bWallPadCallLive_old = false;
public static boolean m_bWallpadCallScreen = false;
int nWallPadCallPID = 0; // WallPadCall을 강제 종료하기 위한 PID (WallPadCall로부터 BR로 수신한다.)
Handler handlerCheckWallPadCallLive = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
sendWallPadCallLiveBR_Request();
handlerCheckWallPadCallLive.sendEmptyMessageDelayed(0, 1000);
}
};
private void sendWallPadCallLiveBR_Request() {
try {
// Log.i(TAG, "[sendWallPadCallLiveBR_Request] ===== START =====");
Intent mIntent = new Intent();
mIntent.setAction(Common.BR_REQUEST_WALLPADCALL_LIVE);
getApplicationContext().sendBroadcast(mIntent);
if (nWallPadCallACKCnt >= 0) {
nWallPadCallACKCnt--;
} else {
bWallPadCallLive = false;
Common.bWallPadCallLive = bWallPadCallLive;
}
if (bWallPadCallLive != bWallPadCallLive_old) {
if (bWallPadCallLive != getCallAppRunning()) {
//Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
setCallAppRunning(bWallPadCallLive);
}
}
bWallPadCallLive_old = bWallPadCallLive;
//Log.i(TAG, "[sendWallPadCallLiveBR_Request] bWallPadCallLive [" + bWallPadCallLive + "]");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendWallPadCallLiveBR_Request()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public boolean getWallpadCallScrean(int iScreen)
{
boolean bRet = false;
try {
switch (iScreen) {
case API_Menu.SubMenuCall.Door:
bRet = false;
break;
case API_Menu.SubMenuCall.Lobby:
bRet = false;
break;
case API_Menu.SubMenuCall.Guard:
bRet = false;
break;
case API_Menu.SubMenuCall.Neighbor:
bRet = false;
break;
case API_Menu.SubMenuCall.PSTN:
bRet = false;
break;
case API_Menu.SubMenuCall.CallList:
bRet = true;
break;
case API_Menu.SubMenuCall.Visitor:
bRet = true;
break;
default:
bRet = false;
break;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] setChangeScreen->Screen Create");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
return bRet;
}
BroadcastReceiver WallPadCallLiveBRCheck = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
String strActionName = intent.getAction();
int iWallpadCallScreen = intent.getIntExtra("WALLPADCALL_VIEW", 0);
// Log.d(TAG,"[WallPadCallLiveBRCheck] strActionName [" + strActionName + "]");
if (strActionName.equals(Common.BR_ACK_WALLPADCALL_LIVE)) {
bWallPadCallLive = true;
Common.bWallPadCallLive = bWallPadCallLive;
nWallPadCallACKCnt = MAX_WALLPADCALL_LIVE_CNT;
m_bWallpadCallScreen = getWallpadCallScrean(iWallpadCallScreen);
Log.w(TAG, "[WallPadCallLiveBRCheck] bWallPadCallLive [" + bWallPadCallLive + "] iWallpadCallScreen [" + iWallpadCallScreen + "]");
} else {
Log.w(TAG, "[WallPadCallLiveBRCheck] Not supported strActionName [" + strActionName + "]");
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] BroadcastReceiver -> WallPadCallLiveBRCheck");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
};
static class CALLCTRLHANDLERMSG {
static final int RELEASE_BLOCK_FRONTCALL = 100;
}
boolean bBlockFrontCall = false;
Handler handlerCallCtrl = new Handler() {
public void handleMessage(Message msg) {
super.handleMessage(msg);
int nMSG = msg.what;
switch (nMSG) {
case CALLCTRLHANDLERMSG.RELEASE_BLOCK_FRONTCALL:
bBlockFrontCall = false;
break;
}
}
};
/**
* JEFF, 2019.12.31
* WallPadCall 실행여부를 DB에 저장한다.
* WallPadMain에서 WallPadCall의 실행여부를 판단하여 DB에 저장을 하고, 다른 App들이 해당 DB값을 참조한다.
* 원래 WallPadMain에서도 해당값을 참조했지만, 오류가 많아 BR 통신방식으로 변경함
*/
public void setCallAppRunning(boolean bRunning) {
try {
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
mWallpadStatusData.SetCallAPKStatus(bRunning);
mWallpadStatusData.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] setCallAppRunning(boolean bRunning)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private boolean getCallAppRunning() {
boolean bRunning = false;
try {
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
bRunning = wallpadStatusData.GetCallAPKStatusRunning();
wallpadStatusData.closeDB();
// Log.d(TAG, "[getCallAppRunning] bRunning = " + bRunning);
return bRunning;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.d(TAG, "[Exception] getCallAppRunning()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
/**
* 통화앱 종료코드
*/
public void killWallPadCall() {
try {
Log.i(TAG, "[killWallPadCall] ===== START =====");
// ActivityManager mActivityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
// mActivityManager.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
Log.w(TAG, "[killWallPadCall] bWallPadCallLive [" + bWallPadCallLive + "], nWallPadCallPID [" + nWallPadCallPID + "]");
// ActivityManager aM = (ActivityManager) getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
// aM.killBackgroundProcesses("kr.co.icontrols.wallpadcall");
// android.os.Process.killProcess(nWallPadCallPID);
// List list = servMng.getRunningAppProcesses();
// if(list != null){
// for(int i=0;i mRunningTaskInfo = mActivityManager.getRunningTasks(1);
ComponentName mComponentName = mRunningTaskInfo.get(0).topActivity;
Log.e(TAG, "[checkForegroundActivity] mComponentName [" + mComponentName + "]");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] checkForegroundActivity()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* JEFF, 2020.01.04
* IHN-D101 국선전화 링시작시 링이벤트를 주기적으로 발생시키는 쓰레드
* IGW-300은 국선전화 링의 시작과 끝만 알려주므로, 통화시나리오를 처리하기에 어려움이 있다.
* - 통화앱이 종료되는 시점에 링이 발생하는 경우, 국선전화 벨 안울릴 가능성 있음
* - 국선전화 링 시작 신호를 놓치는 경우, 벨 안울림
*/
static long lConnectionPeriod = 0;
static int CONNECT_TIMEOUT = (1000 * 60) * 3; // 국선전화 링이 지속되는 경우 최대 3분까지만 링을 울리고, 종료 (일반전화 시험시 3분간만 벨 울림)
boolean bRingGeneratorRun = false;
private void startIGW300RingGenerator() {
try {
Log.v(TAG, "[startIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
if (mIGW300RingGeneratorThread == null && !bRingGeneratorRun) {
bRingGeneratorRun = true;
mIGW300RingGeneratorThread = new IGW300RingGeneratorThread();
mIGW300RingGeneratorThread.start();
} else
Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is not null!!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] startIGW300RingGenerator()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private void stopIGW300RingGenerator() {
try {
Log.v(TAG, "[stopIGW300RingGenerator] bRingGeneratorRun [" + bRingGeneratorRun + "]");
if (mIGW300RingGeneratorThread != null || bRingGeneratorRun) {
lConnectionPeriod = -999;
bRingGeneratorRun = false;
mIGW300RingGeneratorThread = null;
} else Log.v(TAG, "[startIGW300RingGenerator] mIGW300RingGeneratorThread is null!!!");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] stopIGW300RingGenerator()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private IGW300RingGeneratorThread mIGW300RingGeneratorThread;
private class IGW300RingGeneratorThread extends Thread {
public IGW300RingGeneratorThread() {
Log.i(TAG, "============ [IGW300RingGeneratorThread()] ============");
}
public void run() {
try {
Log.v(TAG, "[IGW300RingGeneratorThread().run()] bRingGeneratorRun [" + bRingGeneratorRun + "]");
if (bRingGeneratorRun)
Thread.sleep(3000); // 최초 발생시 3초 지연, 이미 PSTN 신호를 최초에 올려줌, 중복 방지
lConnectionPeriod = System.currentTimeMillis() + CONNECT_TIMEOUT;
while ((System.currentTimeMillis() < lConnectionPeriod) && bRingGeneratorRun) {
if (bRingGeneratorRun) sendPSTNRingEvent(WallPadInterface.EVT_RING);
Log.v(TAG, "[IGW300RingGeneratorThread().run()] ========== RING ==========");
try {
if (bRingGeneratorRun) Thread.sleep(5000); // 5초에 한번씩 링 발생 (국제 규격은 2초~10초)
} catch (InterruptedException e) {
Log.e(TAG, "[InterruptedException] Thread.sleep(5000)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
bRingGeneratorRun = false;
Log.i(TAG, "[IGW300RingGeneratorThread().run()] ===== while end =====");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] IGW300RingGeneratorThread.run()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
}
private void sendPSTNRingEvent(int nKeyCode) {
try {
Log.i(TAG, "[sendPSTNRingEvent] [" + nKeyCode + "]");
KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, nKeyCode);
Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
intent.putExtra("keycode", nKeyCode);
getApplicationContext().sendBroadcast(intent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendPSTNRingEvent()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
/**
* 월패드 타입 판별
*
* @return bResult
* false: 메인월패드
* true: 서브월패드
*/
public boolean getIsSubWallpad() {
boolean bResult = false;
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
String[] DBinfo = mWallpadDeviceSet.GetSettingData("서브월패드");
mWallpadDeviceSet.closeDB();
if (DBinfo != null) {
if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
else bResult = false;
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getIsSubWallpad()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
Log.d(TAG, "[getIsSubWallpad] bResult [" + bResult + "]");
return bResult;
}
/**
* JEFF, 2020.02.05
* 월패드 비상접점 신호 사용 여부 확인
*/
public boolean getEmergencyIOUsage() {
boolean bResult = false;
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this);
bResult = mWallpadDeviceSet.Get_EmergencyContact_SwitchUse();
mWallpadDeviceSet.closeDB();
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getEmergencyIOUsage()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
Log.d(TAG, "[getEmergencyIOUsage] bResult [" + bResult + "]");
return bResult;
}
/**
* JEFF, 2020.02.05
* 거동수상자 녹화기능 활성화 확인
* 스마트현관카메라 사용여부와 거동수상자 녹화기능 사용 여부를 확인하여 결과를 반환한다.
* 스마트IOT현관카메라 : 현산, 스마트현관카메라-효성 : 효성중공업, 스마트현관카메라-대우 : 대우건설
* 조건 : 스마트 현관카메라를 사용하며, 거동수상자 녹화기능이 활성화된 경우에 true 반환.
*/
public boolean getStrangerRecordingManagerSetting() {
boolean bResult = false;
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
try {
int[] nFrontCam = mWallpadDeviceSet.Get_RFDoorCAM_Info();
boolean bRecord = mWallpadDeviceSet.Get_Stranger_RecordUse();
mWallpadDeviceSet.closeDB();
if (nFrontCam[0] == COMPONENT_USE) {
if (nFrontCam[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART || nFrontCam[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) {
if (bRecord) bResult = true;
else bResult = false;
} else bResult = false;
} else bResult = false;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
mWallpadDeviceSet.closeDB();
} catch (Exception e) {
mWallpadDeviceSet.closeDB();
Log.e(TAG, "[Exception] getStrangerRecordingManagerSetting()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
Log.d(TAG, "[getStrangerRecordingManagerSetting] bResult [" + bResult + "]");
return bResult;
}
/**
* Edited by jeff (2020.06.22)
* LCD 잔상 현장 복구/보호를 위해 실행되고 있는 LCD Keeper를 종료하기 위해, 통화 App이 실행되면서
* backlight를 On하기 전에 이를 알리는 BR를 수신하여 LCD Keeper를 종료한다.
*
* @param bOn
*/
private void sendLCDBacklightStatus(boolean bOn) {
try {
Log.d(TAG, "[sendLCDBacklightStatus] bOn [" + bOn + "]");
Intent mIntent = new Intent();
if (bOn) mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_ON);
else mIntent.setAction(define.NOTIFY_ACNAME_LCD_BACKLIGHT_OFF);
getApplicationContext().sendBroadcast(mIntent);
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] sendLCDBacklightStatus(boolean bOn)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
// 명칭 관련
boolean bRoomNameLog = true;
public static final int HEATING = 1;
public static final int LIGHT = 2;
private String[] mDefaultRoomNameList_Light = new String[]{"거실", "주방", "방1", "방2", "방3", "방4", "방5", "방6", "방7"};
private String[] mDefaultRoomNameList_Light_HS = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
private String[] mDefaultRoomNameList_Heating = new String[]{"거실", "침실4", "침실1", "파우더룸", "침실2", "주방1", "침실3",
"복도1", "욕실1", "욕실2","보조주방","욕실3","욕실4","욕실5","복도2", "현관", "신발장", "창고", "주방2", "간이주방"};
private String[] mDefaultRoomNameList_Heating_easymode = new String[]{"거실", "방1", "방2", "방3", "방4", "방5", "방6", "방7", "방8"};
/**
* DB 에서 룸이름 정보를 가져온다.
*
* @return (String []) null - 실패, not null
*/
private String[] getDBRoomName() {
try {
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
String[] strRoomNameList = wallpadStatusData.GetDevRoomName();
wallpadStatusData.closeDB();
if (strRoomNameList == null) {
Log.e(TAG, "[getDBRoomName] strRoomNameList is null!!");
return null;
}
if (bRoomNameLog) {
for (int i = 0; i < strRoomNameList.length; i++)
Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
}
return strRoomNameList;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getDBRoomName()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return null;
}
/**
* DB 에서 룸이름 정보를 가져온다. 난방, 조명 개발 명칭 가져오기
*
* @param nDeviceType - int
* @return (String []) null - 실패, not null
*/
private String[] getDBRoomName(int nDeviceType) {
try {
String[] strRoomNameList = null;
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
if (nDeviceType == HEATING) {
strRoomNameList = wallpadStatusData.GetDevRoomName("heating");
} else {
strRoomNameList = wallpadStatusData.GetDevRoomName("light");
}
wallpadStatusData.closeDB();
if (strRoomNameList == null) {
Log.e(TAG, "[getDBRoomName] strRoomNameList is null !!!");
return null;
}
if (bRoomNameLog) {
for (int i = 0; i < strRoomNameList.length; i++)
Log.i(TAG, "[getDBRoomName] strRoomNameList[" + i + "] " + strRoomNameList[i]);
}
return strRoomNameList;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[DB_GetRoomName] getDBRoomName(int nDeviceType)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return null;
}
/**
* DB에서 방 이름을 가져와서 방 명칭 관련 변수에 값을 넣는다.
**/
private void getRoomName() {
try {
Log.i(TAG, "[getRoomName] ====================");
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getRoomName()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
public boolean getEasyModeUXUsage() {
try {
WallpadDeviceSet deviceSet = new WallpadDeviceSet(getApplicationContext());
boolean bSupport = deviceSet.Get_EasyModeUX_Support();
deviceSet.closeDB();
WallpadStatusData data = new WallpadStatusData(getApplicationContext());
boolean bUse = data.GetEasyModeUxUse();
data.closeDB();
Log.d(TAG, "[getEasyModeUXUsage] bSupport [" + bSupport + "], bUse [" + bUse + "]");
return bSupport & bUse;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getEasyModeUXUsage()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return false;
}
/**
* 월패드 DB에 설정된 현관카메라 설정정보와 BSP에 설정된 현관카메라 프로파일의 정보를 비교하기 위한 함수
* 두 정보를 비교하여 값이 서로 다른 경우에는 JNI CameraSet을 이용하여 DB 설정값대로 카메라 프로파일을 재설정 한다.
* 재설정 5초 후 월패드 재부팅을 실행한다.
* 2020.11.18 SEULKI
*/
public void checkDoorCamConfig() {
try {
if (Build.VERSION.SDK_INT > 23) {
if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101 || Version.getModelType() == Version.MODEL_TYPE.IHN_D101_I || Version.getModelType() == MODEL_TYPE.IHN_D101_I_LX2
|| Version.getModelType() == Version.MODEL_TYPE.IHN_D101K || Version.getModelType() == Version.MODEL_TYPE.IHN_D101K_I
|| Version.getModelType() == MODEL_TYPE.IHN_1010GL || Version.getModelType() == MODEL_TYPE.IHN_1010GL_I
|| Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_2443 || Version.getModelType() == Version.MODEL_TYPE.IHN_1010GL_I_6410
|| Version.getModelType() == MODEL_TYPE.IHN_D101_I_OCF) {
if (!checkAvailableBSPDoorCamConfig()) {
Log.w(TAG, "[checkDoorCamConfig] Current BSP Version is not support!!");
return;
}
if (getDBDoorCamConfig() != getBSPDoorCamConfig()) { //월패드DB 값과 BSP 설정값이 다른 경우 DB 설정값으로 재설정
Log.w(TAG, "[checkDoorCamConfig] ===== setCameraConfigure[" + getDBDoorCamConfig() + "] =====");
if (mIOInterface != null)
mIOInterface.setCameraConfigure(getDBDoorCamConfig());
// 재부팅
setDefaultLauncher();
Intent intent = new Intent();
if (intent != null) {
intent.setAction(define.NOTIFY_ACNAME);
intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_DEVICEREBOOT);
getApplicationContext().sendBroadcast(intent);
}
}
}
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", "", re);
} catch (Exception e) {
Log.e(TAG, "[Exception] checkDoorCamConfig(");
LogUtil.errorLogInfo("", "", e);
}
}
/**
* 현재 BSP의 카메라 설정정보 확인 기능 제공 여부 확인
* BSP 2020.11.18.01 버전 부터 해당 기능 지원 (이전버전은 지원하지 않음)
* BSP 2021.02.25.01 버전 부터 스마트현관카메라 좌우반전 기능 지원 추가
*
* @return true: 지원, false: 미지원
*/
int nCriterionVer = 2020111801; // BSP 버전 2020.11.18.01
private boolean checkAvailableBSPDoorCamConfig() {
try {
int nCurrentVer = Integer.parseInt(Build.DISPLAY.replace(".", ""));
Log.i(TAG, "[checkAvailableBSPDoorCamConfig] nCurrentVer [" + nCurrentVer + "], nCriterionVer [" + nCriterionVer + "]");
if (nCurrentVer >= nCriterionVer) {
return true;
} else return false;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] checkAvailableBSPDoorCamConfig(");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return false;
}
}
/**
* BSP에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
*
* @return 0 - 스마트현관카메라
* 2 - 스마트현관카메라 좌우반전
* 1 - 일반현관카메라
* 2020.11.18 SEULKI
*/
public int getBSPDoorCamConfig() {
InputStreamReader is = null;
try {
Runtime mRuntime = Runtime.getRuntime();
String cmd = "getprop camera.setting.value";
if (mRuntime != null) {
Process mProcess = mRuntime.exec(cmd);
is = new InputStreamReader(mProcess.getInputStream());
BufferedReader br = new BufferedReader(is);
String line;
String strResult = null;
if (br != null) {
while ((line = br.readLine()) != null) {
strResult = line;
}
if (strResult != null) {
Log.d(TAG, "[getBSPDoorCamConfig] strResult [" + strResult + "]");
if (strResult.equals("0")) {
Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD CAMERA");
return 0;
} else if (strResult.equals("1")) {
Log.d(TAG, "[getBSPDoorCamConfig] BSP - NORMAL CAMERA");
return 1;
} else if (strResult.equals("2")) {
Log.d(TAG, "[getBSPDoorCamConfig] BSP - AHD FLIP CAMERA");
return 2;
} else {
Log.w(TAG, "[getBSPDoorCamConfig] Camera Config not correct!!!");
return -1;
}
}
}
}
return -1;
} catch (Exception e) {
Log.e(TAG, "[Exception] getBSPDoorCamConfig()");
e.printStackTrace();
return -1;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
LogUtil.errorLogInfo("", TAG, e);
}
is = null;
}
}
}
/**
* 월패드DB에 설정된 현관카메라 프로파일의 정보를 확인하기 위한 함수
*
* @return 0 - 스마트현관카메라
* 2 - 스마트현관카메라 좌우반전
* 1 - 일반현관카메라
* 2020.11.18 SEULKI
*/
public int getDBDoorCamConfig() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
if (mWallpadDeviceSet != null) {
int[] nType = mWallpadDeviceSet.Get_RFDoorCAM_Info();
boolean bFlip = mWallpadDeviceSet.Get_SmartIOTCamFlipUse();
mWallpadDeviceSet.closeDB();
if (nType != null) {
Log.d(TAG, "[getDBDoorCamConfig] Camera [" + nType[1] + "], bFlip [" + bFlip + "]");
if (nType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART || nType[1] == WallpadDeviceSet.DOORTYPE_HDCAM) {
// Log.e(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
if (bFlip) {
Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT CAMERA or HD CAMERA");
return 0;
} else {
Log.d(TAG, "[getDBDoorCamConfig] DB - SMART IOT FLIP CAMERA");
return 2;
}
} else {
Log.e(TAG, "[getDBDoorCamConfig] DB - BASIC CAMERA");
return 1;
}
}
}
return -1;
} catch (Exception e) {
Log.e(TAG, "[Exception] getDBDoorCamConfig()");
e.printStackTrace();
return -1;
}
}
/**
* 공기질 센서 사용여부 확인
*
* @return true - 사용함, false: 사용안함
*/
boolean bAirQualityEnable = false;
private boolean getAirQualityUsage() {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
try {
int nAirQualityEnable = mWallpadDeviceSet.GetDeviceSetted("센서AP"); // 공기질 센서
mWallpadDeviceSet.closeDB();
if (nAirQualityEnable == WallpadDeviceSet.DEV_DATA_ENABLE) {
bAirQualityEnable = true;
Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
} else {
bAirQualityEnable = false;
Log.i(TAG, "[getAirQualityUsage] bAirQualityEnable [" + bAirQualityEnable + "]");
}
return bAirQualityEnable;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
return false;
} catch (Exception e) {
Log.e(TAG, "[Exception] getAirQualityUsage()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
return false;
}
}
String strAirQualityFWVer = "";
String strAirQualityProtocolVer = "";
String strAirQualityInfo = "";
private String getAirQualityInfo() {
try {
AirQualitySensorAPI mAirQualitySensorAPI = mWallPadAPI.Get_SensorAp_API();
if (mAirQualitySensorAPI != null) {
int nRet = mAirQualitySensorAPI.Refresh(false);
if (nRet >= 0) {
Log.i(TAG, "[getAirQualityInfo] ");
DataClasses.AirQualityData.Info mAirQualityInfo = mAirQualitySensorAPI.mAirQualityData.info;
strAirQualityFWVer = "FW" + (int) (mAirQualityInfo.FWVer_Year + 2000) + "." + mAirQualityInfo.FWVer_Month + "." + mAirQualityInfo.FWVer_Day + "." + mAirQualityInfo.FWVer_No;
strAirQualityProtocolVer = "PRTC" + mAirQualityInfo.ProtocolVer_Main + "." + mAirQualityInfo.ProtocolVer_Sub;
strAirQualityInfo = strAirQualityFWVer + "/" + strAirQualityProtocolVer;
return strAirQualityInfo;
} else return "FAIL";
} else return "NULL";
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return "ERROR";
} catch (Exception e) {
Log.e(TAG, "[Exception] getAirQualityInfo()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return "ERROR";
}
}
private String getAOSVerCode() {
try {
int nOSVer = Build.VERSION.SDK_INT;
switch (nOSVer) {
case Build.VERSION_CODES.BASE:
return "SDK(" + nOSVer + ")/AOS(1.0, BASE)";
case Build.VERSION_CODES.BASE_1_1:
return "SDK(" + nOSVer + ")/AOS(1.1, BASE_1_1)";
case Build.VERSION_CODES.CUPCAKE:
return "SDK(" + nOSVer + ")/AOS(1.5, CUPCAKE)";
case Build.VERSION_CODES.DONUT:
return "SDK(" + nOSVer + ")/AOS(1.6, DONUT)";
case Build.VERSION_CODES.ECLAIR:
return "SDK(" + nOSVer + ")/AOS(2.0, ECLAIR)";
case Build.VERSION_CODES.ECLAIR_0_1:
return "SDK(" + nOSVer + ")/AOS(2.0.1, ECLAIR_0_1)";
case Build.VERSION_CODES.ECLAIR_MR1:
return "SDK(" + nOSVer + ")/AOS(2.1, ECLAIR_MR1)";
case Build.VERSION_CODES.FROYO:
return "SDK(" + nOSVer + ")/AOS(2.2, FROYO)";
case Build.VERSION_CODES.GINGERBREAD:
return "SDK(" + nOSVer + ")/AOS(2.3, GINGERBREAD)";
case Build.VERSION_CODES.GINGERBREAD_MR1:
return "SDK(" + nOSVer + ")/AOS(2.3.3, GINGERBREAD_MR1)";
case Build.VERSION_CODES.HONEYCOMB:
return "SDK(" + nOSVer + ")/AOS(3.0, HONEYCOMB)";
case Build.VERSION_CODES.HONEYCOMB_MR1:
return "SDK(" + nOSVer + ")/AOS(3.1, HONEYCOMB_MR1)";
case Build.VERSION_CODES.HONEYCOMB_MR2:
return "SDK(" + nOSVer + ")/AOS(3.2, HONEYCOMB_MR2)";
case Build.VERSION_CODES.ICE_CREAM_SANDWICH:
return "SDK(" + nOSVer + ")/AOS(4.0, ICE_CREAM_SANDWICH)";
case Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1:
return "SDK(" + nOSVer + ")/AOS(4.0.3, ICE_CREAM_SANDWICH_MR1)";
case Build.VERSION_CODES.JELLY_BEAN:
return "SDK(" + nOSVer + ")/AOS(4.1, JELLY_BEAN)";
case Build.VERSION_CODES.JELLY_BEAN_MR1:
return "SDK(" + nOSVer + ")/AOS(4.2, JELLY_BEAN_MR1)";
case Build.VERSION_CODES.JELLY_BEAN_MR2:
return "SDK(" + nOSVer + ")/AOS(4.3, JELLY_BEAN_MR2)";
case Build.VERSION_CODES.KITKAT:
return "SDK(" + nOSVer + ")/AOS(4.4, KITKAT)";
case Build.VERSION_CODES.KITKAT_WATCH:
return "SDK(" + nOSVer + ")/AOS(4.4W, KITKAT_WATCH)";
case Build.VERSION_CODES.LOLLIPOP:
return "SDK(" + nOSVer + ")/AOS(5.0, LOLLIPOP)";
case Build.VERSION_CODES.LOLLIPOP_MR1:
return "SDK(" + nOSVer + ")/AOS(5.1, LOLLIPOP_MR1)";
case Build.VERSION_CODES.M:
return "SDK(" + nOSVer + ")/AOS(6.0, MARSHMALLOW)";
case Build.VERSION_CODES.N:
return "SDK(" + nOSVer + ")/AOS(7.0, NOUGAT)";
case Build.VERSION_CODES.N_MR1:
return "SDK(" + nOSVer + ")/AOS(7.1, NOUGAT_MR1)";
case Build.VERSION_CODES.O:
return "SDK(" + nOSVer + ")/AOS(8.0, OREO)";
case Build.VERSION_CODES.O_MR1:
return "SDK(" + nOSVer + ")/AOS(8.1, OREO_MR1)";
case Build.VERSION_CODES.P:
return "SDK(" + nOSVer + ")/AOS(9.0, PIE)";
case Build.VERSION_CODES.CUR_DEVELOPMENT:
return "SDK(" + nOSVer + ")/CUR_DEVELOPMENT";
default:
return "SDK(" + nOSVer + ")/UNKNOWN";
}
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return "ERROR";
} catch (Exception e) {
Log.e(TAG, "[Exception] getAirQualityInfo()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return "ERROR";
}
}
/**
* 조명 ON/OFF 상태
*/
public static class LIGHT_ONOFF {
/**
* ON
*/
public static byte ON = (byte) 0x01;
/**
* OFF
*/
public static byte OFF = (byte) 0x02;
/**
* OFF
*/
public static byte DONTCARE = (byte) 0xFF;
}
private byte convertSmartLightPowerValue(String cmd) {
try {
if (cmd.equalsIgnoreCase("on")) return LIGHT_ONOFF.ON;
else if (cmd.equalsIgnoreCase("off")) return LIGHT_ONOFF.OFF;
else return LIGHT_ONOFF.DONTCARE;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
return -1;
} catch (Exception e) {
Log.e(TAG, "[Exception] convertSmartLightPowerValue(String cmd)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return -1;
}
}
/** 거주자 안정 확인 서비스용 코드 시작 */
/**
* Edited by Jeff, 2021.06.15
*/
public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
public boolean bEnableResidentSafetyCheck = false;
private void getResidentSafetyCheckSetting() {
try {
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
mWallpadDeviceSet.closeDB();
Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE)
bEnableResidentSafetyCheck = true;
else bEnableResidentSafetyCheck = false;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private String getSecurityMode() {
try {
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
int nStatus = mWallpadStatusData.GetAlarmStatus();
mWallpadStatusData.closeDB();
String strSecurity = "null";
if (nStatus == WallpadStatusData.ALARM_NONE) strSecurity = "normal";
else if (nStatus == WallpadStatusData.ALARM_ARISE) strSecurity = "emergency";
else if (nStatus == WallpadStatusData.ALARM_STOP) strSecurity = "emergency_stop";
else if (nStatus == WallpadStatusData.GUARD_IN) strSecurity = "occupied";
else if (nStatus == WallpadStatusData.GUARD_OUT) strSecurity = "unoccupied";
else if (nStatus == WallpadStatusData.GUARD_OUT_WAIT) strSecurity = "waitunoccupied";
return strSecurity;
} catch (Exception e) {
Log.e(TAG, "[Exception] getSecurityMode()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
String ResidentSafetyCheck_TimeStamp = "ResidentSafetyCheck_TimeStamp"; // SharedPreferences name
String Touch = "Touch";
String Magnetic = "Magnetic";
private void setTimeStamp_ScreenTouched() {
try {
Calendar mCal = Calendar.getInstance();
String strTouchTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
// Log.i(TAG, "[setTimeStamp_ScreenTouched] strTime [" + strTime + "]");
SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
SharedPreferences.Editor mEditor = mSharedPreferences.edit();
mEditor.putString(Touch, strTouchTime);
mEditor.apply();
} catch (Exception e) {
Log.e(TAG, "[Exception] setTimeStamp_ScreenTouched()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private String getTimeStamp_ScreenTouched() {
try {
SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
String strTouchTime = mSharedPreferences.getString(Touch, null);
// Log.e(TAG, "[getTimeStamp_ScreenTouched] strTouchTime [" + strTouchTime + "]");
return strTouchTime;
} catch (Exception e) {
Log.e(TAG, "[Exception] getTimeStamp_ScreenTouched()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
private void setTimeStamp_Magnetic() {
try {
Calendar mCal = Calendar.getInstance();
String strMagneticTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(mCal.getTime());
// Log.i(TAG, "[setTimeStamp_Magnetic] strTime [" + strTime + "]");
SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
SharedPreferences.Editor mEditor = mSharedPreferences.edit();
mEditor.putString(Magnetic, strMagneticTime);
mEditor.apply();
} catch (Exception e) {
Log.e(TAG, "[Exception] setTimeStamp_Magnetic()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private String getTimeStamp_Magnetic() {
try {
SharedPreferences mSharedPreferences = getSharedPreferences(ResidentSafetyCheck_TimeStamp, MODE_PRIVATE);
String strMagneticTime = mSharedPreferences.getString(Magnetic, null);
// Log.e(TAG, "[getTimeStamp_Magnetic] strMagneticTime [" + strMagneticTime + "]");
return strMagneticTime;
} catch (Exception e) {
Log.e(TAG, "[Exception] getTimeStamp_Magnetic()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
return null;
}
}
/** 거주자 안정 확인 서비스용 코드 종료 */
/**
* 가스밸브를 쿡탑콘센트로 사용
*/
private boolean bGasAsCooktopOutlet = false; // 쿡탑콘센트에 가스밸브 프로토콜이 적용된 경우
/** iCMD 연동시 "remote_access_smartlight.request/reply" CMD 지원여부 */
/** DC 분전반을 사용하는 경우, 조명의 디밍/색온도 제어 지원여부 결정 */
/**
* false: livinglight/light로 livinglight/light 제어, true : 기존 livinglight/light로 smartlight 제어,
*/
// iCMD 연동시 smartlight(DC분전반 조명제어)기기를 기존의 livinglight/light(거실조명/각방조명)로 대체 여부
private boolean bLightCMDUseAsSmartLight = false; // 스마트홈 2.0 앱에서 smartlight 제어기능을 추가하기에 더이상 사용하지 않는다 (2021.05.18)
/**
* 기기 연동 제어 옵션 설정 확인
*/
// 가스밸브 프로토콜을 사용하는 쿡탑콘센트 적용여부
// 기존 조명 제어 CMD(livinglight/light)를 이용하여 smartlight 제어 여부
private void getDeviceCtrlOption() {
int nLightType = WallpadDeviceSet.REMOTECTRL_BASIC_LIGHT;
boolean bUserSetting_SmartLightEnable = false;
int nDPType = Version.DISTRIBUTION_MODEL.OTHER;
WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext());
WallpadStatusData mWallpadStatusData = new WallpadStatusData(getApplicationContext());
try {
bGasAsCooktopOutlet = mWallpadDeviceSet.Get_CookTopConcent_Use();
nLightType = mWallpadDeviceSet.Get_RemoteCtrl_LightType(); // 원격제어 조명 타입 확인 (일반조명/스마트조명/사용자선택)
nDPType = mWallpadDeviceSet.Get_DistributionPannelType_Info(); // DC분전반 확인
mWallpadDeviceSet.closeDB();
bUserSetting_SmartLightEnable = mWallpadStatusData.GetRemoteControlSmartLight(); // 원격제어 조명 제어 타입 확인 (사용자 설정)
mWallpadStatusData.closeDB();
if (nDPType == Version.DISTRIBUTION_MODEL.SMART_DIST) {
// 스마트 분전반을 사용하는 경우에만
// 관리자 설정(원격제어 조명 타입)과 사용자 설정(원격제어시 스마트 조명 설정)을 확인한다.
if (nLightType == WallpadDeviceSet.REMOTECTRL_USER_SELECT) {
// 사용자선택인 경우
if (bUserSetting_SmartLightEnable) bLightCMDUseAsSmartLight = false;
else bLightCMDUseAsSmartLight = true;
} else if (nLightType == WallpadDeviceSet.REMOTECTRL_SMART_LIGHT) {
// 스마트조명을 사용하는 경우
bLightCMDUseAsSmartLight = false;
} else {
// 스마트조명을 사용하지 않는 경우
bLightCMDUseAsSmartLight = true;
}
} else {
// 스마트분전반을 사용하지 않는 경우
bLightCMDUseAsSmartLight = true;
}
Log.i(TAG, "[getDeviceCtrlOption] bLightCMDUseAsSmartLight [" + bLightCMDUseAsSmartLight + "]");
} catch (Exception e) {
if (mWallpadDeviceSet != null) mWallpadDeviceSet.closeDB();
if (mWallpadStatusData != null) mWallpadStatusData.closeDB();
Log.e(TAG, "[Exception] getDeviceCtrlOption()");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
}
private String[] getRoomNameFromDBV2(String strDeviceType) {
try {
String[] RoomNameList = null;
WallpadStatusData wallpadStatusData = new WallpadStatusData(getApplicationContext());
RoomNameList = wallpadStatusData.GetDevRoomNameList(strDeviceType);
wallpadStatusData.closeDB();
if (RoomNameList == null) {
Log.e(TAG, "[getRoomNameFromDBV2] - RoomNameList is null !!!");
return null;
}
Log.i(TAG, "[getRoomNameFromDBV2] RoomNameList " + Arrays.toString(RoomNameList));
return RoomNameList;
} catch (RuntimeException re) {
LogUtil.errorLogInfo("", TAG, re);
} catch (Exception e) {
Log.e(TAG, "[Exception] getRoomNameFromDBV2(int Device)");
//e.printStackTrace();
LogUtil.errorLogInfo("", TAG, e);
}
return null;
}
// private void demoPushMsg()
// {
// String urlStr1 = "";
//
// if(android.os.Build.VERSION.SDK_INT > 9 )
// {
// StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
// StrictMode.setThreadPolicy(policy);
// }
//
// String Msg ="";
// try {
// Msg = URLEncoder.encode("미세먼지가 많아져서 환기를 동작시켰습니다." , "euc-kr");
// } catch (UnsupportedEncodingException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
// urlStr1 = "http://61.33.215.251/push/push.php?dong=0102&ho=1804&msg=";
// Log.d(TAG , "################ : " + urlStr1);
// try
// {
// //URLEncoder.encode(s)
// HttpClient client = new DefaultHttpClient();
//
// HttpGet get = new HttpGet();
// //get.setURI(new URI("http://www.google.com/"));
// get.setURI(new URI(encodeUrl(urlStr1+Msg) ) );
// HttpResponse resp = client.execute(get);
// BufferedReader br = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
// String str = null;
// StringBuilder sb = new StringBuilder();
// while((str = br.readLine()) != null)
// {
// sb.append(str).append("\n");
// }
// br.close();
// //TextView txt = (TextView) findViewById(R.id.txt_get);
// //txt.setText(sb.toString());
// }catch(Exception e)
// {
//
// e.printStackTrace();
//
// }
//
//
// }
//
//
// public static boolean checkForExternal(String str) {
// int length = str.length();
// for (int i = 0; i < length; i++) {
// if (str.charAt(i) > 0x7F) {
// return true;
// }
// }
// return false;
// }
//
// private static final Pattern COLON = Pattern.compile("%3A", Pattern.LITERAL);
// private static final Pattern SLASH = Pattern.compile("%2F", Pattern.LITERAL);
// private static final Pattern QUEST_MARK = Pattern.compile("%3F", Pattern.LITERAL);
// private static final Pattern EQUAL = Pattern.compile("%3D", Pattern.LITERAL);
// private static final Pattern AMP = Pattern.compile("%26", Pattern.LITERAL);
//
// public static String encodeUrl(String url) {
// if (checkForExternal(url)) {
// try {
// String value = URLEncoder.encode(url, "UTF-8");
// value = COLON.matcher(value).replaceAll(":");
// value = SLASH.matcher(value).replaceAll("/");
// value = QUEST_MARK.matcher(value).replaceAll("?");
// value = EQUAL.matcher(value).replaceAll("=");
// return AMP.matcher(value).replaceAll("&");
// } catch (UnsupportedEncodingException e) {
// //throw LOGGER.getIllegalStateException(e);
// return null;
// }
// } else {
// return url;
// }
// }
}