123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931 |
- package kr.co.icontrols.wallpadmain.util;
- import java.util.List;
- import kr.co.icontrols.gledeviceinterface.jni;
- import kr.co.icontrols.wallpadmain.declare.Common;
- import kr.co.icontrols.wallpadmain.declare.ID;
- import kr.co.icontrols.wallpadsupport.Version;
- import com.artncore.WallPadDataMgr.WallpadDeviceSet;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.deviceinterface.WallPadInterface;
- import com.artncore.wallpadapi.DLockAPI;
- import com.artncore.wallpadapi.DLockAPI.DOORSTATUS;
- import com.artncore.wallpadapi.FP_DlockAPI;
- import com.artncore.wallpadapi.IGW200dAPI;
- import com.artncore.wallpadapi.IGW300API;
- import com.artncore.wallpadapi.WallPadAPI;
- import android.app.ActivityManager;
- import android.app.ActivityManager.RunningTaskInfo;
- import android.content.BroadcastReceiver;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.os.Handler;
- import android.os.Message;
- import android.util.Log;
- import android.view.KeyEvent;
- import com.util.LogUtil;
- public class IGW300 {
- private Context mContext = null;
- private String TAG = "IGW300";
- private IGW300API mIGW300API = null;
- private WallPadAPI mWallPadAPI = null;
- private IGW300API.Data mIGW300API_Data = null;
- protected DLockAPI mDLockAPI = null;
- private DLockAPI doorLockAPI = null;
- private FP_DlockAPI FPdoorLockAPI = null;
- public IGW300(Context context , WallPadAPI wapi) {
- mContext = context;
- mWallPadAPI = wapi;
- initIGW300();
- registerIGW300InterfaceBR();
- getResidentSafetyCheckSetting();
- }
- public void registerIGW300InterfaceBR() {
- Log.i(TAG, "[registerIGW300InterfaceBR] ========== START ==========");
- IntentFilter filter = new IntentFilter();
- filter.addAction(Common.BR_IGW200FILTER );
- filter.addAction(Common.BR_EMER_LED_CONTROL );
- filter.addAction(IGW300API.SENSOR_BR_NAME);
- filter.addAction(Common.BR_CALLED_CID_ACK);
- mContext.registerReceiver(IGW300InterfaceBR, filter);
- Log.i(TAG, "[registerIGW300InterfaceBR] ========== END ==========");
- }
- private void checkSensor() {
- if (mIGW300API == null) return;
- if (mIGW300API_Data == null) return;
- if (Common.GetSensorSampleMode(mContext)) {
-
- return;
- }
- WallpadStatusData mWallpadStatusData = new WallpadStatusData(mContext);
- int nAlarmMode = mWallpadStatusData.GetAlarmStatus();
- mWallpadStatusData.closeDB();
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
- int StatusValLadder = mWallpadDeviceSet.GetDeviceSetted("피난사다리");
- mWallpadDeviceSet.closeDB();
- Log.d(TAG , "[checkSensor] nAlarmMode = " + nAlarmMode);
-
-
- if (nAlarmMode == WallpadStatusData.GUARD_OUT || nAlarmMode == WallpadStatusData.GUARD_IN) {
- Log.d(TAG , "[checkSensor] GUARD_OUT or GUARD_IN");
-
- if (mIGW300API_Data.senIn.In_Motion) {
- setSendEventBR(WallPadInterface.EVT_SENSOR_MOTIONIN);
- }
- if (mIGW300API_Data.senIn.Out_Motion) {
- setSendEventBR(WallPadInterface.EVT_SENSOR_MOTIONOUT);
- }
-
- if (mIGW300API_Data.senIn.Magnetic) {
- setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0);
- }
- }
- else {
- Log.d(TAG , "[checkSensor] nAlarmMode is not set!!!");
-
- }
-
- if (mIGW300API_Data.senIn.APU) {
-
-
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- WallPadInterface mWallPadInterface = new WallPadInterface();
- mWallPadInterface.DoControl(WallPadInterface.IOCTL_MOOD_BACKLIGHT_SET, 255);
- }
- 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() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
- setSendEventBR(WallPadInterface.EVT_BLACKOUT_OCCURRED);
- }
- }
- else {
-
- if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020GL) {
- WallPadInterface mWallPadInterface = new WallPadInterface();
- mWallPadInterface.DoControl(WallPadInterface.IOCTL_MOOD_BACKLIGHT_SET, 0);
- }
- 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() == Version.MODEL_TYPE.IHN_D101_I_OCF) {
- setSendEventBR(WallPadInterface.EVT_BLACKOUT_RELEASED);
- }
- }
-
- if (StatusValLadder == WallpadDeviceSet.DEV_DATA_ENABLE) {
- if (mIGW300API_Data.senIn.EVAC_Home) {
- if (nAlarmMode != WallpadStatusData.ALARM_ARISE && nAlarmMode != WallpadStatusData.ALARM_STOP )
- sendLadderEmergencyBR("ladder_Open");
- }
-
- if (mIGW300API_Data.senIn.EVAC_UP) {
- if (nAlarmMode != WallpadStatusData.ALARM_ARISE && nAlarmMode != WallpadStatusData.ALARM_STOP )
- sendLadderEmergencyBR("upladder_Open");
- }
- }
- }
- private int setSendEventBR(int code) {
- try {
- KeyEvent event = new KeyEvent(KeyEvent.ACTION_UP, code);
- Intent intent = new Intent("EVENT_DEVICE_CONTROL", null);
- intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
- intent.putExtra("keycode", code);
- mContext.sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -100;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] setSendEventBR(int code) code = " + code);
-
- LogUtil.errorLogInfo("", TAG, e);
- return -100;
- }
- return 0;
- }
- private void sendLadderEmergencyBR(String detailOption) {
- int base = 7000;
- int [] Menu_Id_List = { base+11, base+21 , base+31 , base+41};
- int Menu_Start_Option = 1;
- WallpadStatusData wdb = new WallpadStatusData(mContext);
- 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 mWallpadDeviceSet = new WallpadDeviceSet(mContext);
- int StatusVal = mWallpadDeviceSet.GetDeviceSetted("피난사다리");
- String pentHo = mWallpadDeviceSet.getPentHouseHoEscapeLadder();
- mWallpadDeviceSet.closeDB();
- Log.d(TAG, "[sendLadderEmergencyBR] pentHo [" + pentHo + "]");
- if (StatusVal == WallpadDeviceSet.DEV_DATA_NONE || StatusVal == WallpadDeviceSet.DEV_DATA_ENABLE) {
- Common.SendAppFinishReqBR(mContext);
- Intent newintent = new Intent(Intent.ACTION_MAIN);
- newintent.putExtra("MENU_ID_LIST", Menu_Id_List);
- newintent.putExtra("MENU_START_ID", Menu_Id_List[3]);
- newintent.putExtra("MENU_START_OPTION", Menu_Start_Option);
- newintent.putExtra("MENU_DETAIL_INFO", detailOption);
- newintent.setComponent(new ComponentName("kr.co.icontrols.wallpademergency", "kr.co.icontrols.wallpademergency.MainActivity"));
- newintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mContext.startActivity(newintent);
- }
- }
- protected String getForegroundAPP() {
- try {
- ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
- List<RunningTaskInfo> taskInfo = am.getRunningTasks(1);
- ComponentName topActivity=taskInfo.get(0).topActivity;
- String str=topActivity.getPackageName();
- return str;
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return " ";
- }
- catch (Exception e) {
-
- LogUtil.errorLogInfo("", TAG, e);
- return " ";
- }
- }
- private WallPadEmerButton mWallPadEmerButton = null;
- private boolean bMuticall_Front_Accept = false;
- private boolean bMulticall_PSTN_Accept = false;
- private boolean bPSTN_Connected = false;
- private boolean bMulticall_PSTN_Hold = false;
- private boolean bSubphone_Connected = false;
- BroadcastReceiver IGW300InterfaceBR = new BroadcastReceiver() {
- private boolean bFirst = true;
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.i(TAG, "[IGW300InterfaceBR] intent [" + intent + "]");
- String strActionName = intent.getAction();
- if (strActionName.equals(IGW300API.SENSOR_BR_NAME)) {
- updateDeviceStatus(false);
- checkSensor();
- }
- else if (strActionName.equals(Common.BR_CALLED_CID_ACK)) {
- Log.d( TAG , "[IGW300InterfaceBR] BR_CALLED_CID_ACK");
- }
- else if (strActionName.equals(Common.BR_IGW200FILTER)) {
- int kind = intent.getIntExtra("KIND",0);
- Log.i(TAG, "[IGW300InterfaceBR] strActionName : " + Common.BR_IGW200FILTER + ", kind : " + kind);
- switch (kind) {
- case Common.IGW200_DOOR_MONITERING :
- ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false);
- ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, true);
- break;
- case Common.IGW200_DOOR_CONNECT:
- bMuticall_Front_Accept = false;
- bSubphone_Connected = false;
- ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false);
- changeCallPath(IGW200dAPI.TEL_PATH.WPAD_DOOR);
- break;
- case Common.IGW200_DOOR_SUBPHONE_CONNECT:
- bMuticall_Front_Accept = false;
- bSubphone_Connected = true;
- ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false);
- changeCallPath(IGW200dAPI.TEL_PATH.SUB_DOOR);
- break;
- case Common.IGW200_DOOR_CLOSE:
- if (!bMuticall_Front_Accept) {
- if (!bPSTN_Connected) {
- changeCallPath(IGW200dAPI.TEL_PATH.OFF);
- }
- ctrlDeviceIO(IGW200dAPI.OUTPUT.DOOR_POWER, false);
- ctrlDeviceIO(IGW200dAPI.OUTPUT.BELL_CONT, false);
- }
- bSubphone_Connected = false;
- break;
- case Common.IGW200_PSTN_CONNECT:
- bPSTN_Connected = true;
- bMulticall_PSTN_Hold = false;
- bSubphone_Connected = false;
- changeCallPath(IGW200dAPI.TEL_PATH.WPAD_TEL);
- break;
- case Common.IGW200_PSTN_CLOSE:
- Log.d( TAG , "[IGW300InterfaceBR] IGW300_PSTN_CLOSE, bMulticall_PSTN_Hold : " + bMulticall_PSTN_Hold);
- if (!bMulticall_PSTN_Hold) {
- bPSTN_Connected = false;
- changeCallPath(IGW200dAPI.TEL_PATH.OFF);
- }
- else {
- bMulticall_PSTN_Hold = false;
- }
- bSubphone_Connected = false;
- break;
- case Common.IGW200_MOIP_SUBPHONE_CONNECT:
- bSubphone_Connected = true;
- changeCallPath(IGW200dAPI.TEL_PATH.MOIP_SUB);
- break;
- case Common.IGW200_MOIP_CLOSE:
- bSubphone_Connected = false;
- changeCallPath(IGW200dAPI.TEL_PATH.OFF);
- ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false);
- break;
- case Common.IGW200_VIDEO_FRONT:
- if (!bSubphone_Connected)
- ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, false);
- break;
- case Common.IGW200_VIDEO_LOBBY:
- if (!bSubphone_Connected)
- ctrlDeviceIO(IGW200dAPI.OUTPUT.VIDEO_SEL, true);
- break;
- case Common.MULTICALL_DOOR_ACCEPT :
- bMuticall_Front_Accept = true;
- if (bPSTN_Connected) {
- changeCallPath(IGW200dAPI.TEL_PATH.OFF);
- bPSTN_Connected = false;
- }
- break;
- case Common.MULTICALL_PSTN_ACCEPT :
- bMulticall_PSTN_Accept = true;
- break;
- case Common.MULTICALL_HOLD_DOOR_ACCEPT:
- bMuticall_Front_Accept = true;
- bMulticall_PSTN_Hold = true;
- break;
- case Common.IGW200_SENSOR_CHECK:
- Log.d(TAG, "[IGW300InterfaceBR] Common.IGW200_SENSOR_CHECK " );
- mSensorCheckHandler.sendEmptyMessageDelayed(0, 500);
- mSensorCheckHandler.sendEmptyMessageDelayed(1, 600);
- break;
- }
- }
- else if (strActionName.equals(Common.BR_EMER_LED_CONTROL)) {
- int kind = intent.getIntExtra("KIND",0);
- Log.d( TAG , "[IGW300InterfaceBR] Common.BR_EMER_LED_CONTROL, kind : " + kind);
- if (kind == 1) {
- if (mWallPadEmerButton == null) {
- mWallPadEmerButton = new WallPadEmerButton();
- mWallPadEmerButton.start();
- }
- }
- else {
- if (mWallPadEmerButton != null) {
- mWallPadEmerButton.Exit();
- try{Thread.sleep(100);}
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e){
- LogUtil.errorLogInfo("", TAG, e);
- }
- mWallPadEmerButton = null;
- }
- }
- }
- }
- };
- private void initIGW300() {
- mIGW300API = mWallPadAPI.Get_IGW300Controller();
- mDLockAPI = mWallPadAPI.Get_DLockController();
- doorLockAPI = mWallPadAPI.Get_DLockController();
- FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController();
- if (mIGW300API == null) {
- Common.DebugLog("mIGW300API == null");
- }
- }
- public int ctrlDeviceIO(byte kind, boolean OnOff) {
- try {
-
- Log.d(TAG, "[ctrlDeviceIO] kind :" + kind + " , OnOff :" + OnOff );
- if (mIGW300API == null) {
- Log.e(TAG, "[ctrlDeviceIO] - mIGW300API unload !!!");
- return -1;
- }
- int ret = mIGW300API.ControlOutput(kind, OnOff);
- if (ret < 0) {
- Log.e(TAG, "[ctrlDeviceIO] - mIGW300API.ControlOutput() ret = " + ret + " / ErrorCode = " + mIGW300API.ErrorCode.ErrStr());
- return -2;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -102;
- }catch(Exception e) {
- Log.e(TAG, "[ctrlDeviceIO] - [Exception Error] mIGW300API.ControlOutput()");
- Log.e(TAG, "[ctrlDeviceIO] - " + e.toString());
-
- LogUtil.errorLogInfo("", TAG, e);
- return -102;
- }
-
- return 0;
- }
-
- public int changeCallPath(byte ChangePath) {
- try {
- if (mIGW300API == null) {
- Log.e(TAG, "[changeCallPath] - mIGW200dAPI unload !!!");
- return -1;
- }
- try {
- Log.e(TAG, "[changeCallPath] - -----------------1------ !!!");
- int ret = mIGW300API.ControlTelPath(ChangePath);
- if (ret < 0) {
- Log.e(TAG, "[changeCallPath] - mIGW300API.ControlTelPath(" + ChangePath + ") ret = " + ret + " / ErrorCode = " + mIGW300API.ErrorCode.ErrStr());
- return -2;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -102;
- }catch(Exception e) {
- Log.e(TAG, "[changeCallPath] - [Exception Error] mIGW300API.ControlTelPath()");
- Log.e(TAG, "[changeCallPath] - " + e.toString());
-
- LogUtil.errorLogInfo("", TAG, e);
- return -102;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, "[changeCallPath] - " + e.toString());
-
- LogUtil.errorLogInfo("", TAG, e);
- }
- return 0;
- }
-
- private int updateDeviceStatus(boolean real) {
-
- if (mIGW300API == null) {
- Log.e(TAG, "[updateDeviceStatus] - mIGW200dAPI unload !!!");
- return -1;
- }
-
- try {
- int ret = mIGW300API.Refresh(real);
- if (ret < 0) {
- Log.e(TAG, "[updateDeviceStatus] getState - ret (" + ret + ") ErrorCode = " + mIGW300API.ErrorCode.ErrStr());
- return -2;
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return -102;
- }catch(Exception e) {
- Log.e(TAG, "[updateDeviceStatus] - [Exception Error] mIGW300API.Refresh(" + real + ")");
- Log.e(TAG, "[updateDeviceStatus] - " + e.toString());
-
- LogUtil.errorLogInfo("", TAG, e);
- return -102;
- }
-
- mIGW300API_Data = mIGW300API.data;
-
- Common.DebugLog("---------------------------------------");
- Common.DebugLog("[updateDeviceStatus]");
- Common.DebugLog("---------------------------------------");
- Common.DebugLog("[senIn]");
- Common.DebugLog("In_Motion : " + mIGW300API_Data.senIn.In_Motion);
- Common.DebugLog("Out_Motion : " + mIGW300API_Data.senIn.Out_Motion);
- Common.DebugLog("Magnetic : " + mIGW300API_Data.senIn.Magnetic);
- Common.DebugLog("APU : " + mIGW300API_Data.senIn.APU);
- Common.DebugLog("EVAC_Home : " + mIGW300API_Data.senIn.EVAC_Home);
- Common.DebugLog("EVAC_UP : " + mIGW300API_Data.senIn.EVAC_UP);
- Common.DebugLog("---------------------------------------");
- Common.DebugLog("[updateDeviceStatus] - OK");
- if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) {
- if (mIGW300API_Data.senIn.Magnetic) sendDoorOpenBR();
- }
- return 0;
- }
-
-
-
-
-
- private void callEmerAPK(Context context, int nScreenID , int startOption, String detailInfo ) {
- try {
-
- int [] m_EmerMenuList = new int[4];
- m_EmerMenuList[0] = ID.LINKEDSCREEN.SubEmergency.EMER_ALARM;
- m_EmerMenuList[1] = ID.LINKEDSCREEN.SubEmergency.FIRE_ALARM;
- m_EmerMenuList[2] = ID.LINKEDSCREEN.SubEmergency.BREAKIN_ALARM;
- m_EmerMenuList[3] = ID.LINKEDSCREEN.SubEmergency.LADDER_ALARM;
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.putExtra(Common.MENU_ID_LIST, m_EmerMenuList);
- intent.putExtra(Common.MENU_START_ID, nScreenID);
- intent.putExtra(Common.MENU_START_OPTION, startOption);
- intent.putExtra(Common.MENU_DETAIL_INFO, detailInfo);
- intent.setComponent(new ComponentName(Common.EMER_ALARM_APK, Common.EMER_ALARM_APK + Common.MAIN_ACTIVITY ));
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, e.toString());
-
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
-
-
- class WallPadEmerButton extends Thread {
- private jni mGleInterface = null;
- private boolean m_LedOn = false;
- private boolean m_ThreadExit = false;
- public WallPadEmerButton() {
- try { mGleInterface = new jni(); }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e("Exception", "[ExceptionError] - onCreate->mGleInterface Create : " + e);
- }
- }
- public void run() {
- try {
- Common.DebugLog("WallPadEmerButton------ Thread Run");
- do {
- if (mGleInterface != null) {
- if (m_LedOn == false) {
- mGleInterface.setEmerLedOnOff(true);
- m_LedOn = true;
- }
- else {
- mGleInterface.setEmerLedOnOff(false);
- m_LedOn = false;
- }
- }
- for (int i = 0 ; i < 10 ; i++) {
- try{Thread.sleep(50);}
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e){
- LogUtil.errorLogInfo("", TAG, e);
- }
- if (m_ThreadExit && mGleInterface!=null) {
- mGleInterface.setEmerLedOnOff(false);
- return;
- }
- }
- }
- while (true);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return;
- }
- catch (Exception e) {
-
- LogUtil.errorLogInfo("", TAG, e);
- e.getStackTrace();
- return;
- }
- }
- private void Exit()
- {
- m_ThreadExit = true;
- }
- }
- public boolean checkSensorforOutmode() {
- updateDeviceStatus(true);
- IGW300API.Data mData = mIGW300API.data;
- boolean bInMotionSensor = mData.senIn.In_Motion;
- boolean bOutMotionSensor = mData.senIn.Out_Motion;
- boolean bMagneticSensor = mData.senIn.Magnetic;
- Log.d(TAG, "[checkSensorforOutmode] bInMotionSensor [" + bInMotionSensor + "], bOutMotionSensor [" + bOutMotionSensor + "], bMagneticSensor [" + bMagneticSensor + "]");
-
- byte DoorLockState = DOORSTATUS.Close ;
- try
- {
- WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
- String[] GetValue = devSet.GetSettingData("디지털도어락");
- devSet.closeDB();
- if (GetValue == null)
- {
- Log.e("Common", "GetSettingData(디지털도어락) is null");
- return false;
- }
- Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]);
- if( GetValue[1].indexOf("유선") > 0 )
- {
- Log.d("Common", "Normal Line Doorlock");
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- doorLockAPI = mWallPadAPI.Get_DLockController();
- doorLockAPI.Refresh(true);
- DoorLockState = doorLockAPI.data.DoorStatus;
- Log.d(TAG, "Normal Line DoorLock State : ==> " + DoorLockState );
- }
- }
- else if(GetValue[1].indexOf("지문인식") > 0)
- {
-
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController();
- FPdoorLockAPI.Refresh(true);
- DoorLockState = FPdoorLockAPI.data.DoorStatus;
- Log.d(TAG, "FingerPrint DoorLock State : ==> " + DoorLockState );
- }
- }
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e)
- {
-
- LogUtil.errorLogInfo("", TAG, e);
- }
-
- if (Common.isWirelessDoorlock(mContext)) {
- DoorLockState = DOORSTATUS.Close;
- }
- int[] SensorInfoDB;
- SensorInfoDB = Common.GetInSensorUseOfNotFromDB(mContext);
- Log.w(TAG, "[checkSensorforOutmode] SensorInfoDB.length = " + SensorInfoDB.length);
- if (SensorInfoDB[0] == 0) {
-
- bInMotionSensor = false;
- }
- if (SensorInfoDB[1] == 0) {
-
- bOutMotionSensor = false;
- }
- if (bInMotionSensor == false && bOutMotionSensor == false && bMagneticSensor == false && DoorLockState == DOORSTATUS.Close) {
- return true;
- }
- return false;
- }
- public boolean checkSensorforInmode() {
- updateDeviceStatus(true);
- IGW300API.Data mData = mIGW300API.data;
- boolean bMagneticSensor = mData.senIn.Magnetic;
- Log.d(TAG, "[checkSensorforInmode] bMagneticSensor [" + bMagneticSensor + "]");
-
- byte DoorLockState = DOORSTATUS.Close ;
-
- try
- {
- WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
- String[] GetValue = devSet.GetSettingData("디지털도어락");
- devSet.closeDB();
- if (GetValue == null)
- {
- Log.e("Common", "GetSettingData(디지털도어락) is null");
- return false;
- }
- Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]);
- if( GetValue[1].indexOf("유선") > 0 )
- {
- Log.d("Common", "Normal Line Doorlock");
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- doorLockAPI = mWallPadAPI.Get_DLockController();
- doorLockAPI.Refresh(true);
- DoorLockState = doorLockAPI.data.DoorStatus;
- Log.d(TAG, "Normal Line DoorLock State : ==> " + DoorLockState );
- }
- }
- else if(GetValue[1].indexOf("지문인식") > 0)
- {
-
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController();
- FPdoorLockAPI.Refresh(true);
- DoorLockState = FPdoorLockAPI.data.DoorStatus;
- Log.d(TAG, "FingerPrint DoorLock State : ==> " + DoorLockState );
- }
- }
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e)
- {
-
- LogUtil.errorLogInfo("", TAG, e);
- }
-
- if (Common.isWirelessDoorlock(mContext)) {
- DoorLockState = DOORSTATUS.Close;
- }
- if (bMagneticSensor == false && DoorLockState == DOORSTATUS.Close) {
- return true;
- }
- return false;
- }
- private Handler mSensorCheckHandler = new Handler()
- {
- @Override
- public void handleMessage(Message msg)
- {
- if (msg.what == 0) {
- Log.d(TAG, "[mSensorCheckHandler] ");
-
- checkSensor();
- }
- else if (msg.what == 1) {
- checkGLEDoorlock();
- }
- }
- };
- private boolean checkGLEDoorlock() {
- byte DoorLockState = DOORSTATUS.Close ;
- Log.d(TAG, "[checkGLEDoorlock] ========== START ==========" );
-
- if (Common.isWirelessDoorlock(mContext)) {
- return true;
- }
-
- try
- {
- WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
- String[] GetValue = devSet.GetSettingData("디지털도어락");
- devSet.closeDB();
- if (GetValue == null)
- {
- Log.e("Common", "GetSettingData(디지털도어락) is null");
- return false;
- }
- Log.d("Common", "GetSettingData(디지털도어락) is value : " + GetValue[1]);
- if( GetValue[1].indexOf("유선") > 0 )
- {
- Log.d("Common", "Normal Line Doorlock");
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- doorLockAPI = mWallPadAPI.Get_DLockController();
- doorLockAPI.Refresh(true);
- DoorLockState = doorLockAPI.data.DoorStatus;
- Log.d(TAG, "[checkGLEDoorlock] DoorLockState [" + DoorLockState + "]");
- if (DoorLockState != DOORSTATUS.Close) {
- setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0);
- return true;
- }
- }
- }
- else if(GetValue[1].indexOf("지문인식") > 0)
- {
-
- if (mWallPadAPI != null && mWallPadAPI.Check_Connect())
- {
- FPdoorLockAPI = mWallPadAPI.Get_FP_DLockController();
- FPdoorLockAPI.Refresh(true);
- DoorLockState = FPdoorLockAPI.data.DoorStatus;
- Log.d(TAG, "[checkGLEDoorlock] DoorLockState [" + DoorLockState + "]");
- if (DoorLockState != DOORSTATUS.Close) {
- setSendEventBR(WallPadInterface.EVT_SENSOR_MAGNETIC0);
- return true;
- }
- }
- }
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e)
- {
-
- LogUtil.errorLogInfo("", TAG, e);
- }
- return false;
- }
- public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE;
- private void getResidentSafetyCheckSetting() {
- try {
- WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext);
- nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck();
- mWallpadDeviceSet.closeDB();
- Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()");
-
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- public void sendDoorOpenBR() {
- try {
- Intent mIntent = new Intent();
- mIntent.setAction(Version.NOTIFY_ACNAME_RESIDENT_SAFETY_CHECK);
- mIntent.putExtra(Version.NOTIBR_KIND, Version.NOTIFY_DOOR_OPENED);
- mContext.sendBroadcast(mIntent);
- } catch (RuntimeException re) {
- kr.co.icontrols.wallpadsupport.LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] sendDoorOpenBR()");
-
- kr.co.icontrols.wallpadsupport.LogUtil.errorLogInfo("", TAG, e);
- }
- }
- }
|