package kr.co.icontrols.ilp300_700.rfreader;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;

import kr.co.icontrols.ilp300_700.global.Global;

public class RFReaderManager {

    final static String TAG = "RFReaderManager";

    public final static int HANDLE_RFREADER_HDCIPARK = 1100;
    public final static int HANDLE_RFREADER_STANDDARD = 1200;
    public final static int HANDLE_RFPASS_STANDARD = 2100;
    public final static int HANDLE_MSG_RECEIVED = 8100;

    static boolean bLOG_DEBUG = false;   // true, false
    static int nHandlerRFReaderType = HANDLE_RFREADER_HDCIPARK;
    public static Handler RFReaderManagerHandler = new Handler(Looper.getMainLooper()) {
        public void handleMessage(Message msg) {
            if (!Global.getEnableDeviceInput()) {
                Log.w(TAG, "[RFReaderManagerHandler] Global.getEnableDeviceInput() = " + Global.getEnableDeviceInput());
                return;
            }
            LOG_DEBUG("RFReaderManagerHandler : " + msg.what);
            nHandlerRFReaderType = msg.what;

            switch (nHandlerRFReaderType) {
                case HANDLE_RFREADER_STANDDARD:
                    HDCStandardManager.procRcvData(msg.what, msg.arg1, msg.arg2, (byte[]) (msg.obj));
                    break;

                case HANDLE_RFREADER_HDCIPARK:
                    HDCIPARKManager.procRcvData(msg.what, msg.arg1, msg.arg2, (byte[]) (msg.obj));
                    break;
            }
        }
    };
    public final int HANDLE_RFPASS_SMART = 2200;
    public final int HANDLE_RFPASS_MIFARE = 2300;
    public final int HANDLE_RFPASS_TMONEY = 2400;
    public final int HANDLE_RFPASS_NFC = 2500;
    public final int HANDLE_MSG_DONE = 8200;
    public final int HANDLE_MSG_ING = 8300;
    public final int HANDLE_MSG_ERROR_TIMEOUT = 8800;
    public final int HANDLE_MSG_ERROR_TIMEOUT_READ = 8801;
    public final int HANDLE_MSG_ERROR = 8900;
    public final int HANDLE_MSG_ERROR_READ = 8901;
    public final int HANDLE_MSG_ERROR_MESSAGE = 8902;
    public final int HANDLE_MSG_NONE = 9000;
    boolean bLOG = true;   // true, false
    boolean bLOG_INFO = true;   // true, false
    Context mContext;
    int nHandlerResult = HANDLE_MSG_NONE;

    private static void LOG_DEBUG(String log) {
        if (bLOG_DEBUG) Log.d(TAG, log);
    }

    private void LOG(String log) {
        if (bLOG) Log.v(TAG, log);
    }

    private void LOG_INFO(String log) {
        if (bLOG_INFO) Log.i(TAG, log);
    }


}