Skip to content

Commit

Permalink
Updated Code
Browse files Browse the repository at this point in the history
  • Loading branch information
SantamRC committed Apr 12, 2024
1 parent 9fabc76 commit 7409edc
Showing 1 changed file with 27 additions and 38 deletions.
65 changes: 27 additions & 38 deletions HardwareReport/HardwareReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -1166,37 +1166,41 @@ function load_airspeed(log) {
}

// Load GPS
let gps;
const max_num_gps = 2
let num_gps = 0
function load_gps(log) {
let gps = []

// for (let i = 0; i < max_num_gps; i++) {
// let index = String(i+1)
// if (i == 0) {
// index = ""
// }
// const type_name = "GPS_TYPE" + index
// if (type_name in params) {
// const type = params[type_name]
// if (type != 0) {
// const pos_names = get_param_name_vector3("GPS_POS" + (i+1) + "_")
// gps[i] = { type: type,
// pos: get_param_array(params, pos_names),
// node_id: params["GPS_CAN_NODEID" + (i+1)] }
// }
// }
// }
let gps_instances = []

for (let i = 0; i < max_num_gps; i++) {
let index = String(i + 1)
if (i == 0) {
index = ""
}
const type_name = "GPS_TYPE" + index
if (type_name in params) {
const type = params[type_name]
if (type != 0) {
const pos_names = get_param_name_vector3("GPS_POS" + (i + 1) + "_")
gps[i] = {
type: type,
pos: get_param_array(params, pos_names),
node_id: params["GPS_CAN_NODEID" + (i + 1)]
}
}
}
}

let messages = log.get("MSG").Message

let section = document.getElementById("GPS")
let gps_num = 0
// This regular expression is used to get the word after "as" to get the GPS device name. (?<=as\s) will exclude the "as" and a whitespace from the regex and then (\S+) will match the next word.
let regex = /(?<=as\s)(\S+)/i;
for (let i = 0; i < messages.length; i++) {
if (messages[i].startsWith("GPS")) {
let gps_device = messages[i].match(regex)[0];
gps[gps_num++] = { gps: gps_device }
gps_instances[gps_num++] = { gps: gps_device }
}
}

Expand All @@ -1209,38 +1213,22 @@ function load_gps(log) {
heading.innerHTML = "GPS " + inst
fieldset.appendChild(heading)

// const id = decode_devid(params.id, DEVICE_TYPE_BARO)
// print_device(fieldset, id)

fieldset.appendChild(document.createTextNode(params.gps))
fieldset.appendChild(document.createElement("br"))

// fieldset.appendChild(document.createElement("br"))
// fieldset.appendChild(document.createTextNode("Wind compensation: " + (params.wind_cmp ? "\u2705" : "\u274C")))

// if ("all_healthy" in params) {
// fieldset.appendChild(document.createElement("br"))
// fieldset.appendChild(document.createTextNode("Health: " + (params.all_healthy ? "\u2705" : "\u274C")))
// }

return fieldset
}

// let primary = params["BARO_PRIMARY"]
// section.appendChild(document.createTextNode("Primary: " + (primary+1)))
// section.appendChild(document.createElement("br"))
// section.appendChild(document.createElement("br"))

let table = document.createElement("table")
section.appendChild(table)

let have_section = false
for (let i = 0; i < gps.length; i++) {
if (gps[i] != null) {
for (let i = 0; i < gps_instances.length; i++) {
if (gps_instances[i] != null) {
have_section = true
let colum = document.createElement("td")

colum.appendChild(print_gps(i + 1, gps[i]))
colum.appendChild(print_gps(i + 1, gps_instances[i]))
table.appendChild(colum)
}
}
Expand Down Expand Up @@ -2384,6 +2372,7 @@ function reset() {
setup_section(document.getElementById("DroneCAN"))
setup_section(document.getElementById("WAYPOINTS"))
setup_section(document.getElementById("FILES"))
setup_section(document.getElementById("GPS"))

ins = []
compass = []
Expand Down

0 comments on commit 7409edc

Please sign in to comment.