
var draw_diagnostics = function() {
    getFullPanel(0, 0, 3, 9, "tab-page-diagnostics", "sec-diag-1", "MAIN UNIT", "DIAGNOSTICS", "VER 1.0");
    var panel = document.getElementById("sec-diag-1");
    panel.innerHTML += draw_diagnostics_main_n1();
    panel.innerHTML += draw_diagnostics_main_0();
    panel.innerHTML += draw_diagnostics_main_1();
    panel.innerHTML += draw_diagnostics_main_2();
    panel.innerHTML += draw_diagnostics_main_3();
    panel.innerHTML += draw_diagnostics_main_4();
    panel.innerHTML += draw_diagnostics_main_5();
    panel.innerHTML += draw_diagnostics_main_6();
    panel.innerHTML += draw_diagnostics_main_7();
    
    getFullPanel(3, 0, 3, 9, "tab-page-diagnostics", "sec-diag-2", "FLOW/FC CONTROL", "DIAGNOSTICS", "VER 1.0");
    var panel = document.getElementById("sec-diag-2");
    panel.innerHTML += draw_diagnostics_flow_0();
    panel.innerHTML += draw_diagnostics_flow_2();
    panel.innerHTML += draw_diagnostics_flow_3();
    panel.innerHTML += draw_diagnostics_flow_4();
    panel.innerHTML += draw_diagnostics_flow_5();
    
    getFullPanel(6, 0, 3, 9, "tab-page-diagnostics", "sec-diag-3", "HYDR CONTROL", "DIAGNOSTICS", "VER 1.0");
    var panel = document.getElementById("sec-diag-3");
    panel.innerHTML += draw_diagnostics_hydr_0();
    panel.innerHTML += draw_diagnostics_hydr_2();
    panel.innerHTML += draw_diagnostics_hydr_3();
    panel.innerHTML += draw_diagnostics_hydr_4();
}

