File: Fibo_standalone.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (124 lines) | stat: -rw-r--r-- 3,400 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "/usr/local/lib/scilab/routines/machine.h"
/* Code prototype for standalone use  */
/*     Generated by Code_Generation toolbox of Scicos with scilab-2.6 */
/*     date : 27-Feb-2002 */

#include <stdio.h>
#include <string.h>

void Fibomain1(double *z, double *t, double * rpar, integer *nrpar,
  integer *ipar,integer *nipar);

void Fibomain2(double *z, double *t, double * rpar, integer *nrpar,
  integer *ipar,integer *nipar) ;

void Fibo_init(double *z, double *t, double * rpar, integer *nrpar,
  integer *ipar,integer *nipar) ;

void Fibo_end(double *z, double *t, double * rpar, integer *nrpar,
  integer *ipar,integer * nipar) ;

void Fibo_sim(double tf) ;

void Fibo_events(int *nevprt, double *t);

void set_nevprt(int nevprt);
static double RPAR1[1];
static integer NRPAR1  = 0;
static integer IPAR1[ ]= {1,1};
static integer NIPAR1  = 2;
/*Main program */
int main()
{
   double tf=20.0;
   Fibo_sim(tf);
   return 0;
}

/*----------------------------------------  External simulation function */ 
void 
Fibo_sim(tf)
 
     double tf; 
{
  double t;
  int nevprt=1;

  /*Initial values */
  double z[]={1,2,3,1,2,0.5,0.5,0,0,0,0,0,0,0};
  t=0.0;
  Fibo_init(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);
  while (t<=tf) {   
    Fibo_events(&nevprt,&t);
    set_nevprt(nevprt);
    Fibomain1(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);
    Fibomain2(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);
  }
  Fibo_end(z,&t,RPAR1,&NRPAR1,IPAR1,&NIPAR1);
  return ;
}
/*----------------------------------------  Lapack messag function */ 
void
C2F(xerbla)(SRNAME,INFO,L)
char *SRNAME;
int *INFO;
long int L;
{
printf("** On entry to %s, parameter number %d  had an illegal value\n",SRNAME,*INFO);
}
/*----------------------------------------  External events handling function */ 
void 
Fibo_events(int *nevprt,double *t)
{
/*  set next event time and associated events ports  
 *  nevprt has binary expression b1..b1 where bi is a bit 
 *  bi is set to 1 if an activation is received by port i. Note that
 *  more than one activation can be received simultaneously 
 *  Caution: at least one bi should be equal to one */

    int i,p,b[]={0};

    b[0]=1;
    *t = *t + 1; /* CUST: *t + 0.1 changed to *t + 1 */
    *nevprt=0;p=1;
    for (i=0;i<1;i++) {
      *nevprt=*nevprt+b[i]*p;
      p=p*2;}
}
/*---------------------------------------- Actuators */ 
void 
Fibo_actuator(flag,nport,nevprt,t,u,nu)
     /*
      * To be customized for standalone execution
      * flag  : specifies the action to be done
      * nport : specifies the  index of the Super Bloc 
      *         regular input (The input ports are numbered 
      *         from the top to the bottom ) 
      * nevprt: indicates if an activation had been received
      *         0 = no activation
      *         1 = activation
      * t     : the current time value
      * u     : the vector inputs value
      * nu    : the input  vector size
      */
     integer *flag,*nevprt,*nport;
     integer *nu;

     double  *t, u[];
{
  int k;
  /* skeleton to be customized */
  switch (*flag) {
  case 2 : 
    if(*nevprt>0) {/* get the input value */
      printf("n=%4.0f | u = %9.5f |\n",*t,u[0]);/* CUST: added */
    } 
    break;
  case 4 : /* actuator initialisation */
    /* do whatever you want to initialize the actuator */
    break;
  case 5 : /* actuator ending */
    /* do whatever you want to end the actuator */
    break;
  }
}