板卡常用前端 数据表操作

news2025/2/26 14:34:15

两年前写的,现在看,有点想吐, 数据操作表,调试设备用

采用外挂的方法,以前设备的接口命令,简易,换个UI展示很容易

自己写着玩的,公司部分产品再用,前端展示,不涉密

index.html

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Device Dashboard</title>
    <link rel="stylesheet" type="text/css" href="themes/gray/easyui.css" />
    <link rel="stylesheet" type="text/css" href="themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="www/demo.css" />
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery.easyui.min.js"></script>
    <script type="text/javascript" src="www/js/dataGrid.js"></script>
    <script type="text/javascript" src="www/js/cgiOperator.js"></script>
    <script type="text/javascript" src="www/js/index.js"></script>
  </head>

  <body>
    <br />
    <div class="easyui-layout" fit="true">
      <div id="tb" style="height: auto">
        <a
          id="refresh"
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-reload',plain:true"
          onclick="reload()"
          >Refresh</a
        >
        <a
          id="save"
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-save',plain:true"
          onclick="edit()"
          >Save</a
        >
        <a
          id="cancel"
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-undo',plain:true"
          onclick="cancel()"
          >Cancel</a
        >
        <a
          id="view"
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-search',plain:true"
          onclick="getChanges()"
          >View changes</a
        >
        <a
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-reload',plain:true"
          onclick="chinese()"
          >中文</a
        >
        <a
          href="javascript:void(0)"
          class="easyui-linkbutton"
          data-options="iconCls:'icon-reload',plain:true"
          onclick="english()"
          >ENGLISH</a
        >
      </div>
      <br />
      <div
        class="easyui-layout"
        style="width: 1300px; height: 960px"
        fit="true"
      >
        <div
          data-options="region:'west',title:'Menu directory'"
          style="width: 250px"
          border="false"
          border="false"
        >
          <ul id="tt" class="easyui-tree">
            <li data-options="state:'open'">
              <span class="dev_info">Device Information</span>
              <ul>
                <li><a id="SystemInfo">Base Information</a></li>
              </ul>
            </li>
            <li data-options="state:'open'">
              <span class="dev_status">Device Status</span>
              <ul>
                <li><a id="MiscInfo">Misc Status</a></li>
                <li><a id="AlarmInfo">Alarm Status</a></li>
              </ul>
            </li>
            <li data-options="state:'open'">
              <span class="dev_setup">Device Setup</span>
              <ul>
                <li><a id="NetWorkConfig">Network Setup</a></li>
                <li><a id="RadioConfigCommon">RF Common Setup</a></li>
                <li data-options="state:'open'">
                  <span id="5G setup">5G NR Setup</span>
                  <ul>
                    <li><a id="CarrierConfigOne">Band 1 Slots Setup</a></li>
                    <li><a id="CarrierConfigTwo">Band 2 Slots Setup</a></li>
                  </ul>
                </li>
              </ul>
            </li>
            <li data-options="state:'open'">
              <span class="Factorty">Factory Calibration</span>
              <ul>
                <li><a id="FactorySetup">Calibration Setup</a></li>
              </ul>
            </li>
          </ul>
        </div>
        <div
          id="CenterBlock"
          data-options="region:'center',title:'Access Unit Equipment'"
        >
          <div
            id="HomeIndex"
            class="easyui-tabs"
            style="width: auto; height: 800px"
          >
            <div title="Home" style="padding: 10px">
              <table
                id="dg"
                class="easyui-datagrid"
                style="width: auto; height: 720px"
                data-options="
                                                                                checkOnSelect:false,
                                                                                selectOnCheck:false,
                                                                                onClickCell: onClickCell,
                                                                        "
              >
                <thead>
                  <tr>
                    <th
                      data-options="field:'selectRows',width:40,align:'center',checkbox:true"
                    ></th>
                    <th
                      data-options="field:'paramsName',width:400,align:'left'"
                    >
                      name
                    </th>
                    <th
                      data-options="field:'paramsValue',width:200,align:'left',editor:{type:'textbox'}"
                    >
                      value
                    </th>
                    <th
                      data-options="field:'UpdateTime',width:280,align:'center'"
                    >
                      update time
                    </th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>

index.js

//cgi request url information tag is directions ajax
var cacheDataParaList = undefined;
var cacheDataParaListArray = new Array();
var cacheData = undefined;
var cacheDataArray = new Array();
var DEBUG = 0;
var ZH_TABLE = undefined;
var TableType = undefined;

var NetWorkConfigArgs = new Array();
var NetWorkConfigFilterIndex = [1];

var SystemInfoArgs = new Array();
var SystemFilterIndex = [0];

var AlarmInfoArgs = new Array();
var AlarmFilterIndex = [100];

var AlarmConfigArgs = new Array();
var AlarmConfigFilterIndex = [99];

var CarrierConfigOneArgs = new Array();
var CarrierConfigOneFilterIndex = [2];

var CarrierConfigTwoArgs = new Array();
var CarrierConfigTwoFilterIndex = [3];

var RadioConfigCommonArgs = new Array();
var RadioConfigCommonFilterIndex = [4];

