package kr.co.compcareworker.Util;

import android.os.Handler;
import android.os.Message;

public class MonitoringThread extends Thread {
    private final Handler handler;
    private boolean isRun = true;
    private final String type;
    private final String mac;
    private final String i;
    private String k = "";

    public MonitoringThread(Handler handler, String type, String mac, String i, String k) {
        this.handler = handler;
        this.type = type;
        this.mac = mac;
        this.i = i;
        this.k = k;
    }

    public void stopForever() {
        synchronized (this) {
            this.interrupt();
        }
    }

    public String getMac() {
        return mac;
    }

    public int getPosition() {
        return Integer.parseInt(i);
    }

    public int getPosition_k() {
        return Integer.parseInt(k);
    }

    public void run() {
        //반복적으로 수행할 작업을 한다.
        while (!Thread.currentThread().isInterrupted()){
            Message message = new Message();
            message.obj = mac + "i" + i + "k" + k;
            handler.sendMessage(message);
            try {
                int SLEEP = 2000;
                Thread.sleep(SLEEP);
            } catch (Exception e) {
                e.printStackTrace();
                break;
            }
        }
    }
}
