
document.write("<script type='text/javascript' src='../public/public.js'></script>");
document.write("<script type='text/javascript' src='../static/echarts/echarts.min.js'></script>");


var TaktTimeDelay = 50;
var OverTimeDelay = 200;
var WriteTimeDelay = 400;
var InstrumentModel = null;
var obj = {cnt:0, delay:0, set_delay:1, delay1:500, delay2:500, overDelay:1200, get_delay:100};



// var comm = new serial();
var interface = new Interface(1);


var get_InstrumentModel = function(val){
    if(InstrumentModel != null && InstrumentModel.indexOf(val) >= 0){
        return true;
    }
    return false;
}

/*
//串口通信封装
function serial() {
    //型号判断
    this.get_InstrumentModel = function(val){
        if(InstrumentModel != null && InstrumentModel.indexOf(val) >= 0){
            return true;
        }
        return false;
    }

    var get_delay = 100, set_delay = 1;
    //获取当前负载支持的通道数
    this.get_ch_sum = function () {
        return serial_comm(0, "CHANNUM?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //当前通道查询
    this.get_ch = function () {
        return serial_comm(0, "CHAN?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //当前通道设置
    this.set_ch = function (ch) {
        return serial_comm(0, "CHAN" + ch, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //开关状态查询
    this.get_OnOff = function () {
        return serial_comm(0, "INPut?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //开关状态设置
    this.set_OnOff = function (on) {
        return serial_comm(0, "INPut " + on, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询触发状态
    this.get_Trigger = function () {
        return serial_comm(0, "INPut:TRIG:SET?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置触发状态
    this.set_Trigger = function () {
        return serial_comm(0, "INP:TRIG:SET 1", TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询暂停状态
    this.get_PauseState = function () {
        return serial_comm(0, "INPut:PAUSe?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置暂停状态
    this.set_PauseState = function (on) {
        return serial_comm(0, "INP:PAUSe " + on, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询短路状态
    this.get_ShortState = function () {
        return serial_comm(0, "INPut:SHORt?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置短路状态
    this.set_ShortState = function (on) {
        return serial_comm(0, "INP:SHOR " + on, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询触发方式
    this.get_Trig_Mode = function () {
        return serial_comm(0, "INPut:TRIG:MODE?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置触发方式
    this.set_Trig_Mode = function (mode) {
        return serial_comm(0, "INPut:TRIG:MODE " + mode, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询控制方式
    this.get_LOCal = function () {
        return serial_comm(0, "SYSTem:LOCal?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置控制方式
    this.set_LOCal = function (mode) {
        return serial_comm(0, "SYSTem:" + mode, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询电压补偿功能状态
    this.get_SENSe = function () {
        return serial_comm(0, "SYSTem:SENSe?", TaktTimeDelay, OverTimeDelay, 3);
    }
    //设置电压补偿功能状态
    this.set_SENSe = function (on) {
        return serial_comm(0, "SYST:SENS " + on, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询是定电流or定电压or定功率or定电阻
    this.get_LimitModeState = function (mode) {
        return serial_comm(0, "mode?", TaktTimeDelay, OverTimeDelay, 5);
    }
    //定电流or电定压or定功率or定电阻模式选择
    this.set_LimitMode = function (mode) {
        return serial_comm(0, "MODE " + mode, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设定定电流、电压、功率、电阻值
    this.set_LimitValue = function (cmd_str) {
        return serial_comm(0, cmd_str, TaktTimeDelay, WriteTimeDelay, 0);
    }

    //查询电流
    this.get_Curr = function () {
        return serial_comm(0, "MEASure:CURRent?", TaktTimeDelay, OverTimeDelay, 5);
    }
    //查询电压
    this.get_Volt = function () {
        return serial_comm(0, "MEASure:VOLTage?", TaktTimeDelay, OverTimeDelay, 5);
    }
    //查询功率
    this.get_Power = function () {
        return serial_comm(0, "MEAS:POWer?", TaktTimeDelay, OverTimeDelay, 5);
    }

    //查询固件版本
    this.get_IDN = function() {
        return serial_comm(0, "*IDN?", TaktTimeDelay, OverTimeDelay, 20);
    }




    //设置动态模式的高准位拉载电流
    this.set_DYN_HIGH = function(value) {
        return serial_comm(0, "DYN:HIGH " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式下的高准位拉载电流持续时间
    this.set_DYN_HIGH_DWELl = function(value) {
        return serial_comm(0, "DYN:HIGH:DWELl " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式的低准位拉载电
    this.set_DYN_LOW = function(value) {
        return serial_comm(0, "DYN:LOW " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式下的低准位拉载电流持续时间
    this.set_DYN_LOW_DWELl = function(value) {
        return serial_comm(0, "DYN:LOW:DWELl " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式电流上升率
    this.set_DYN_SLEW_RISE = function(value) {
        return serial_comm(0, "DYN:SLEW:RISE " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式电流下降
    this.set_DYN_SLEW_FALL = function(value) {
        return serial_comm(0, "DYN:SLEW:FALL " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式下的工作模式
    this.set_DYN_MODE = function(value) {
        return serial_comm(0, "DYN:MODE " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式下的重复运行次数
    this.set_DYN_REP = function(value) {
        return serial_comm(0, "DYN:REP " + value, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置动态模式开始
    this.set_DYN_START = function() {
        return serial_comm(0, "INPut 1", TaktTimeDelay, WriteTimeDelay, 0);
    }



    //启动或停止OCP测试.
    this.set_ocp_ON = function(on) {
        return serial_comm(0, "OCP " + on, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置OCP起始电流
    this.set_ocp_IST = function(val) {
        return serial_comm(0, "OCP:IST " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置OCP截止电流
    this.set_ocp_IEND = function(val) {
        return serial_comm(0, "OCP:IEND " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置OCP步进电流值
    this.set_ocp_CSTep = function(val) {
        return serial_comm(0, "OCP:CSTep " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置OCP单步驻留时间
    this.set_ocp_DWEL = function(time) {
        return serial_comm(0, "OCP:DWEL " + time, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置OCP触发电平
    this.set_ocp_VTR = function(val) {
        return serial_comm(0, "OCP:VTR " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //查询OCP点电流值
    this.set_ocp_RES = function() {
        return serial_comm(0, "OCP:RES?", TaktTimeDelay, OverTimeDelay, 2);
    }
    //查询PMAX点
    this.set_ocp_PMAX = function() {
        return serial_comm(0, "OCP:RES:PMAX?", TaktTimeDelay, OverTimeDelay, 2);
    }



    //设置电池恒流放电电流值
    this.set_bat_CURR = function(val) {
        return serial_comm(0, "BATT:CURR " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置电池恒流放电截止电压
    this.set_bat_CCV = function(val) {
        return serial_comm(0, "BATT:CCV " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置电池恒阻放电电阻值
    this.set_bat_RES = function(val) {
        return serial_comm(0, "BATT:RES " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置电池恒阻放电截止电压值
    this.set_bat_CRV = function(val) {
        return serial_comm(0, "BATT:CRV " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置电池恒功率放电功率值
    this.set_bat_POW = function(val) {
        return serial_comm(0, "BATT:POW " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置电池恒功率放电截止电压
    this.set_bat_CPV = function(val) {
        return serial_comm(0, "BATT:CPV " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //读取电池容量
    this.get_bat_CAPacity = function() {
        return serial_comm(0, "MEAS:CAPacity?", TaktTimeDelay, OverTimeDelay, 3);
    }





    //设置快充协议:QCM:PROT PD3
    this.set_qc_Prot = function (val) {
        return serial_comm(0, "QCM:PROT " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //查询DP线上的实时电压值 QCM:D+:VOLT?
    this.get_qc_DpVolt = function () {
        return serial_comm(0, "QCM:D+:VOLT?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //在BC1.2协议下对D+施加3.3V电压（对电源短路测试）QCM:D+:SHORt ON
    this.set_qc_BcShort1 = function (val) {
        return serial_comm(0, "QCM:D+:SHORt " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //查询DN线上的实时电压值 QCM:D-:VOLT?
    this.get_qc_DnVolt = function () {
        return serial_comm(0, "QCM:D-:VOLT?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //BC1.2协议下对D-施加3.3V电压（对电源短路测试）QCM:D-:SHORt ON
    this.set_qc_BcShort2 = function (val) {
        return serial_comm(0, "QCM:D-:SHORt " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //查询PD电源电压对象的数量 QCM:PDO:COUN?
    this.get_qc_PdoCoun = function () {
        return serial_comm(0, "QCM:PDO:COUN?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //查询PD电源电压列表 QCM:PDO:LIST?
    this.get_qc_PdoList = function () {
        return serial_comm(0, "QCM:PDO:LIST?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //查询快充协议连接状态 QCM:CONN?
    this.get_qc_Conn = function () {
        return serial_comm(0, "QCM:CONN?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //查询快充命令运行状态 QCM:RUN?
    this.get_qc_Run = function () {
        return serial_comm(0, "QCM:RUN?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //查询快充运行结果 QCM:RES?
    this.get_qc_Res = function () {
        return serial_comm(0, "QCM:RES?", TaktTimeDelay, WriteTimeDelay, 3);
    }
    //设置快充运行模式，同时触发快充电源电压输出 QCM:FUNC PDFIX
    this.set_qc_Func = function (val) {
        return serial_comm(0, "QCM:FUNC " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置快充运行模式（与QCM: FUNC功能相同） QCM:MODE PDFIX
    this.set_qc_mode = function (val) {
        return serial_comm(0, "QCM:MODE " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置快充运行开关 QCM:INP ON
    this.set_qc_OnOff = function (val) {
        return serial_comm(0, "QCM:INP " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC定压模式下的电压值 QCM:QC:VOLT 9
    this.set_qc_Volt = function (val) {
        return serial_comm(0, "QCM:QC:VOLT " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC步进模式下的起始电压值 QCM:QC: STAR 9
    this.set_qc_StartVolt = function (val) {
        return serial_comm(0, "QCM:QC: STAR " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC步进模式下的步进电压值 QCM:QC:STEP 0.2
    this.set_qc_StepVolt = function (val) {
        return serial_comm(0, "QCM:QC:STEP " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC步进模式下的结束电压值 QCM:QC:END 12
    this.set_qc_StopVolt = function (val) {
        return serial_comm(0, "QCM:QC:END " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC步进模式下的单步驻留时间 QCM:QC:DWELl 1000
    this.set_qc_StepTime = function (val) {
        return serial_comm(0, "QCM:QC:DWELl " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置QC步进模式下的触发方式 QCM:QC:TRIGger 1
    this.set_qc_Trig = function (val) {
        return serial_comm(0, "QCM:QC:TRIGger " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //发送QC步进模式下的手动触发，此命令只有在QC步进模式并且设置了手动触发方式以后才能生效 QCM:QC:MANual ON
    this.set_qc_Manual = function (val) {
        return serial_comm(0, "QCM:QC:MANual " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置DPDN测试模式下的DP电压值 QCM:DPDN:PVOLtage 0.6
    this.set_qc_DpVolt = function (val) {
        return serial_comm(0, "QCM:DPDN:PVOLtage " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置DPDN测试模式下的DN电压值 QCM:DPDN:NVOLtage 0.6
    this.set_qc_DnVolt = function (val) {
        return serial_comm(0, "QCM:DPDN:NVOLtage " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置DPDN测试模式下的允许误差电压值 QCM:DPDN:VERRor 0.2
    this.set_qc_DpdnErrorVolt = function (val) {
        return serial_comm(0, "QCM:DPDN:VERRor " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置DPDN测试模式下的测试持续时间值 QCM:DPDN:DWELl 500
    this.set_qc_DpdnDweL1 = function (val) {
        return serial_comm(0, "QCM:DPDN:DWELl " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置PE定压模式下的电压值 QCM:PE:VOLTage 5
    this.set_qc_PeVolt = function (val) {
        return serial_comm(0, "QCM:PE:VOLTage " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置UPD定压模式下的电压值 QCM:PD:VOLTage 5
    this.set_qc_UpdVolt = function (val) {
        return serial_comm(0, "QCM:PD:VOLTage " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置UPD定压模式下的电流值 QCM:PD:CURRent 3
    this.set_qc_UpdCurr = function (val) {
        return serial_comm(0, "QCM:PD:CURRent " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    //设置UPD定压模式下的电压对象序号 QCM:PD:PDON 3
    this.set_qc_UpdPdon = function (val) {
        return serial_comm(0, "QCM:PD:PDON " + val, TaktTimeDelay, WriteTimeDelay, 0);
    }
    
    
    

}
*/

