diff options
author | Shashank Bhalotia | 2017-07-12 13:59:52 +0000 |
---|---|---|
committer | GitHub | 2017-07-12 13:59:52 +0000 |
commit | 9caf9dc75adeef66323b2faf67975dc296531090 (patch) | |
tree | 8366068b345146e392ad4ef6e16fc910412d6e5d | |
parent | 2e51d5cc7d2f0b15d9e221e0463e546b50a08da8 (diff) | |
download | scilab_for_xcos_on_cloud-9caf9dc75adeef66323b2faf67975dc296531090.tar.gz scilab_for_xcos_on_cloud-9caf9dc75adeef66323b2faf67975dc296531090.tar.bz2 scilab_for_xcos_on_cloud-9caf9dc75adeef66323b2faf67975dc296531090.zip |
Update cmscope.c
-rwxr-xr-x | modules/scicos_blocks/src/c/cmscope.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/modules/scicos_blocks/src/c/cmscope.c b/modules/scicos_blocks/src/c/cmscope.c index cac4cb338..32926d4c9 100755 --- a/modules/scicos_blocks/src/c/cmscope.c +++ b/modules/scicos_blocks/src/c/cmscope.c @@ -216,16 +216,20 @@ SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag) int i, j; BOOL result; - FILE* filePointer; + // Define file pointer to write data to a log file which can used for output generation to the client + FILE* filePointer; int processId; char fileName[25]; char line[100]; filePointer = NULL; processId = 0; + // Get the process id to give a unique name to the requested simulation processId = getpid(); // On Linux sprintf(fileName, "scilab-log-%d.txt", processId); + // Open file in append mode filePointer = fopen(fileName, "a"); + // Give block id to distinguish blocks int block_id=2; switch (flag) @@ -246,7 +250,7 @@ SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag) break; } - + // Write data to define Initialization phase fprintf(filePointer, "%d || Initialization %d\n", processId, iFigureUID); break; @@ -268,25 +272,34 @@ SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag) appendData(block, i, t, u); for (j = 0; j < block->insz[i]; j++) { - int iFigureUID = getFigure(block); - int iAxeUID = getAxe(iFigureUID, block, i); - int iPolylineUID = getPolyline(iAxeUID, block, i,j, FALSE); - double time = t; - double y = u[j]; - double z = 0; - char *labl = GetLabelPtrs(block); - if (strlen(labl) == 0) - labl = "CMSCOPE"; - - int nin = block->nin; - int input = i; - double period = block->rpar[block->nrpar - 3 * nin + input]; - double ymin = block->rpar[block->nrpar - 2 * nin + 2 * input]; - double ymax = block->rpar[block->nrpar - 2 * nin + 2 * input + 1]; - - fprintf(filePointer, "%d %d || %d | %d | %d || %f %f %f %d %f %f %f %s\n", block_id, processId, iFigureUID, iAxeUID, iPolylineUID, time, y, z,nin,ymin,ymax,period,labl); - + // Store parameters required to generate output on the web + int iFigureUID = getFigure(block); + int iAxeUID = getAxe(iFigureUID, block, i); + int iPolylineUID = getPolyline(iAxeUID, block, i,j, FALSE); + double time = t; + double y = u[j]; + double z = 0; + char *labl = GetLabelPtrs(block); + if (strlen(labl) == 0) + labl = "CMSCOPE"; + + // Store number of output graphs + int nin = block->nin; + int input = i; + // Calculate period, ymin, ymax of each graph + double period = block->rpar[block->nrpar - 3 * nin + input]; + double ymin = block->rpar[block->nrpar - 2 * nin + 2 * input]; + double ymax = block->rpar[block->nrpar - 2 * nin + 2 * input + 1]; + + // Store scilab's plotted data in the log file + fprintf(filePointer, "%d %d || %d | %d | %d || %f %f %f %d %f %f %f %s\n", block_id, processId, iFigureUID, iAxeUID, iPolylineUID, time, y, z, nin, ymin, ymax, period, labl); + /* + block_id - block_id of this block, process_id - process id of currently running scilab's instance, iFigureUID - figure id of graph generated, + iAxeUID - axes id of graph, iPolylineUID - id for each separate output line of graph, time - current time interval(x-axis), + y - value of y-axis, z - value of z-axis, nin - representing number of output graphs, ymin - yMin value, ymax - yMax value, + period - refresh period, labl - Label for graph(default - "CMSCOPE") + */ result = pushData(block, i, j); if (result == FALSE) @@ -308,6 +321,7 @@ SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag) pushHistory(block, i, sco->internal.maxNumberOfPoints[i]); } deleteBufferPolylines(block); + // Write data to define Ending phase fprintf(filePointer, "%d || Ending %d\n", processId, getFigure(block)); freeScoData(block); @@ -316,7 +330,8 @@ SCICOS_BLOCKS_IMPEXP void cmscope(scicos_block * block, scicos_flag flag) default: break; } - fclose(filePointer); + // Close the file pointer + fclose(filePointer); } /*-------------------------------------------------------------------------*/ |