var RadioConfigOneArgs = new Array();
var RadioConfigOneFilterIndex = [5];

var RadioConfigTwoArgs = new Array();
var RadioConfigTwoFilterIndex = [6];

var RadioConfigThreeArgs = new Array();
var RadioConfigThreeFilterIndex = [7];

var RadioConfigFourArgs = new Array();
var RadioConfigFourFilterIndex = [8];

var OptInfoArgs = new Array();
var OptInfoFilterIndex = [9];

var MiscInfoArgs = new Array();
var MiscInfoFilterIndex = [0xa];

var FactorySetupArgs = new Array();
var FactorySetupFilterIndex = [0x2b];

var cgi_config = "cgi-bin/wsgi.py";

function FilterIndex(IndexArray, index) {
  for (var i = 0; i < IndexArray.length; i++) {
    if (index == IndexArray[i]) {
      return true;
    }
  }
  return false;
}

function ajaxPost(url_t, msg, func) {
  $.ajax({
    url: url_t,
    type: "POST", //对数据的请求指令使用post的请求方式
    data: msg,
    async: false,
    success: function(data, status) {
      // $.messager.alert("Successful", "Operator Successful");
      func(data, status);
    },
    error: function(data, status) {
      $.messager.alert("Failed", "Operator Failed");
    },
  });
}

function RequestFromBoaParaList() {
  ajaxPost(cgi_config, "cmd=para_list&nodata", function(data, status) {
    cacheDataParaList = data;
  });
}

function ajaxJson(url_t) {
  $.ajax({
    url: url_t,
    type: "GET", //对数据的请求指令使用post的请求方式
    async: false,
    dataType: "json",
    success: function(data, status) {
      // $.messager.alert("Successful", "Operator Successful");
      ZH_TABLE = data;
    },
    error: function(data, status) {
      $.messager.alert("Failed", "Operator Failed");
    },
  });
}

function ajaxJsonPost(url_t, msg, func) {
  $.ajax({
    url: url_t,
    type: "POST", //对数据的请求指令使用post的请求方式
    data: msg,
    async: false,
    dataType: json,
    success: function(data, status) {
      // $.messager.alert("Successful", "Operator Successful");
      func(data, status);
    },
    error: function(data, status) {
      $.messager.alert("Failed", "Operator Failed");
    },
  });
}

var DevList = undefined;

function RequestDeviceList() {
  ajaxPost(cgi_config, "cmd=device_list&nodata", function(data, status) {
    console.log("REQUESTDEVICELIST: " + status);
    DevList = data;
  });
}

function TreeNodeAdd() {
  var data = [{ text: "DeviceList", children: [{ text: "LocalDevice" }] }];
  var data_leaf = data[0].children;
  RequestDeviceList();
  if (DevList != undefined) {
    console.log(DevList);
    let tmp = DevList.split("&");
    for (var i = 1; i < tmp.length - 1; i++) {
      console.log(tmp[i]);
      data_leaf.push({ text: tmp[i] });
    }
  }
  console.log(data_leaf);
  // init tree for every node
  $("#ptt").tree({ data: data });
}

function RequestFromBoaReadPara() {
  ajaxPost(cgi_config, "cmd=read&nodata", function(data, status) {
    console.log("RequestFromBoaReadPara: " + status);
    cacheData = data;
  });
}

//may payload some data from client
function RequestFromBoaWritePara(WriteCmd, Error) {
  ajaxPost(cgi_config, "cmd=write&" + WriteCmd, function(data, status) {
    Error = data;
  });
}

function ParaListData2Params(RemoteDataArray, ParamsDataArray) {
  var tmp = undefined;
  var tmpCOMMA = undefined;

  var tmpArrayEQ = new Array();
  var tmpArrayCOMMA = new Array();

  for (var i = 1; i < RemoteDataArray.length; i++) {
    if (RemoteDataArray[i] === "") {
      continue;
    }
    tmp = RemoteDataArray[i];
    tmpArrayEQ = tmp.split("=");
    ParamsDataArray[i].index = tmpArrayEQ[0];
    tmpCOMMA = tmpArrayEQ[1];
    tmpArrayCOMMA = tmpCOMMA.split(",");
    ParamsDataArray[i].name = tmpArrayCOMMA[0];
    ParamsDataArray[i].type = tmpArrayCOMMA[1];
    ParamsDataArray[i].coff = tmpArrayCOMMA[2];
    ParamsDataArray[i].attr = tmpArrayCOMMA[3];
    ParamsDataArray[i].len = tmpArrayCOMMA[4];
  }
}

function ParaRead2Params(RemoteDataArray, ParamsDataArray) {
  var tmp = undefined;
  var tmpArrayEQ = new Array();
  for (var i = 1; i < RemoteDataArray.length; i++) {
    tmp = RemoteDataArray[i];
    tmpArrayEQ = tmp.split("=");
    ParamsDataArray[i].index = tmpArrayEQ[0];
    ParamsDataArray[i].value = tmpArrayEQ[1];
  }
}

function clearCacheGlobData() {
  cacheData = undefined;
  cacheDataArray = null;
  cacheDataParaList = undefined;
  cacheDataParaListArray = null;
}