var draw_diagnostics_main_n1 = function() {
    var html = getSectionTitle('USB COMMS');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-usbcomms-1', 'USB TO RS232');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_0 = function() {
    var html = getSectionTitle('FLASH');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-flash-1', 'CHIP 1');
    row += getInfoCell('diag-main-flash-2', 'CHIP 2');
    row += getInfoCell('diag-main-flash-3', 'CHIP 3');
    row += getInfoCell('diag-main-flash-4', 'CHIP 4');
    rows += getInfoRow(row);
    row = getInfoCell('diag-main-flash-5', 'CHIP 5');
    row += getInfoCell('diag-main-flash-6', 'CHIP 6');
    row += getInfoCell('diag-main-flash-7', 'CHIP 7');
    row += getInfoCell('diag-main-flash-8', 'CHIP 8');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_1 = function() {
    var html = getSectionTitle('EEPROM');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-eeprom-1', 'EEPROM');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_2 = function() {
    var html = getSectionTitle('GPS');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-gps-int', 'INTERNAL GPS');
    row += getInfoCell('diag-main-gps-ext', 'EXTERNAL GPS');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_3 = function() {
    var html = getSectionTitle('LCD');
    var rows = '';
    var row = '';
    row = '<td><div class="ai-cell ai-cell-info-1" id="diag-main-lcd" onclick="LCDMainWorks();">LCD</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_4 = function() {
    var html = getSectionTitle('KEYPAD');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-keypad-1', 'KEY 1');
    row += getInfoCell('diag-main-keypad-2', 'KEY 2');
    row += getInfoCell('diag-main-keypad-3', 'KEY 3');
    row += getInfoCell('diag-main-keypad-4', 'KEY 4');
    row += getInfoCell('diag-main-keypad-5', 'KEY 5');
    rows += getInfoRow(row);
    row = getInfoCell('diag-main-keypad-6', 'KEY 6');
    row += getInfoCell('diag-main-keypad-7', 'KEY 7');
    row += getInfoCell('diag-main-keypad-8', 'KEY 8');
    row += getInfoCell('diag-main-keypad-9', 'KEY 9');
    row += getInfoCell('diag-main-keypad-10', 'KEY 10');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_5 = function() {
    var html = getSectionTitle('USB FLASH');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-usb', 'USB');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_6 = function() {
    var html = getSectionTitle('COMMS');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-main-can-bus', 'CAN BUS');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_main_7 = function() {
    var html = getSectionTitle('CHECKOUT');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'PROGRESS');
    row += getInfoCell('diag-main-checkout', '0%');
    rows += getInfoRow(row);
    row = '<td><div class="ai-cell ai-cell-info-1" id="diag-main-reset" onclick="ResetDiagnosticsMain();">RESET</div></td>';
    row += '<td><div class="ai-cell ai-cell-danger" id="diag-main-start" onclick="StartDiagnosticsMain();">START</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_flow_0 = function() {
    var html = getSectionTitle('DEVICES');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-flow-motor', 'MOTOR');
    row += getInfoCell('diag-flow-pickup', 'PICKUP');
    row += getInfoCell('diag-flow-engage', 'ENGAGE');
    row += getInfoCell('diag-flow-pressure', 'PRESSURE');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_flow_2 = function() {
    var html = getSectionTitle('DIPSWITCH');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-flow-dipswitch-1', 'SWITCH 1');
    row += getInfoCell('diag-flow-dipswitch-2', 'SWITCH 2');
    row += getInfoCell('diag-flow-dipswitch-3', 'SWITCH 3');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_flow_3 = function() {
    var html = getSectionTitle('COMMS');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-flow-can-bus', 'CAN BUS');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_flow_4 = function() {
    var html = getSectionTitle('KEYPAD');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-flow-keypad-1', 'KEY 1');
    row += getInfoCell('diag-flow-keypad-2', 'KEY 2');
    row += getInfoCell('diag-flow-keypad-3', 'KEY 3');
    row += getInfoCell('diag-flow-keypad-4', 'KEY 4');
    row += '<td><div class="ai-cell ai-cell-info-1" id="diag-flow-keypad-green" onclick="DiagFlowGreen();">GREEN</div></td>';
    row += '<td><div class="ai-cell ai-cell-info-1" id="diag-flow-keypad-red" onclick="DiagFlowRed();">RED</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_flow_5 = function() {
    var html = getSectionTitle('CHECKOUT');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'PROGRESS');
    row += getInfoCell('diag-flow-checkout', '0%');
    rows += getInfoRow(row);
    row = '<td><div class="ai-cell ai-cell-info-1" id="diag-flow-reset" onclick="ResetDiagnosticsFlow();">RESET</div></td>';
    row += '<td><div class="ai-cell ai-cell-danger" id="diag-flow-start" onclick="StartDiagnosticsFlow();">START</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_hydr_0 = function() {
    var html = getSectionTitle('DEVICES');
    var rows = '';
    var row = '';
    row += '<td><div class="ai-cell ai-cell-info-1" id="diag-hydr-motor" onclick="DiagHydrMotor();">MOTOR</div></td>';
    row += getInfoCell('diag-hydr-pickup', 'PICKUP');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_hydr_2 = function() {
    var html = getSectionTitle('COMMS');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-hydr-can-bus', 'CAN BUS');
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_hydr_3 = function() {
    var html = getSectionTitle('KEYPAD');
    var rows = '';
    var row = '';
    row = getInfoCell('diag-hydr-keypad-1', 'KEY 1');
    row += getInfoCell('diag-hydr-keypad-2', 'KEY 2');
    row += getInfoCell('diag-hydr-keypad-3', 'KEY 3');
    row += getInfoCell('diag-hydr-keypad-4', 'KEY 4');
    row += '<td><div class="ai-cell ai-cell-info-1" id="diag-hydr-keypad-green" onclick="DiagHydrGreen();">GREEN</div></td>';
    row += '<td><div class="ai-cell ai-cell-info-1" id="diag-hydr-keypad-red" onclick="DiagHydrRed();">RED</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

var draw_diagnostics_hydr_4 = function() {
    var html = getSectionTitle('CHECKOUT');
    var rows = '';
    var row = '';
    row = getInfoCell('', 'PROGRESS');
    row += getInfoCell('diag-hydr-checkout', '0%');
    rows += getInfoRow(row);
    row = '<td><div class="ai-cell ai-cell-info-1" id="diag-hydr-reset" onclick="ResetDiagnosticsHydr();">RESET</div></td>';
    row += '<td><div class="ai-cell ai-cell-danger" id="diag-hydr-start" onclick="StartDiagnosticsHydr();">START</div></td>';
    rows += getInfoRow(row);

    html += getTabel(rows);
    html = getPanel(html);
    return html;
}

draw_diagnostics();

var diagnostic_main_count = function()
{
    var score = 0;
    if (document.getElementById("diag-main-usbcomms-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-2").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-3").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-4").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-5").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-6").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-7").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-flash-8").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-eeprom-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-gps-int").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-gps-ext").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-lcd").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-2").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-3").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-4").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-5").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-6").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-7").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-8").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-9").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-keypad-10").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-usb").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-main-can-bus").className == "ai-cell ai-cell-success") score++;

    document.getElementById("diag-main-checkout").innerText = ((score*100/25) + ' %');
    if (score < 25) {
        document.getElementById("diag-main-checkout").className = "ai-cell ai-cell-warning";
    } else if (score == 25) {
        document.getElementById("diag-main-checkout").className = "ai-cell ai-cell-success";
    }
}

