diff options
author | Shashank Bhalotia | 2017-07-12 14:00:41 +0000 |
---|---|---|
committer | GitHub | 2017-07-12 14:00:41 +0000 |
commit | e4ef91e9cf7216af331235e36f35675aeebc9ad0 (patch) | |
tree | 37c18dec4bcec0253e683bff6090dfbf97532868 /modules | |
parent | 9caf9dc75adeef66323b2faf67975dc296531090 (diff) | |
download | scilab_for_xcos_on_cloud-e4ef91e9cf7216af331235e36f35675aeebc9ad0.tar.gz scilab_for_xcos_on_cloud-e4ef91e9cf7216af331235e36f35675aeebc9ad0.tar.bz2 scilab_for_xcos_on_cloud-e4ef91e9cf7216af331235e36f35675aeebc9ad0.zip |
Update cscopxy.c
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/scicos_blocks/src/c/cscopxy.c | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/modules/scicos_blocks/src/c/cscopxy.c b/modules/scicos_blocks/src/c/cscopxy.c index 79e8bd119..18e323377 100755 --- a/modules/scicos_blocks/src/c/cscopxy.c +++ b/modules/scicos_blocks/src/c/cscopxy.c @@ -149,63 +149,72 @@ SCICOS_BLOCKS_IMPEXP void cscopxy(scicos_block * block, scicos_flag flag) sco_data *sco; BOOL result; - + // 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=4; - switch (flag) { case Initialization: - sco = getScoData(block); - if (sco == NULL) - { - set_block_error(-5); - } - iFigureUID = getFigure(block); - if (iFigureUID == 0) - { - // allocation error - set_block_error(-5); - } - - - fprintf(filePointer, "%d || Initialization %d\n", processId, iFigureUID); + sco = getScoData(block); + if (sco == NULL) + { + set_block_error(-5); + } + iFigureUID = getFigure(block); + if (iFigureUID == 0) + { + // allocation error + set_block_error(-5); + } - break; + // Write data to define Initialization phase + fprintf(filePointer, "%d || Initialization %d\n", processId, iFigureUID); - case StateUpdate: - iFigureUID = getFigure(block); - if (iFigureUID == 0) - { - // allocation error - set_block_error(-5); break; - } - double *x = GetRealInPortPtrs(block, 1); - double *y = GetRealInPortPtrs(block, 2); - appendData(block,x, y); - for (j = 0; j < block->insz[0]; j++) - { - - int iFigureUID = getFigure(block); - int iAxeUID = getAxe(iFigureUID, block); - int iPolylineUID = getPolyline(iAxeUID, block, j); - double z = 0; + case StateUpdate: + iFigureUID = getFigure(block); + if (iFigureUID == 0) + { + // allocation error + set_block_error(-5); + break; + } - fprintf(filePointer, "%d %d || %d | %d | %d || %f %f %f %d %f %f %f %f %s\n", block_id,processId, iFigureUID, iAxeUID, iPolylineUID, x[j], y[j], z,1,block->rpar[0],block->rpar[1],block->rpar[2],block->rpar[3],"CSCOPXY"); + double *x = GetRealInPortPtrs(block, 1); + double *y = GetRealInPortPtrs(block, 2); + appendData(block,x, y); + for (j = 0; j < block->insz[0]; j++) + { + + // Store parameters required to generate output on the web + int iFigureUID = getFigure(block); + int iAxeUID = getAxe(iFigureUID, block); + int iPolylineUID = getPolyline(iAxeUID, block, j); + double z = 0; + + // Store scilab's plotted data in the log file + fprintf(filePointer, "%d %d || %d | %d | %d || %f %f %f %d %f %f %f %f %s\n", block_id, processId, iFigureUID, iAxeUID, iPolylineUID, x[j], y[j], z, 1, block->rpar[0], block->rpar[1], block->rpar[2], block->rpar[3], "CSCOPXY"); + /* + 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, x[j]- value of x-axis for j, + y[j] - value of y-axis for j, z - value of z-axis(0 for 2d-graph), 1 - representing 1 output graph, block->rpar[0] - xMin value, + block->rpar[1] - xMax value, block->rpar[2] - yMin value, block->rpar[3] - yMax value + */ result = pushData(block, j); if (result == FALSE) @@ -217,6 +226,7 @@ SCICOS_BLOCKS_IMPEXP void cscopxy(scicos_block * block, scicos_flag flag) break; case Ending: + // Write data to define Ending phase fprintf(filePointer, "%d || Ending %d\n", processId, getFigure(block)); freeScoData(block); @@ -224,9 +234,10 @@ SCICOS_BLOCKS_IMPEXP void cscopxy(scicos_block * block, scicos_flag flag) default: break; - } - fclose(filePointer); } + // Close the file pointer + fclose(filePointer); +} /*-------------------------------------------------------------------------*/ |