function ParamsType() {
  var tmp_index = undefined;
  OptInfoArgs.length = 0;
  SystemInfoArgs.length = 0;
  AlarmInfoArgs.length = 0;
  AlarmConfigArgs.length = 0;
  NetWorkConfigArgs.length = 0;
  RadioConfigCommonArgs.length = 0;
  RadioConfigFourArgs.length = 0;
  RadioConfigOneArgs.length = 0;
  RadioConfigTwoArgs.length = 0;
  RadioConfigThreeArgs.length = 0;
  CarrierConfigOneArgs.length = 0;
  CarrierConfigTwoArgs.length = 0;
  MiscInfoArgs.length = 0;
  FactorySetupArgs.length = 0;

  for (var i = 0; i < ParamsDataArray.length; i++) {
    tmp_index = parseInt(ParamsDataArray[i].attr);
    if (FilterIndex(SystemFilterIndex, tmp_index)) {
      SystemInfoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(OptInfoFilterIndex, tmp_index)) {
      OptInfoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(AlarmFilterIndex, tmp_index)) {
      AlarmInfoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(AlarmConfigFilterIndex, tmp_index)) {
      AlarmConfigArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(RadioConfigCommonFilterIndex, tmp_index)) {
      RadioConfigCommonArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(RadioConfigOneFilterIndex, tmp_index)) {
      RadioConfigOneArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(RadioConfigTwoFilterIndex, tmp_index)) {
      RadioConfigTwoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(RadioConfigThreeFilterIndex, tmp_index)) {
      RadioConfigThreeArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(RadioConfigFourFilterIndex, tmp_index)) {
      RadioConfigFourArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(CarrierConfigOneFilterIndex, tmp_index)) {
      CarrierConfigOneArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(CarrierConfigTwoFilterIndex, tmp_index)) {
      CarrierConfigTwoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(NetWorkConfigFilterIndex, tmp_index)) {
      NetWorkConfigArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(MiscInfoFilterIndex, tmp_index)) {
      MiscInfoArgs.push(ParamsDataArray[i]);
    } else if (FilterIndex(FactorySetupFilterIndex, tmp_index)) {
      FactorySetupArgs.push(ParamsDataArray[i]);
    }
  }
}

var ParamsDataArray = new Array();