var diagnostic_flow_count = function()
{
    var score = 0;
    if (document.getElementById("diag-flow-motor").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-pickup").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-engage").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-pressure").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-dipswitch-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-dipswitch-2").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-dipswitch-3").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-2").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-3").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-4").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-green").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-keypad-red").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-flow-can-bus").className == "ai-cell ai-cell-success") score++;

    document.getElementById("diag-flow-checkout").innerText = Math.round(score*100/14) + ' %';
    if (score < 14) {
        document.getElementById("diag-flow-checkout").className = "ai-cell ai-cell-warning";
    } else if (score == 14) {
        document.getElementById("diag-flow-checkout").className = "ai-cell ai-cell-success";
    }
}

var diagnostic_hydr_count = function()
{
    var score = 0;
    if (document.getElementById("diag-hydr-motor").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-pickup").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-1").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-2").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-3").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-4").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-green").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-keypad-red").className == "ai-cell ai-cell-success") score++;
    if (document.getElementById("diag-hydr-can-bus").className == "ai-cell ai-cell-success") score++;

    document.getElementById("diag-hydr-checkout").innerText = Math.round(score*100/9) + ' %';
    if (score < 9) {
        document.getElementById("diag-hydr-checkout").className = "ai-cell ai-cell-warning";
    } else if (score == 9) {
        document.getElementById("diag-hydr-checkout").className = "ai-cell ai-cell-success";
    }
}

var mainDiagStageCounter = 0;

var DiagHydrMotor = function()
{
    document.getElementById("diag-hydr-motor").className = "ai-cell ai-cell-success";
}

var DiagHydrGreen = function()
{
    document.getElementById("diag-hydr-keypad-green").className = "ai-cell ai-cell-success";
}

var DiagHydrRed = function()
{
    document.getElementById("diag-hydr-keypad-red").className = "ai-cell ai-cell-success";
}

var DiagFlowGreen = function()
{
    document.getElementById("diag-flow-keypad-green").className = "ai-cell ai-cell-success";
}

var DiagFlowRed = function()
{
    document.getElementById("diag-flow-keypad-red").className = "ai-cell ai-cell-success";
}

var StartDiagnosticsMain = function()
{
    document.getElementById("diag-main-start").className = "ai-cell ai-cell-success";
}

var StartDiagnosticsFlow = function()
{
    document.getElementById("diag-flow-start").className = "ai-cell ai-cell-success";
}

var StartDiagnosticsHydr = function()
{
    document.getElementById("diag-hydr-start").className = "ai-cell ai-cell-success";
}

