import { reactive } from "vue";

import Reflect_SeviceClient from "@/wscf-client/Reflect_SeviceClient";

/**
 * 系统状态
 * @readonly
 * @enum {0|1|2|3|4|5|7|10|11|12}
 */
const CTRL_STATE = {
    /** 定点 @type {0} */
    FIX:0,
    /** 归零 @type {1} */
    ORG:1,
    /** 扫描 @type {2} */
    SCAN:2,
    /** 前进 @type {3} */
    FORW:3,
    /** 后退 @type {4} */
    BACKW:4,
    /** 停止 @type {5} */
    STOP:5,
    /** 机架修正 @type {7} */
    CORR:7,
    /** 运行至 @type {10} */
    RUNNING:10,
    /** 连接断开 @type {11} */
    DISCONNECTED:11,
    /** 获取机架信息 @type {12} */
    GAGEINFO:12
};
/**
 */
class TDGageServiceClient extends Reflect_SeviceClient {
    constructor(){
        super();
        this.Data=reactive({
            DynArea:{
                Thk : 100.23,
                Position : 0,
                PosMm : 0,
                AD : 12345,
                ADMax : 65535,
                Position2 :0,
                DataValid :false,
                Width :0,
                FilmVelocity :0,
                FilmPosition :0,
                Velocity :0,
                /**
                 * @type {CTRL_STATE}
                 */
                ControllerState:CTRL_STATE.FIX,
                AutoScanCounter:5,
                IsTest:false,
                 IStatus:0xffff,
                 OStatus:0xffff,
                 IsIOShowNo:false,
                 Hrs:3,
                 FLYADIsConnect:false,
                 SecuteLock:false
            }
        });

    }
    /**
     * @description 扫描
     */
    async Scan(){
        return await this.SyncCall('Scan');
    }

    /**
     * @description 停止
     */
    async Stop()
    {
        return await this.SyncCall('Stop');
    }

    /**
     * @description 归零
     */
    async Home()
    {
        return await this.SyncCall('Home');
    }


    /**
     * @description 前进
     */
    async Forward()
    {
        return await this.SyncCall('Forward');
    }

    /**
     * @description 后退
     */
    async Backward()
    {
        return await this.SyncCall('Backward');
    }

    /**
     * @description 运行到targetPos
     */
    async Runto(targetPos)
    {
        this.SyncCall('Runto',targetPos);
    }
}




export { TDGageServiceClient,CTRL_STATE };