$(function() {
  clearCacheGlobData();
  clearDataTable();
  RequestFromBoaParaList();
  cacheDataParaListArray = cacheDataParaList.split("&");
  console.log(cacheDataParaListArray);

  RequestFromBoaReadPara();
  cacheDataArray = cacheData.split("&");
  console.log(cacheDataArray);

  if (cacheDataParaListArray.length != cacheDataArray.length) {
    $.messager.alert("Error", "Parameter list incomplete");
  } else {
    $.messager.alert("Success", "SUCCESSFULL");
  }

  for (var i = 0; i < cacheDataArray.length; i++) {
    ParamsDataArray.push(new ParamsData("0", "0", "0", "0", "0", "0", "0"));
  }

  ParaListData2Params(cacheDataParaListArray, ParamsDataArray);
  ParaRead2Params(cacheDataArray, ParamsDataArray);

  //default zh
  ajaxJson("zhTable.json");
  //reload with chinese
  if (ZH_TABLE != undefined) {
    console.log("ZH_TABLE");
    console.log(ZH_TABLE);
  }

  for (var i = 0; i < ParamsDataArray.length; i++) {
    if (ParamsDataArray[i].name == 0) {
      continue;
    }
    if (ParamsDataArray[i].index === ZH_TABLE[i].ID) {
      ParamsDataArray[i].name = ZH_TABLE[i].NAME;
      console.log(ZH_TABLE[i].NAME);
    }
    if (DEBUG) {
      console.log(ParamsDataArray[i].NAME);
    }
  }

  for (var i = 0; i < ParamsDataArray.length; i++) {
    if (ParamsDataArray[i].type == "uint1" && ParamsDataArray[i].len > 1) {
      console.log("FilterArray: ");
      console.log(ParamsDataArray[i]);
      continue;
    }
    if (ParamsDataArray[i].type != "str" && ParamsDataArray[i].coff != 1) {
      ParamsDataArray[i].value =
        parseInt(ParamsDataArray[i].value) / parseInt(ParamsDataArray[i].coff);
    }

    if (ParamsDataArray[i].type == "sint1") {
      if (ParamsDataArray[i].value > 127) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 255;
      }
    }

    if (ParamsDataArray[i].type == "sint2") {
      if (ParamsDataArray[i].value > 32767) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 65535;
      }
    }
    if (ParamsDataArray[i].type == "sint4") {
      if (ParamsDataArray[i].value > 2147483647) {
        ParamsDataArray[i].value =
          ParamsDataArray[i].value - 2147483647 * 2 - 1;
      }
    }
  }

  ParamsType();

  console.log(ParamsDataArray);

  var DeviceInfo = new Object();
  DeviceInfo.SystemInfo = new CenterBlockClass(
    "#SystemInfo",
    "SystemInfoTable",
    SystemInfoArgs,
  );

  DeviceInfo.AlarmInfo = new CenterBlockClass(
    "#AlarmInfo",
    "AlarmInfoTable",
    AlarmInfoArgs,
  );

  DeviceInfo.OptInfo = new CenterBlockClass(
    "#OptInfo",
    "OptInfoTable",
    OptInfoArgs,
  );

  var DeviceConfig = new Object();
  DeviceConfig.NetWorkConfig = new CenterBlockClass(
    "#NetWorkConfig",
    "NetConfigTable",
    NetWorkConfigArgs,
  );

  DeviceConfig.AlarmConfig = new CenterBlockClass(
    "#AlarmConfig",
    "AlarmConfigTable",
    AlarmConfigArgs,
  );

  DeviceConfig.RadioConfigCommon = new CenterBlockClass(
    "#RadioConfigCommon",
    "RadioConfigCommonTable",
    RadioConfigCommonArgs,
  );

  DeviceConfig.RadioConfigOne = new CenterBlockClass(
    "#RadioConfigOne",
    "RadioConfigOneTable",
    RadioConfigOneArgs,
  );

  DeviceConfig.RadioConfigTwo = new CenterBlockClass(
    "#RadioConfigTwo",
    "RadioConfigTwoTable",
    RadioConfigTwoArgs,
  );

  DeviceConfig.RadioConfigThree = new CenterBlockClass(
    "#RadioConfigThree",
    "RadioConfigThreeTable",
    RadioConfigThreeArgs,
  );

  DeviceConfig.RadioConfigFour = new CenterBlockClass(
    "#RadioConfigFour",
    "RadioConfigFourTable",
    RadioConfigFourArgs,
  );

  DeviceConfig.CarrierConfigOne = new CenterBlockClass(
    "#CarrierConfigOne",
    "CarrierConfigOneTable",
    CarrierConfigOneArgs,
  );

  DeviceConfig.CarrierConfigTwo = new CenterBlockClass(
    "#CarrierConfigTwo",
    "CarrierConfigTwoTable",
    CarrierConfigTwoArgs,
  );

  DeviceConfig.MiscInfo = new CenterBlockClass(
    "#MiscInfo",
    "MiscInfoTable",
    MiscInfoArgs,
  );
  DeviceConfig.FactorySetup = new CenterBlockClass(
    "#FactorySetup",
    "FactorySetupTable",
    FactorySetupArgs,
  );

  var CenterBlockEvent = new Array();
  CenterBlockEvent["SystemInfo"] = DeviceInfo.SystemInfo;
  CenterBlockEvent["AlarmInfo"] = DeviceInfo.AlarmInfo;
  CenterBlockEvent["OptInfo"] = DeviceInfo.OptInfo;
  CenterBlockEvent["NetWorkConfig"] = DeviceConfig.NetWorkConfig;
  CenterBlockEvent["AlarmConfig"] = DeviceConfig.AlarmConfig;
  CenterBlockEvent["RadioConfigCommon"] = DeviceConfig.RadioConfigCommon;
  CenterBlockEvent["RadioConfigOne"] = DeviceConfig.RadioConfigOne;
  CenterBlockEvent["RadioConfigTwo"] = DeviceConfig.RadioConfigTwo;
  CenterBlockEvent["RadioConfigThree"] = DeviceConfig.RadioConfigThree;
  CenterBlockEvent["RadioConfigFour"] = DeviceConfig.RadioConfigFour;
  CenterBlockEvent["CarrierConfigOne"] = DeviceConfig.CarrierConfigOne;
  CenterBlockEvent["CarrierConfigTwo"] = DeviceConfig.CarrierConfigTwo;
  CenterBlockEvent["MiscInfo"] = DeviceConfig.MiscInfo;
  CenterBlockEvent["FactorySetup"] = DeviceConfig.FactorySetup;

  $("#tt").tree({
    onClick: function(node) {
      var index = node.text;
      var ack_index = index.split('"');
      var txt = ack_index[2];
      var tmp_txt = txt.split(">");
      $("#HomeIndex").tabs("select", FirstTmp);
      var tab = $("#HomeIndex").tabs("getSelected");
      $("#HomeIndex").tabs("update", {
        tab: tab,
        options: {
          title: tmp_txt,
        },
      });
      do {
        if (ack_index[1] == undefined) {
          break;
        }
        FirstTmp = txt;
        clearDataTable();
        TableType = CenterBlockEvent[ack_index[1]].type;
        DrawTable(CenterBlockEvent[ack_index[1]].args);
      } while (0);
    },
  });
});

dataGrid.js

var editIndex = undefined;
var SystemInfoData = undefined;
var AlarmInfoData = undefined;
var NetWorkConfigData = undefined;
var RadioConfigData = undefined;
var checked = undefined;

function AddDataGrid(ParamsData) {
  $("#dg").datagrid("appendRow", {
    paramsIndex: ParamsData.index,
    paramsName: ParamsData.name,
    paramsCoff: ParamsData.coff,
    paramsAttr: ParamsData.attr,
    paramsType: ParamsData.type,
    paramsValue: ParamsData.value,
    paramsLength: ParamsData.len,
    UpdateTime:
      new Date().getFullYear() +
      "-" +
      (new Date().getMonth() + 1) +
      "-" +
      new Date().getDate() +
      " " +
      new Date().getHours() +
      ":" +
      new Date().getMinutes() +
      ":" +
      new Date().getSeconds(),
  });
}