//不同页之相同元素操作
{
    //通道选择
    function ch_select(){
        window.get_chan = function (i, str) {
            var select_ch = $("#Droplist_Channel_input").val();
            if(str == "1" && select_ch == "CH2"){
                interface.setSerialSend(0, "CHAN2", "", obj.delay1, obj.delay2, obj.overDelay);
            }
            else if(str == "2" && select_ch == "CH1"){
                interface.setSerialSend(0, "CHAN1", "", obj.delay1, obj.delay2, obj.overDelay);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "CHAN?", "get_chan", TaktTimeDelay, OverTimeDelay);
    }


    //以下为点击“断开连接”后操作
    $('#PrimaryButton_Disconnect').click(function() {//按键-断开连接
        obj.cnt = 0;
        interface.setSerialSend(0, "LOCal", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_LOCal("LOCal");
        interface.setSerialClose(0);
        layer.msg("<h1>断开连接啦</h1>");
    });

    //以下为点击“开关”后操作
    $('#PrimaryButton_OnOffMini_img').click(function() {//按键-开关
        if(select_is("#PrimaryButton_OnOff_img") == true){
            set_img_select("#PrimaryButton_OnOff_img", false);
            interface.setSerialSend(0, "INPut 0", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_OnOff("0");
        }else{
            set_img_select("#PrimaryButton_OnOff_img", true);
            interface.setSerialSend(0, "INPut 1", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_OnOff("1");
        }
    });
    function get_OnOff(){//查询开关状态
        window.get_input = function (i, dat) {
            if(dat == "0"){
                $("#Ellipse_Run_img").hide();
                $("#Ellipse_Stop_img").show();
                set_img_select("#PrimaryButton_OnOff_img", false);
            }
            else if(dat == "1"){
                $("#Ellipse_Run_img").show();
                $("#Ellipse_Stop_img").hide();
                set_img_select("#PrimaryButton_OnOff_img", true);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "INPut?", "get_input", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_OnOff();
    }

    //显示时间
    var TimeCnt = 0;
    var t2 = window.setInterval(function() {
        function formatSeconds(value) {
            let result = parseInt(value);
            let h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
            let m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
            let s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
            result = `${h} : ${m} : ${s}`;
            return result
        }
        var src  = $("#PrimaryButton_OnOff_img")[0].src;
        if(src.substr(src.length - 13, 13) == "_selected.svg"){
            TimeCnt++;
        }else{
            TimeCnt = 0;
        }
        $('#Heading_RunTime_text').html(formatSeconds(TimeCnt));
    },1000);

    //以下为点击“触发”后操作
    $('#PrimaryButton_TriggerMini_img').click(function() {//按键-触发
        interface.setSerialSend(0, "INP:TRIG:SET 1", obj.delay1, obj.delay2, obj.overDelay);  //var dat = comm.set_Trigger();
        set_img_select("#PrimaryButton_Trigger_img", true);
    });
    function get_Trigger(){//查询触发状态
        window.get_input_trig_set = function (i, dat) {
            if(dat == "0"){
                set_img_select("#PrimaryButton_Trigger_img", false);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "INPut:TRIG:SET?", "get_input_trig_set", TaktTimeDelay, OverTimeDelay); //var dat = comm.get_Trigger();
    }

    //以下为点击“暂停”后操作
    $('#PrimaryButton_PauseMini_img').click(function() {//按键-暂停
        if(get_InstrumentModel("UTL82") == false){
            if(select_is("#PrimaryButton_Pause_img") == true){
                set_img_select("#PrimaryButton_Pause_img", false);
                interface.setSerialSend(0, "INP:PAUSe 0", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_PauseState("0");
            }else{
                set_img_select("#PrimaryButton_Pause_img", true);
                interface.setSerialSend(0, "INP:PAUSe 1", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_PauseState("1");
            }
        }else{layer.msg("<h1>" + InstrumentModel + "机型不支持该功能" + "</h1>");}
    });
    function get_PauseState(){//查询暂停状态
        if(get_InstrumentModel("UTL85") == false){//有些机型不支持该指令，直接返回true跳过
            return "ok";
        }else{
            window.get_input_pause = function (i, dat) {
                if(dat == "0"){
                    $("#Ellipse_Pause_img").hide();
                    set_img_select("#PrimaryButton_Pause_img", false);
                }else if(dat == "1"){
                    $("#Ellipse_Pause_img").show();
                    set_img_select("#PrimaryButton_Pause_img", true);
                }
                obj.delay = 0;
            }
        }
        return interface.getSerialComm(0, "INPut:PAUSe?", "get_input_pause", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_PauseState();
    }

    //以下为点击“短路”后操作
    $('#PrimaryButton_ShortMini_img').click(function() {//按键-短路
        if(select_is("#PrimaryButton_Short_img") == true){
            set_img_select("#PrimaryButton_Short_img", false);
            interface.setSerialSend(0, "INP:SHOR 0", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_ShortState("0");
        }else{
            set_img_select("#PrimaryButton_Short_img", true);
            interface.setSerialSend(0, "INP:SHOR 1", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_ShortState("1");
        }
    });
    function get_ShortState(){//查询短路状态
        window.get_input_short = function (i, dat) {
            if(dat == "0"){
                $("#Ellipse_Short_img").hide();
                set_img_select("#PrimaryButton_Short_img", false);
            }else if(dat == "1"){
                $("#Ellipse_Short_img").show();
                set_img_select("#PrimaryButton_Short_img", true);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "INPut:SHORt?", "get_input_short", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_ShortState();
    }

    //以下为触发方式选择（手动或外部）
    $('#RadioButton_Manual_input').click(function() {//触发模式_单选-手动
        interface.setSerialSend(0, "INPut:TRIG:MODE 0", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_Trig_Mode("0");
    });
    $('#RadioButton_External_input').click(function() {//触发模式_单选-自动
        interface.setSerialSend(0, "INPut:TRIG:MODE 1", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_Trig_Mode("1");
    });
    function get_Trig_Mode(){//查询触发方式
        window.get_input_trig_mode = function (i, dat) {
            if(dat == "0"){
                set_img_select("#RadioButton_Manual_img", true);
                set_img_select("#RadioButton_External_img", false);
            }else if(dat == "1"){
                set_img_select("#RadioButton_Manual_img", false);
                set_img_select("#RadioButton_External_img", true);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "INPut:TRIG:MODE?", "get_input_trig_mode", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_Trig_Mode(); INPut:TRIG:MODE?
    }

    //以下为近控或远控方式选择
    $('#RadioButton_Local_img').click(function() {//控制方式_单选-近控
        obj.cnt = 0;
        interface.setSerialSend(0, "SYSTem:LOCal", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_LOCal("LOCal");
    });
    $('#RadioButton_Remote_img').click(function() {//控制方式_单选-远控
        obj.cnt = 0;
        interface.setSerialSend(0, "SYSTem:REMote", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_LOCal("REMote");
    });
    function get_LOCal(){//查询控制方式
        window.system_local = function (i, str) {
            if(str == "0"){
                $("#Ellipse_Local_img").show();
                $("#Ellipse_Remote_img").hide();
                set_img_select("#RadioButton_Local_img", true);
                set_img_select("#RadioButton_Remote_img", false);
            }else if(str == "1"){
                $("#Ellipse_Local_img").hide();
                $("#Ellipse_Remote_img").show();
                set_img_select("#RadioButton_Local_img", false);
                set_img_select("#RadioButton_Remote_img", true);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "SYSTem:LOCal?", "system_local", TaktTimeDelay, OverTimeDelay);
    }

    //以下为补偿功能的开启和关闭
    $('#RadioButton_Disable_img').click(function() {//控制方式_单选-近控
        interface.setSerialSend(0, "SYST:SENS 0", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_SENSe("0");
    });
    $('#RadioButton_Enable_img').click(function() {//控制方式_单选-远控
        interface.setSerialSend(0, "SYST:SENS 1", "", obj.delay1, obj.delay2, obj.overDelay); //comm.set_SENSe("1");
    });
    function get_SENSe(){//查询电压补偿功能状态
        window.get_system_sense = function (i, dat) {
            if(dat == "0"){
                set_img_select("#RadioButton_Disable_img", true);
                set_img_select("#RadioButton_Enable_img", false);
            }else if(dat == "1"){
                set_img_select("#RadioButton_Disable_img", false);
                set_img_select("#RadioButton_Enable_img", true);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "SYSTem:SENSe?", "get_system_sense", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_SENSe();
    }

    //设定定电流、电压、功率、电阻值
    $("#PrimaryButton_Seting").click(function () {
        if(select_is("#RadioButton_FixedCurrent_img") == true){
            // comm.set_LimitValue("CURR "+ $('#TextField_SetCurrent_input').val());
            interface.setSerialSend(0, "CURR "+ $('#TextField_SetCurrent_input').val(), "", obj.delay1, obj.delay2, obj.overDelay);
        }else if(select_is("#RadioButton_FixedVoltage_img") == true){
            // comm.set_LimitValue("VOLT "+ $('#TextField_SetVoltage_input').val())
            interface.setSerialSend(0, "VOLT "+ $('#TextField_SetVoltage_input').val(), "", obj.delay1, obj.delay2, obj.overDelay);
        }else if(select_is("#RadioButton_FixedPower_img") == true){
            // comm.set_LimitValue("POW "+ $('#TextField_SetPower_input').val())
            interface.setSerialSend(0, "POW "+ $('#TextField_SetPower_input').val(), "", obj.delay1, obj.delay2, obj.overDelay);
        }else if(select_is("#RadioButton_FixedResistance_img") == true){
            var res = $('#TextField_SetResistance_input').val();
            if($("#Droplist_ResistanceUnit_input").val() == "mOhm"){
                res = parseInt(res)/1000;
            }
            // comm.set_LimitValue("RES "+ res)
            interface.setSerialSend(0, "RES "+ res, "", obj.delay1, obj.delay2, obj.overDelay);
        }
    });
    //以下为定电流or电定压or定功率or定电阻选择
    $('#RadioButton_FixedCurrent_img').click(function() {//单选-定电流
        interface.setSerialSend(0, "MODE CURRent", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_LimitMode("CURRent");
    });
    $('#RadioButton_FixedVoltage_img').click(function() {//单选-定电压
        interface.setSerialSend(0, "MODE VOLTage", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_LimitMode("VOLTage");
    });
    $('#RadioButton_FixedPower_img').click(function() {//单选-定功率
        interface.setSerialSend(0, "MODE POWer", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_LimitMode("POWer");
    });
    $('#RadioButton_FixedResistance_img').click(function() {//单选-定电阻
        interface.setSerialSend(0, "MODE RESistance", "", obj.delay1, obj.delay2, obj.overDelay);  //comm.set_LimitMode("RESistance");
    });
    function get_ModeState(){//查询是定电流or定电压or定功率or定电阻
        window.get_mode = function (i, dat) {
            if(dat == "0.0"){
                set_img_select("#RadioButton_FixedCurrent_img", true);
                set_img_select("#RadioButton_FixedVoltage_img", false);
                set_img_select("#RadioButton_FixedPower_img", false);
                set_img_select("#RadioButton_FixedResistance_img", false);
            }else if(dat == "1.0"){
                set_img_select("#RadioButton_FixedCurrent_img", false);
                set_img_select("#RadioButton_FixedVoltage_img", true);
                set_img_select("#RadioButton_FixedPower_img", false);
                set_img_select("#RadioButton_FixedResistance_img", false);
            }else if(dat == "3.0"){
                set_img_select("#RadioButton_FixedCurrent_img", false);
                set_img_select("#RadioButton_FixedVoltage_img", false);
                set_img_select("#RadioButton_FixedPower_img", true);
                set_img_select("#RadioButton_FixedResistance_img", false);
            }else if(dat == "2.0"){
                set_img_select("#RadioButton_FixedCurrent_img", false);
                set_img_select("#RadioButton_FixedVoltage_img", false);
                set_img_select("#RadioButton_FixedPower_img", false);
                set_img_select("#RadioButton_FixedResistance_img", true);
            }else{
                set_img_select("#RadioButton_FixedCurrent_img", false);
                set_img_select("#RadioButton_FixedVoltage_img", false);
                set_img_select("#RadioButton_FixedPower_img", false);
                set_img_select("#RadioButton_FixedResistance_img", false);
            }
            obj.delay = 0;
        }
        return interface.getSerialComm(0, "mode?", "get_mode", TaktTimeDelay, OverTimeDelay);  //var dat = comm.get_LimitModeState();
    }



    $('#Button_Reload').click(function() {//重新判断机型信息
        $(location).attr('href', "../index/index.html");
    });
    $('#PrimaryButton_Exit').click(function() {//退出按键
        interface.exit_windows();
    });



}















