//Variables
var draw_USB_variables = function() {
    getFullPanel(0, 0, 3, 9, "tab-page-usb", "sec-usb-control", "USB", "CONTROL", "VER 1.0");
    var panel = document.getElementById("sec-usb-control");
    panel.innerHTML += draw_USB_variables_1();
    panel.innerHTML += draw_USB_variables_2();
    panel.innerHTML += draw_USB_variables_3();
    panel.innerHTML += draw_USB_variables_4();
    panel.innerHTML += draw_USB_variables_5();
}

var draw_USB_variables_1 = function() {
    var html = getSectionTitle('USB FLAGS');
    var rows = '';

    var row = '';
    row += getInfoCell('flags-usb-com-fail', 'COM_FAIL');
    row += getInfoCell('flags-usb-bad-comm', 'BAD_COMM');
    row += getInfoCell('flags-usb-disk-ful', 'DISK_FUL');
    row += getInfoCell('flags-usb-file-inv', 'FILE_INV');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-read-onl', 'READ_ONL');
    row += getInfoCell('flags-usb-fil-open', 'FIL_OPEN');
    row += getInfoCell('flags-usb-filn-inv', 'FILN_INV');
    row += getInfoCell('flags-usb-end-odat', 'END_ODAT');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-return-s', 'RETURN_S');
    row += getInfoCell('flags-usb-dev-onli', 'DEV_ONLI');
    row += getInfoCell('flags-usb-dev-dete', 'DEV_DETE');
    row += getInfoCell('flags-usb-comm-set', 'COMM_SET');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-data-mod', 'DATA_MOD');
    row += getInfoCell('flags-usb-buff-ovf', 'BUFF_OVF');
    row += getInfoCell('flags-usb-expl-typ', 'EXPL_TYP');
    row += getInfoCell('flags-usb-reserved', 'RESERVED');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-prog-typ', 'PROG_TYP');
    row += getInfoCell('flags-usb-hal-read', 'HAL_READ');
    row += getInfoCell('flags-usb-run--out', 'RUN__OUT');
    row += getInfoCell('flags-usb-vis-allf', 'VIS_ALLF');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-vis-pl-f', 'VIS_PL_F');
    row += getInfoCell('flags-usb-vis-cf-f', 'VIS_CF_F');
    row += getInfoCell('flags-usb-vis-pf-f', 'VIS_PF_F');
    row += getInfoCell('flags-usb-vis-ph-f', 'VIS_PH_F');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('flags-usb-vis-pd-f', 'VIS_PD_F');
    row += getInfoCell('flags-usb-boot-mod', 'BOOT_MOD');
    rows += getInfoRow(row);

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

var draw_USB_variables_2 = function() {
    var html = getSectionTitle('USB COUNTERS');
    var rows = '';
    var row = '';
    row += getInfoCell('', 'RETURN_PAGE');
    row += getInfoCell('counter-usb-return-page', '0');
    row += getInfoCell('', 'READ_D_F_TYP');
    row += getInfoCell('counter-usb-read-d-f-typ', '0');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('', 'WRIT_D_F_TYP');
    row += getInfoCell('counter-usb-writ-d-f-typ', '0');
    row += getInfoCell('', 'MAIN_ACTION');
    row += getInfoCell('counter-usb-main-action', '0');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('', 'BASE_ACTION');
    row += getInfoCell('counter-usb-base-action', '0');
    row += getInfoCell('', 'COMM_ACTION');
    row += getInfoCell('counter-usb-comm-action', '0');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('', 'PROG_DEVICE');
    row += getInfoCell('counter-usb-prog-device', '0');
    row += getInfoCell('', 'DIREC_LEVEL');
    row += getInfoCell('counter-usb-direc-level', '0');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('', 'READ_COUNTER');
    row += getInfoCell('counter-usb-read-counter', '0');
    row += getInfoCell('', 'PAGE COUNTER');
    row += getInfoCell('counter-usb-page-counter', '0');
    rows += getInfoRow(row);

    row = '';
    row += getInfoCell('', 'FILE_LENGTH');
    row += getInfoCell('counter-usb-file-length', '0');
    row += getInfoCell('', 'DATA COUNTER');
    row += getInfoCell('counter-usb-data-counter', '0');
    rows += getInfoRow(row);

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

var draw_USB_variables_3 = function() {
    var html = getSectionTitle('USB MAIN ACTION');
    var rows = '';
    var row = '';
    row = getInfoCell('usb-main-action-0', 'IDLE');
    row += getInfoCell('usb-main-action-1', 'COPY_PLANTING');
    row += getInfoCell('usb-main-action-2', 'COPY_CONFIG_UP');
    rows += getInfoRow(row);
    row = getInfoCell('usb-main-action-3', 'COPY_CONFIG_DO');
    row += getInfoCell('usb-main-action-4', 'DIRECTORY');
    row += getInfoCell('usb-main-action-5', 'DIRECTORY_ENTE');
    rows += getInfoRow(row);
    row = getInfoCell('usb-main-action-6', 'DIRECTORY_BACK');
    row += getInfoCell('usb-main-action-7', 'DIRECTORY_CONT');
    row += getInfoCell('usb-main-action-8', 'COPY_LOG');
    rows += getInfoRow(row);
    row = getInfoCell('usb-main-action-9', 'FIRMWARE');
    row += getInfoCell('usb-main-action-10', 'RUN OUT SELECT');
    row += getInfoCell('usb-main-action-11', 'COMMAND SET');
    rows += getInfoRow(row);

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

var draw_USB_variables_4 = function() {
    var html = getSectionTitle('USB BASE ACTION');
    var rows = '';
    var row = '';
    row = getInfoCell('usb-base-action-0', 'IDLE');
    row += getInfoCell('usb-base-action-1', 'DIR');
    row += getInfoCell('usb-base-action-2', 'CD');
    row += getInfoCell('usb-base-action-3', 'WRITEFILE');
    rows += getInfoRow(row);
    row = getInfoCell('usb-base-action-4', 'READFILE');
    row += getInfoCell('usb-base-action-5', 'DELETEFILE');
    row += getInfoCell('usb-base-action-6', 'FILEEXISTS');
    row += getInfoCell('usb-base-action-7', 'CLAIMFLASH');
    rows += getInfoRow(row);
    row = getInfoCell('usb-base-action-8', 'RELEASE FLASH');
    rows += getInfoRow(row);

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

var draw_USB_variables_5 = function() {
    var html = getSectionTitle('USB COMMAND ACTION');
    var rows = '';
    var row = '';
    row = getInfoCell('usb-command-action-0', 'IDLE');
    row += getInfoCell('usb-command-action-1', 'OPW');
    row += getInfoCell('usb-command-action-2', 'WRF');
    row += getInfoCell('usb-command-action-3', 'CLF');
    rows += getInfoRow(row);
    row = getInfoCell('usb-command-action-4', 'RDF');
    row += getInfoCell('usb-command-action-5', 'END');
    rows += getInfoRow(row);

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

draw_USB_variables();

//Data
var draw_USB_data = function() {
    getFullPanel(3, 0, 6, 9, "tab-page-usb", "sec-usb-data", "DATA", "FEED", "VER 1.0");
    var panel = document.getElementById("sec-usb-data");
    panel.innerHTML += draw_USB_data_1();
}

var draw_USB_data_1 = function() {
    var html = '';
    var rows = '';

    var row = '';
    row += getInfoCellH('flags-usb-com-fail', 'DATA');
    row += getInfoCellH('flags-usb-bad-comm', 'Description');
    rows += getInfoRow(row);
    rows += getInfoRow('<td></td><td></td>');

    html += getTabelID(rows, 'USB-data-table');
    html = getPanel(html);
    return html;
}

var getTabelID = function(innerHTML, id) {
    var html = '<table class="ai-table ai-table-border">';
    html += '<thead></thead>';
    html += '<tbody id="' + id + '">';
    html += innerHTML;
    html += '</tbody>';
    html += '</table>';
    return html;
}

draw_USB_data();