function endEditing() {
  if (editIndex == undefined) {
    return true;
  }
  if ($("#dg").datagrid("validateRow", editIndex)) {
    $("#dg").datagrid("endEdit", editIndex);
    editIndex = undefined;
    return true;
  } else {
    return false;
  }
}

function onClickCell(index, field) {
  if (editIndex != index) {
    if (endEditing()) {
      $("#dg").datagrid("selectRow", index).datagrid("beginEdit", index);
      var ed = $("#dg").datagrid("getEditor", { index: index, field: field });
      if (ed) {
        ($(ed.target).data("textbox")
          ? $(ed.target).textbox("textbox")
          : $(ed.target)
        ).focus();
      }
      editIndex = index;
    } else {
      setTimeout(function() {
        $("#dg").datagrid("selectRow", editIndex);
      }, 0);
    }
  }
}

// 更新客户端数据库
function cancel() {
  $.messager.confirm("Info:", "Whether to cancel the check?", function(r) {
    if (r) {
      $(":checked").removeAttr("checked");
    }
  });
}

// 更新客户端数据库
function edit() {
  endEditing();
  $.messager.confirm(
    "Info:",
    "Please confirm the submission configuration?",
    function(r) {
      if (r) {
        checked = $("#dg").datagrid("getChecked");
        console.log(checked);
        var CmdWrite = "";
        var tmp = 0;
        for (var i = 0; i < checked.length; i++) {
          if (checked[i].paramsType == "uint1" && checked[i].paramsLength > 1) {
            console.log("FilterArray: ");
            console.log(checked[i]);
            tmp = checked[i].paramsValue;
            CmdWrite += checked[i].paramsIndex + "=" + tmp + "&";
            continue;
          }
          if (checked[i].paramsType != "str") {
            tmp =
              parseFloat(checked[i].paramsCoff) *
              parseFloat(checked[i].paramsValue);
          } else {
            tmp = checked[i].paramsValue;
          }
          CmdWrite += checked[i].paramsIndex + "=" + tmp + "&";
        }
        console.log(CmdWrite);
        var err = undefined;
        RequestFromBoaWritePara(CmdWrite, err);
      } else {
        $(":checked").removeAttr("checked");
      }
    },
  );
}
function zhBar() {
  $("#SystemInfo").text("系统基本信息");
  $("#MiscInfo").text("基础状态");
  $("#AlarmInfo").text("告警状态");
  $("#dev setup").text("设备初始化");
  $("#NetWorkConfig").text("网络设置");
  $("#RadioConfigCommon").text("射频常用设置");
  $("#CarrierConfigOne").text("载波 一");
  $("#CarrierConfigTwo").text("载波 二");
  $("#FactorySetup").text("工厂初始化设置");
}

function enBar() {
  $("#SystemInfo").text("Base Infomation");
  $("#MiscInfo").text("Misc Info");
  $("#AlarmInfo").text("Alarm Info");
  $("#dev setup").text("Device Setup");
  $("#NetWorkConfig").text("NetWorkConfig");
  $("#RadioConfigCommon").text("RadioConfigCommon");
  $("#CarrierConfigOne").text("CarrierConfigOne");
  $("#CarrierConfigTwo").text("CarrierConfigTwo");
  $("#FactorySetup").text("FactorySetup");
}

