package com.example.iot_controlhost.utils.mainboard;

import com.example.iot_controlhost.MyApp;
import com.example.iot_controlhost.utils.PollingTask;
import com.example.iot_controlhost.utils.log.MyLog;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.zcapi;

/**
 * @Description 卓策API
 * @Author DuanKaiji
 * @CreateTime 2024年01月05日 14:36:37
 */
public class ZCAPI extends API {

    zcapi zcApi;

    @Override
    public void init() {
        // 初始化zcApi
        try {
            zcApi = new zcapi();
            zcApi.getContext(MyApp.getAppContext());
            zcApi.setStatusBar(true);
            zcApi.setGestureStatusBar(true);
            MyLog.app("看门狗初始化成功");
        } catch (Exception e) {
            e.printStackTrace();
            MyLog.appError("看门狗初始化失败：" + e.getMessage());
        }
    }

    @Override
    public void shutDown() {
        zcApi.shutDown();
    }

    @Override
    public void reBoot() {
        zcApi.reboot();
    }

    @Override
    public void feed() {
        MyLog.app("开始持续喂狗");
        PollingTask.getInstance("FeedDog").startPollingTaskOnIOThread("Feed", 45, () -> zcApi.watchDogEnable(true));
    }
}
