Saving variable from a web server in a txt file (client side)

Saving variable from a web server in a txt file (client side)

pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
edited October 2012 in General
Hello!
I'm running a web server with a PIC32MX microprocessor running on FreeRTOS. I'm using java scripting to refresh variable from server.
Now i should save these variables on a text file client side.
Please, can you help me?
Thank you!
MM

Replies

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    How does TableTools suit your requirements: http://datatables.net/extras/tabletools/

    Allan
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    I should save table data as CSV, XLS or PDF files
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    TableTools allows you to do that, yes. It could be used to output a different format as well if you need, but those are the default built in ones.

    Allan
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    yes, but i can't understand how to do this.

    Thank you for the answers!
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    How you downloaded TableTools and set up sDom like that shown in the example: http://datatables.net/extras/tabletools/ ?
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    This is my page on web server:
    [code]
    ~inc:header.inc~



    Parametri ERMES


    Versione Stack: ~version~
    Data compilazione: ~builddate~


    ...Lavori in corso! In questa pagina verranno visualizzati i parametri del computer di bordo...



    Errore:
    La connessione con il computer di bordo ERMES è andata persa!


    CAN2 TX
    ?
    CAN1 RX
    ?
    LM70 Temp (SPI1 RX)
    ?
    LM70 Temp (SPI2 RX)
    ?
    TC1047A Temp
    ?
    Current tlm
    ?
    Flash Read
    ?
    Oscillator
    ?
    Whatch Dog
    ?
    Latch-Up
    ?






    <!--
    // Parses the xmlResponse from status.xml and updates the status box
    function aggiornaStato1(xmlData) {
    var mainstat1 = document.getElementById('display1').style.display;
    var loadstat1 = document.getElementById('loading1').style.display;

    // Check if a timeout occurred
    if(!xmlData)
    {
    mainstat1 = 'none';
    loadstat1 = 'inline';
    return;
    }

    // Make sure we're displaying the status display
    mainstat1 = 'inline';
    loadstat1 = 'none';
    // Aggiorna variabile can1rx
    document.getElementById('can1tx').innerHTML = getXMLValue(xmlData, 'can1tx');
    document.getElementById('can2rx').innerHTML = getXMLValue(xmlData, 'can2rx');
    document.getElementById('spi1rx').innerHTML = getXMLValue(xmlData, 'spi1rx');
    document.getElementById('spi2rx').innerHTML = getXMLValue(xmlData, 'spi2rx');
    document.getElementById('tc1047a').innerHTML = getXMLValue(xmlData, 'tc1047a');
    document.getElementById('Itlm').innerHTML = getXMLValue(xmlData, 'Itlm');
    document.getElementById('NVMread').innerHTML = getXMLValue(xmlData, 'NVMread');
    }

    setTimeout("newAJAXCommand('testpanel.xml', aggiornaStato1, true)",100);
    //-->



    <!--
    document.getElementById('hello').innerHTML = "~hellomsg~";
    //-->


    ~inc:footer.inc~
    [/code]
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Where exactly are you initialising the DataTable? I don't see it there.
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    Maybe i should insert this code?:
    [code]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">





    DataTables example

    @import "../../media/css/demo_page.css";
    @import "../../media/css/demo_table.css";




    $(document).ready(function() {
    var oTable = $('#example').dataTable( {
    "bProcessing": true,
    "sAjaxSource": "arrays.txt"
    } );
    } );





    DataTables AJAX source example


    Preamble
    Although DataTables is built from the principle of progressive enhancement, it is often useful to be able to

    construct a table from an AJAX source. This can be done in one of two ways - either using the aData initialisation parameter which

    takes an array of data, or using the sAjaxSource initialisation parameter which will have DataTables go to that source with an XHR call

    and load data from there. This example shows the latter method in action. DataTables expects an object with an array called "aaData" with the

    data source.

    Live example




    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade







    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade



    [/code]
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    Then i should replace the arrays.txt with my variables?
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    Hello!
    Starting from a swf_path.html, now I can retreive and manual save webserver variable.
    [code]
    ~inc:header.inc~

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">





    TableTools example

    @import "media/css/demo_page.css";
    @import "media/css/demo_table.css";
    @import "media/css/TableTools.css";






    $(document).ready( function () {
    $('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "oTableTools": {
    "sSwfPath": "media/swf/copy_csv_xls_pdf.swf"
    }
    } );
    } );





    TableTools example - setting SWF path


    Live example




    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade




    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade




    ?
    Internet Explorer 4.0
    Win 95+
    4
    X


    Trident
    Internet Explorer 5.0
    Win 95+
    5
    C


    Trident
    Internet Explorer 5.5
    Win 95+
    5.5
    A








    function aggiornaStato1(xmlData) {
    document.getElementById('adc10an0').innerHTML = getXMLValue(xmlData, 'adc10an0');
    }
    setTimeout("newAJAXCommand('testpanel.xml', aggiornaStato1, true)",100);
    //-->




    [/code]
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    First of all thanks to allan for the support.
    Now the question is...
    Is there anyway to automatic save on file the table?

    Thanks so much!
    MM
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    ops...
    When I save data or copy it I can't see the variable values:
    [quote]
    Valore Parametro Note
    ? ADC canale 0 ADC Vref
    ? ADC canale 1 sensore TC1047A
    ? ADC canale 3
    ? ADC canale 4
    ? ADC canale 5
    ? ADC canale 6
    ? ADC canale 7
    ? ADC canale 8
    ? ADC canale 9
    ? ADC canale 10
    ? ADC canale 11
    ? ADC canale 12
    ? ADC canale 13
    ? ADC canale 14
    ? ADC canale 15
    Valore Parametro Note
    [/quote]

    Any idea about???
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Where are you setting the content of the table? I see you've got some of my demo content, but I presume you are overwriting that somehow?
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    Hello!
    I'm using this ? to refresh the value passed from the server, but when I save the file I can't see the value displayed on screen, but only this "?".
  • pic32rtospic32rtos Posts: 12Questions: 0Answers: 0
    I refresh the variable content with this java script:
    [code]

    function aggiornaStato1(xmlData) {
    document.getElementById('adc10an0').innerHTML = getXMLValue(xmlData, 'adc10an0');
    }
    setTimeout("newAJAXCommand('testpanel.xml', aggiornaStato1, true)",100);
    //-->

    [/code]
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    This FAQ applies: http://datatables.net/faqs#append
This discussion has been closed.