CH = true;
EN = false;
function chinese() {
  zhBar();
  RequestFromBoaReadPara();
  cacheDataArray = cacheData.split("&");
  console.log(cacheDataArray);
  CH = true;
  EN = false;
  if (cacheDataParaListArray.length !== cacheDataArray.length) {
    $.messager.alert("Error", "Parameter list incomplete");
  } else {
    $.messager.alert("Success", "Get the full parameter list");
  }

  ParaListData2Params(cacheDataParaListArray, ParamsDataArray);
  ParaRead2Params(cacheDataArray, ParamsDataArray);

  ajaxJson("zhTable.json");
  //reload with chinese
  if (ZH_TABLE != undefined) {
    console.log("CHINESE ZH_TABLE");
    console.log(ZH_TABLE);
  }

  for (var i = 0; i < ParamsDataArray.length; i++) {
    if (ParamsDataArray[i].name == 0) {
      continue;
    }
    if (ParamsDataArray[i].index === ZH_TABLE[i].ID) {
      ParamsDataArray[i].name = ZH_TABLE[i].NAME;
      console.log(ZH_TABLE[i].NAME);
    }
    if (DEBUG) {
      console.log(ParamsDataArray[i].NAME);
    }
  }

  for (var i = 0; i < ParamsDataArray.length; i++) {
    if (ParamsDataArray[i].type === "uint1" && ParamsDataArray[i].len > 1) {
      console.log("FilterArray: ");
      console.log(ParamsDataArray[i]);
      continue;
    }
    if (ParamsDataArray[i].type !== "str" && ParamsDataArray[i].coff !== 1) {
      ParamsDataArray[i].value =
        parseInt(ParamsDataArray[i].value) / parseInt(ParamsDataArray[i].coff);
    }

    if (ParamsDataArray[i].type === "sint1") {
      if (ParamsDataArray[i].value > 127) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 255;
      }
    }

    if (ParamsDataArray[i].type == "sint2") {
      if (ParamsDataArray[i].value > 32767) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 65535;
      }
    }
    if (ParamsDataArray[i].type == "sint4") {
      if (ParamsDataArray[i].value > 2147483647) {
        ParamsDataArray[i].value =
          ParamsDataArray[i].value - 2147483647 * 2 - 1;
      }
    }
  }

  ParamsType();

  var TableTmp = undefined;

  if (TableType == "SystemInfoTable") {
    TableTmp = SystemInfoArgs;
  } else if (TableType == "AlarmInfoTable") {
    TableTmp = AlarmInfoArgs;
  } else if (TableType == "OptInfoTable") {
    TableTmp = OptInfoArgs;
  } else if (TableType == "NetConfigTable") {
    TableTmp = NetWorkConfigArgs;
  } else if (TableType == "AlarmConfigTable") {
    TableTmp = AlarmConfigArgs;
  } else if (TableType == "RadioConfigCommonTable") {
    TableTmp = RadioConfigCommonArgs;
  } else if (TableType == "RadioConfigOneTable") {
    TableTmp = RadioConfigOneArgs;
  } else if (TableType == "RadioConfigTwoTable") {
    TableTmp = RadioConfigTwoArgs;
  } else if (TableType == "RadioConfigThreeTable") {
    TableTmp = RadioConfigThreeArgs;
  } else if (TableType == "RadioConfigFourTable") {
    TableTmp = RadioConfigFourArgs;
  } else if (TableType == "CarrierConfigOneTable") {
    TableTmp = CarrierConfigOneArgs;
  } else if (TableType == "CarrierConfigTwoTable") {
    TableTmp = CarrierConfigTwoArgs;
  } else if (TableType == "MiscInfoTable") {
    TableTmp = MiscInfoArgs;
  } else if (TableType == "FactorySetupTable") {
    TableTmp = FactorySetupArgs;
  }
  //coef calc for value
  console.log(TableTmp);
  clearDataTable();
  DrawTable(TableTmp);
}

function english() {
  enBar();
  RequestFromBoaReadPara();
  cacheDataArray = cacheData.split("&");
  console.log(cacheDataArray);

  CH = false;
  EN = true;
  if (cacheDataParaListArray.length != cacheDataArray.length) {
    $.messager.alert("Error", "Parameter list incomplete");
  } else {
    $.messager.alert("Success", "Get the full parameter list");
  }

  ParaListData2Params(cacheDataParaListArray, ParamsDataArray);
  ParaRead2Params(cacheDataArray, ParamsDataArray);
  for (var i = 0; i < ParamsDataArray.length; i++) {
    if (ParamsDataArray[i].type == "uint1" && ParamsDataArray[i].len > 1) {
      console.log("FilterArray: ");
      console.log(ParamsDataArray[i]);
      continue;
    }
    if (ParamsDataArray[i].type != "str" && ParamsDataArray[i].coff != 1) {
      ParamsDataArray[i].value =
        parseInt(ParamsDataArray[i].value) / parseInt(ParamsDataArray[i].coff);
    }

    if (ParamsDataArray[i].type == "sint1") {
      if (ParamsDataArray[i].value > 127) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 255;
      }
    }

    if (ParamsDataArray[i].type == "sint2") {
      if (ParamsDataArray[i].value > 32767) {
        ParamsDataArray[i].value = ParamsDataArray[i].value - 65535;
      }
    }
    if (ParamsDataArray[i].type == "sint4") {
      if (ParamsDataArray[i].value > 2147483647) {
        ParamsDataArray[i].value =
          ParamsDataArray[i].value - 2147483647 * 2 - 1;
      }
    }
  }

  ParamsType();

  var TableTmp = undefined;

  if (TableType === "SystemInfoTable") {
    TableTmp = SystemInfoArgs;
  } else if (TableType === "AlarmInfoTable") {
    TableTmp = AlarmInfoArgs;
  } else if (TableType === "OptInfoTable") {
    TableTmp = OptInfoArgs;
  } else if (TableType === "NetConfigTable") {
    TableTmp = NetWorkConfigArgs;
  } else if (TableType === "AlarmConfigTable") {
    TableTmp = AlarmConfigArgs;
  } else if (TableType === "RadioConfigCommonTable") {
    TableTmp = RadioConfigCommonArgs;
  } else if (TableType === "RadioConfigOneTable") {
    TableTmp = RadioConfigOneArgs;
  } else if (TableType == "RadioConfigTwoTable") {
    TableTmp = RadioConfigTwoArgs;
  } else if (TableType == "RadioConfigThreeTable") {
    TableTmp = RadioConfigThreeArgs;
  } else if (TableType == "RadioConfigFourTable") {
    TableTmp = RadioConfigFourArgs;
  } else if (TableType == "CarrierConfigOneTable") {
    TableTmp = CarrierConfigOneArgs;
  } else if (TableType == "CarrierConfigTwoTable") {
    TableTmp = CarrierConfigTwoArgs;
  } else if (TableType == "MiscInfoTable") {
    TableTmp = MiscInfoArgs;
  } else if (TableType == "FactorySetupTable") {
    TableTmp = FactorySetupArgs;
  }
  //coef calc for value
  console.log(TableTmp);
  clearDataTable();
  DrawTable(TableTmp);
}

