package com.kfb.kfbv1.model;

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

public class KfbTaskTablet  implements Runnable{
    @Override
    public void run() {
        Handler handler = KfbModel.getData().handler;
        while(KfbModel.getData().sendHttp==true) {
            for(int i =0;i<KfbModel.getData().getTabletss().getmSize();i++)
            {
                KfbGate tabl = KfbModel.getData().getTabletss().getmGate().get(i);
                if(tabl.ismActive()==true)
                {
                    KfbHttpRequest.getTabletStatus(tabl);
                    Message msg = handler.obtainMessage();
                    msg.what = 2;
                    msg.obj = "Pomiar";
                    if(tabl.getId()==4) {
                        msg.arg1 = KfbModel.getData().getGates().getmGate().get(0).getId();
                    }
                    if(tabl.getId()==5) {
                        msg.arg1 = KfbModel.getData().getGates().getmGate().get(1).getId();
                    }
                    if(tabl.getId()==6) {
                        msg.arg1 = KfbModel.getData().getGates().getmGate().get(2).getId();
                    }
                    if(tabl.getId()==7) {
                        msg.arg1 = KfbModel.getData().getGates().getmGate().get(3).getId();
                    }
                //    handler.sendMessage(msg);
                    KfbHttpRequest.getTabletTemp(tabl);
                }
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