var ResetDiagnosticsMain = function()
{
    document.getElementById("diag-main-usbcomms-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-2").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-3").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-4").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-5").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-6").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-7").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-flash-8").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-eeprom-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-gps-int").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-gps-ext").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-lcd").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-2").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-3").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-4").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-5").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-6").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-7").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-8").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-9").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-keypad-10").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-usb").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-can-bus").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-main-start").className = "ai-cell ai-cell-danger";

    document.getElementById("diag-main-checkout").innerText = '0 %';
    document.getElementById("diag-main-checkout").className = "ai-cell ai-cell-info-1";
}

var ResetDiagnosticsFlow = function()
{
    document.getElementById("diag-flow-keypad-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-keypad-2").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-keypad-3").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-keypad-4").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-keypad-green").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-keypad-red").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-motor").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-pickup").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-engage").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-pressure").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-dipswitch-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-dipswitch-2").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-dipswitch-3").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-can-bus").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-flow-start").className = "ai-cell ai-cell-danger";

    document.getElementById("diag-flow-checkout").innerText = '0 %';
    document.getElementById("diag-flow-checkout").className = "ai-cell ai-cell-info-1";
}

var ResetDiagnosticsHydr = function()
{
    document.getElementById("diag-hydr-keypad-1").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-keypad-2").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-keypad-3").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-keypad-4").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-keypad-green").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-keypad-red").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-motor").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-pickup").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-can-bus").className = "ai-cell ai-cell-info-1";
    document.getElementById("diag-hydr-start").className = "ai-cell ai-cell-danger";

    document.getElementById("diag-hydr-checkout").innerText = '0 %';
    document.getElementById("diag-hydr-checkout").className = "ai-cell ai-cell-info-1";
}

var LCDMainWorks = function()
{
    document.getElementById("diag-main-lcd").className = "ai-cell ai-cell-success";
    diagnostic_main_count();
}

var GPSType = -1;

setInterval(function() {
    if (document.getElementById("diag-main-start").className == "ai-cell ai-cell-success") {
        if (document.getElementById("diag-main-usbcomms-1").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "Ping" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-1").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 1" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-2").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 2" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-3").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 3" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-4").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 4" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-5").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 5" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-6").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 6" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-7").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 7" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-flash-8").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 8" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-eeprom-1").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckEEPROM" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-main-gps-int").className != "ai-cell ai-cell-success")  {
            updateMainUnit_GPS(0);
        } else if (document.getElementById("diag-main-gps-ext").className != "ai-cell ai-cell-success")  {
            PrecisionOutput('output');
            updateMainUnit_GPS(1);
        } else {
            if (GPSType != 2) {
                GPSType = 2;
                PrecisionOutput('off');
                updateMainUnit_GPS(0);
            }
        }
        if (document.getElementById("diag-main-keypad-1").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-2").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-3").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-4").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-5").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-6").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-7").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-8").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-9").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-keypad-10").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-gps-int").className != "ai-cell ai-cell-success"
        || document.getElementById("diag-main-gps-ext").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "CheckFlash 1" + String.fromCharCode(13));
        }
    }
    
    if (document.getElementById("diag-flow-start").className == "ai-cell ai-cell-success") {
        if (document.getElementById("diag-flow-keypad-green").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "ConfigMode 0" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-flow-keypad-red").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "ConfigMode 1" + String.fromCharCode(13));
            GPSType = 0;
            return;
        } else {
            if (GPSType != 3) {
                GPSType = 3;
                ipcRenderer.send('main-unit-message', "ConfigMode 0" + String.fromCharCode(13));
            }
        }
    }
    
    if (document.getElementById("diag-hydr-start").className == "ai-cell ai-cell-success") {
        if (document.getElementById("diag-hydr-keypad-green").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "ConfigMode 0" + String.fromCharCode(13));
            return;
        } else if (document.getElementById("diag-hydr-keypad-red").className != "ai-cell ai-cell-success") {
            ipcRenderer.send('main-unit-message', "ConfigMode 1" + String.fromCharCode(13));
            GPSType = 0;
            return;
        } else {
            if (GPSType != 3) {
                GPSType = 3;
                ipcRenderer.send('main-unit-message', "ConfigMode 0" + String.fromCharCode(13));
            }
        }
    }
}, 500);