function reload() {
  if (CH) {
    chinese();
  } else if (EN) {
    english();
  }
}

function getChanges() {
  $.messager.show({
    title: "Modified data that has been submitted",
    height: 400,
    width: 800,
    msg: JSON.stringify(checked),
    showType: "slide",
    timeout: 5000000000,
    style: {
      right: "",
      bottom: "",
    },
  });
}

function clearDataTable() {
  $("#dg").datagrid("loadData", { total: 0, rows: [] });
}

//add data table
function DrawTable(ParamsDataArrayN) {
  for (var i = 0; i < ParamsDataArrayN.length; i++) {
    if (ParamsDataArrayN[i].name != "0") {
      AddDataGrid(ParamsDataArrayN[i]);
    }
  }
}

cgiOperator.js

class ParamsData {
  constructor(index, name, coff, attr, type, value, len) {
    this.index = index;
    this.name = name;
    this.coff = coff;
    this.attr = attr;
    this.type = type;
    this.value = value;
    this.len = len;
    this.time = (new Date()).getHours()+":"+(new Date()).getMinutes()+":"+(new Date()).getSeconds();
  }
}

class CenterBlockClass {
  constructor(index, type, args) {
    this.index = index;
    this.type = type;
    this.args = args;
  }
}

var FirstTmp = "Home";
function setCenterBlockEvent(CenterBlockClass) {
  $(CenterBlockClass.index).click(function () {
    var txt = $(this).text();
    $("#HomeIndex").tabs("select", FirstTmp);
    var tab = $("#HomeIndex").tabs("getSelected");
    $("#HomeIndex").tabs("update", {
      tab: tab,
      options: {
        title: txt,
      },
    });
    FirstTmp = txt;
    clearDataTable();
    TableType = CenterBlockClass.type;
    DrawTable(CenterBlockClass.args);
  });
}

显示看很勉强

在这里插入图片描述
在这里插入图片描述

现在看尴尬的扣脚,勉强可用

python -m http.server 5090

python server 验证 网页

cgi 还挺容易的,都可以动态修改,看到显示的变化

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/896733.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vue根据template结构自动生成css/scss/less样式嵌套

vscode搜索安装插件&#xff1a;AutoScssStruct4Vue

Java实现postgre数据库每日定时自动备份

前提&#xff1a;该备份仅为同数据库不同schema备份 假设需要备份的数据库为test&#xff0c;schema为public。代码如下 public void backupAllTables() {log.info("备份全表开始执行" System.currentTimeMillis());String origScheme1 "public";String…

卷积神经网络全解!CNN结构、训练与优化全维度介绍!

目录 一、引言1.1 背景和重要性1.2 卷积神经网络概述 二、卷积神经网络层介绍2.1 卷积操作卷积核与特征映射卷积核大小多通道卷积 步长与填充步长填充 空洞卷积&#xff08;Dilated Convolution&#xff09;分组卷积&#xff08;Grouped Convolution&#xff09; 2.2 激活函数R…

Excel自动化办公——Openpyxl的基本使用

Excel自动化办公——Openpyxl的基本使用 个人感觉&#xff0c;相比Pandas&#xff0c;openpyxl对Excel的操作更为细致&#xff0c;Pandas则更适用于统计计算&#xff1b; 01 基本环境02 Excel数据读取操作03 案例04 向Excel写入数据05 表数据定向修改06 单元格样式制定07 单元…

2019年3月全国计算机等级考试真题(C语言二级)

2019年3月全国计算机等级考试真题&#xff08;C语言二级&#xff09; 第1题 负责数据库中查询操作的数据库语言是 A. 数据定义语言 B. 数据管理语言 C. 数据操纵语言 D. 数据控制语言 正确答案&#xff1a;C 第2题 有关系如下图所示&#xff0c;其违反了哪一类完整性约束 …

c++——静态成员变量、静态成员函数和const修饰的静态成员变量

一、c静态成员变量 在C中&#xff0c;静态成员变量&#xff08;Static Member Variable&#xff09;是类的一种特殊类型的成员变量&#xff0c;它被类的所有实例共享&#xff0c;而不是每个实例都有自己的副本。静态成员变量在类的所有对象之间保持唯一的状态&#xff0c;具有…

ElementPlusError 解决: [ElForm] model is required for validate to work 的三种方式

1、问题描述&#xff1a; 其一、报错为&#xff1a; ElementPlusError: [ElForm] model is required for validate to work. 中文为&#xff1a; ElementPlusError&#xff1a;验证工作需要 [ElForm] 模型 其二、问题描述为&#xff1a; 在 form 表单中需要进行规则校验&a…

分布式锁系列之Redis分布式锁

