This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Logging data from GUI Composer ScalarLineGraph widget

Other Parts Discussed in Thread: TM4C1294NCPDT

 I tried to follow the example for logging data from a graph in GUI Composer, but I am using a ScalarLineGraph widget. I understand that the data series is not in "series0", but rather in 'value0'.

So I made the following change:

require(["dojo/ready"], function(ready){
     ready(function(){
         dijit.byId('widget_graph').watch('value1', function( prop, newValue, oldValue) {
        	 logData( newValue, false);
         });
     });
});

However, this only writes one data point to the file. It is not updating every second like the example. Also, I need to write more than one series to the file at a time and am not clear on what changes are needed to do so. That is, how to "watch" more than one series and have all the new values written to the file at once.

Code Composer Studio 6.1.0.00104

Tiva TM4C1294NCPDT processor on custom board

XDS100v2 JTAG probe

  • The link does not seem to have embedded properly:
    processors.wiki.ti.com/.../Logging_Graph_Data
  • My original app.js must have had a typo in it. When I started over again, the change from 'series0' to 'value0' was all that was needed to read a single series.

    The TI.CSVFILE function will write multiple values if it is passed an array. My hack is to read all the series of interest into an array and pass that to logData whenever 'value0' property has changed, assuming all the other values have changed as well.

    /*
     * This file is provided for custom JavaScript logic that your HTML files might need.
     * GUI Composer includes this JavaScript file by default within HTML pages authored in GUI Composer.
     */
    require(["dojo/ready"], function(ready){
         ready(function(){
        	 /* create an empty array to receive all the data */
        	 var allData = [];
        	 /* watch any series for change, assume they have all updated */
    		 dijit.byId('widget_graph').watch('value0', function( prop, newValue, oldValue) {
    			 allData = getData();
    			 logData(allData, false);
    		 });
         });
    });
    
    var FI = undefined;
    var Logged = false;
    
    function isLogging() {
    	return dijit.byId('widget_log_enabled').get('checked');
    }
    
    function getFileName() {
    	return dijit.byId('widget_path').get('value');
    }
    
    function getOptions() {
    	return { 
    		clientLocation : 'auto'
    	}
    }
    
    function logData( data, reset) {
    	if( !reset && !isLogging())
    		return;
    	var file = getFileName();	
    	if( !file)
    		return;
    	var callback = function( fileInfo, errorInfo) {
    		if( errorInfo) {
    			$TI.helper.showError( "Error Logging.", errorInfo.message);
    		}
    	}
    	var options = getOptions();
    	if( !reset) {
    		options.append = true;
    		options.addCRAfter = true;
    	}
    	new TI.CSVFile().save( data, FI, options, callback);
    }
    
    function getData() {
    	var data = [];
    	
    	/* read the data from all the series and push it to the array */
    	data.push(dijit.byId( 'widget_graph').get('value0'));
    	data.push(dijit.byId( 'widget_graph').get('value1'));
    	data.push(dijit.byId( 'widget_graph').get('value2'));
    	data.push(dijit.byId( 'widget_graph').get('value3'));
    	data.push(dijit.byId( 'widget_graph').get('value4'));
    	data.push(dijit.byId( 'widget_graph').get('value5'));
    	
    	return data;
    }
    
    function setFileName( name) {
    	dijit.byId( 'widget_path').set('value',name);
    }
    
    function updateFileName() {
    	var name = '';
    	if( FI && FI.localPath) {
    		name = FI.localPath; 
    	}
    	setFileName(name);
    }
    
    function updateFields() {
    	updateFileName();
    }
    
    function onBrowse() {
    	var data = getData(); 
    	var callback = function( fileInfo, errorInfo) {
    		if( errorInfo) {
    			$TI.helper.showError( "Save as...", errorInfo.message);
    		} 
    		else {
    			FI = fileInfo;
    			updateFields();
    		}
    	};
    	var options = getOptions();
    	options.addCRAfter = true;
    	new TI.CSVFile().browseAndSave( data, FI, options, callback);
    }
    
    function onReset() {
    	logData( "", true);
    }
    

  • Thanks for the update and thanks for sharing!

    ki