How to used get_scicos_time() functions in new module (external module)

hehiha dungnguyenbk at gmail.com
Tue Jun 12 05:41:52 CEST 2012


I try to implement a block (ex4) depend on time in external module.
In my file /src/c/xcpl_EX4.c
I used get_scicos_time() functions to get time when simulator.
So this function is not get time of simulator.
My file src/c/xcpl_EX4.c

#include "scicos_block4.h"
#include <stdio.h>
#include <ctype.h>

#define Y			((SCSREAL_COP *)GetRealOutPortPtrs(blk, 1))
// parameters
#define P1			(GetRparPtrs(blk)[0])
#define P2			(GetRparPtrs(blk)[1])
#define P3			(GetRparPtrs(blk)[2])
#define pi			3.14 

void xcpl_EX4(scicos_block *blk, int flag)
{
	double t;	
	double ptr;
	t = get_scicos_time();
	
	switch (flag)
	{
		case Initialization:
			Y[0] = P1*P2*P3;
			break;		
		case StateUpdate:
			Y[0] = 1;			
			break;	
		case Ending:
			scicos_free(GetWorkPtrs(blk));
			break;
        
		case OutputUpdate:
		t=get_scicos_time();
			if( t > 100){
			Y[0]= 3;
			}else{
				if(Y[0] == P1*P2*P3 ){
					Y[0] = P1*P2*P3;			
				}else if(Y[0] > 10)
				{
					Y[0] = P1*P2*P3;
				}else {
					Y[0]= Y[0]+0.01;
				}
			}
			  ptr = Y[0]; 	  

            break;

		default:
				break;
	}
	

}

What's wrong ?


--
View this message in context: http://mailinglists.scilab.org/How-to-used-get-scicos-time-functions-in-new-module-external-module-tp4024348.html
Sent from the Scilab developers - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the dev mailing list