目录 介绍 模拟订单超卖场景 代码版 不加锁情况 synchronized加锁 ​编辑 lock加锁 整合Mysql版 不加锁版 synchronized加锁 lock加锁版 jvm加锁失效情况 多例模式 事务 集群搭建 书写sql解决集群超卖 使用悲观锁select ...for update ​编辑 不加悲观锁情况 使用…

备份或同步数据?跨国大文件传输的不同需求与解决方案

信息化时代的到来&#xff0c;使得许多个人、组织、企业在日常生活中都需要对数据进行备份或同步。但不同的应用场景和需求&#xff0c;也需要不同的备份和同步方式。而在跨国大文件传输方面&#xff0c;更是需要根据不同需求选择合适的传输方案。下面将分别介绍备份与同步数据…

第一章MyBatis概述

框架 Java常用框架 SSM三大框架&#xff1a;SpringSpringMVCMyBatisSpringBootSpringCloud 框架简单来说就是提前封装好的通用代码&#xff0c;提高我们的开发的效率&#xff08;站在巨人的肩膀上&#xff09; 框架一般以jar包的形式存在 三层架构 代码封装主要为了降低代…

MQTT 常用客户端库介绍 (全面涵盖c,c++,java,c#,python)

MQTT&#xff08;Message Queuing Telemetry Transport&#xff09;是一种轻量级的通信协议&#xff0c;被广泛应用于物联网和分布式系统中。它以其简单、可靠和高效的特性而备受推崇&#xff0c;成为连接设备和应用程序的首选协议。MQTT的重要性不言而喻&#xff0c;它为实时通…

K8S应用笔记 —— 签发自签名证书用于Ingress的https配置

一、需求描述 在本地签发自命名证书&#xff0c;用于K8S集群的Ingress的https配置。 前提条件&#xff1a; 完成K8S集群搭建。完成证书制作机器的openssl服务安装。 二、自签名证书制作 2.1 脚本及配置文件准备 2.1.1 CA.sh脚本准备 注意事项&#xff1a; openssl服务默认CA…

【vim 学习系列文章 5 - cscope 过滤掉某些目录】

文章目录 cscope 过滤目录介绍 cscope 过滤目录介绍 第一步创建自己的cscope脚本~/.local/bin/cscope.sh&#xff0c;如下&#xff1a; function my_cscope() {CODE_PATHpwdecho "$CODE_PATH"echo "start cscope...."if [ ! -f "$CODE_PATH/cscope.…

qt实现9×9数独游戏

qt实现的数独小游戏&#xff0c;资源有可下载直接跑的exe&#xff08;enigma已经打包好&#xff09;&#xff0c;源码可私信 部分代码 #include "widget.h" #include "ui_widget.h" #include"form.h" #include<QDebug> #include<QPush…

数据结构——二叉搜索树(附带C++实现版本)

文章目录 二叉搜索树概念 二叉树的实际应用二叉树模拟实现存储结构二叉搜索树构成二叉搜索树的查找插入操作中序遍历二叉树的删除循环(利用左子树最右节点&#xff09;递归(利用右子树根节点) 二叉树拷贝二叉树资源的销毁 二叉树实现完整代码总结 二叉搜索树 概念 二叉搜索树…

LVS-DR+keepalived实现高可用负载群集

VRRP 通信原理&#xff1a; VRRP就是虚拟路由冗余协议&#xff0c;它的出现就是为了解决静态路由的单点故障。 VRRP是通过一种竞选的一种协议机制&#xff0c;来将路由交给某台VRRP路由。 VRRP用IP多播的方式&#xff08;多播地址224.0.0.18&#xff09;来实现高可用的通信&…

opencv运动目标检测-背景建模

背景建模 帧差法 由于场景中的目标在运动&#xff0c;目标的影像在不同图像帧中的位置不同。该类算法对时间上连续的两帧图像进行差分运算&#xff0c;不同帧对应的像素点相减&#xff0c;判断灰度差的绝对值&#xff0c;当绝对值超过一定阈值时&#xff0c;即可判断为运动目…

Java虚拟机(JVM):垃圾收集算法

目录 一、分代收集理论 二、标记-清除算法 三、标记-复制算法 四、标记-整理算法 一、分代收集理论 分代收集理论建立在两个分代假说之上&#xff1a; 1、弱分代假说&#xff1a;绝大多数对象都是朝生夕灭的。 2、强分代假说&#xff1a;熬过越多次垃圾收集过程的对象就…

Python中数据结构列表详解

列表是最常用的 Python 数据类型&#xff0c;它用一个方括号内的逗号分隔值出现&#xff0c;列表的数据项不需要具有相同的类型。 列表中的每个值都有对应的位置值&#xff0c;称之为索引&#xff0c;第一个索引是 0&#xff0c;第二个索引是 1&#xff0c;依此类推。列表都可…

C语言之指针进阶篇(1)

目录​​​​​​​ 引言 字符指针 指针数组 数组指针 数组指针的定义 &数组名vs数组名 数组指针的使用 一维数组使用 二维数组使用 一维数组传参 二维数组传参 总结 数组参数 一维数组传参 二维数组传参 指针参数 一级指针传参 二级指针传参 引言 今…