Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec-tests / tests / linear_ctl / ex1.c @ 79ef5fc5

History | View | Annotate | Download (1.25 KB)

1 604d5b37 ploc
#include <stdio.h>
2
#include <unistd.h>
3
#include "/usr/local/include/lustrec/io_frontend.h"
4
#include <stdlib.h>
5
#include <assert.h>
6
#include "ex1.h"
7
8
/* C code generated by lustrec
9
   SVN version number 255
10
   Code is C99 compliant */
11
   
12
/* Imported nodes declarations */
13
14
/* Global constants (definitions) */
15
16
void top_reset (struct top_mem *self) {
17
  _arrow_reset(self->ni_0);
18
  return;
19
}
20
21
void top_step (double in0, 
22
               double (*x), double (*y),
23
               struct top_mem *self) {
24
  _Bool __top_1;
25
  
26
  _arrow_step (1, 0, &__top_1, self->ni_0);
27
  if (__top_1) {
28
    *y = 0.;
29
    *x = 0.;
30
  } else {
31
    *y = self->_reg.__top_3;
32
    *x = (((1.5 * self->_reg.__top_3) - (0.7 * self->_reg.__top_2)) + (1.6 * in0));
33
  }
34
  self->_reg.__top_3 = *x;
35
  self->_reg.__top_2 = *y;
36
  return;
37
}
38
39
int main (int argc, char *argv[]) {
40
  /* Declaration of inputs/outputs variables */
41
  double in0 = 0.;
42
  double x = 0.;
43
  double y = 0.;
44
  
45
  /* Main memory allocation */
46
  top_ALLOC(static,main_mem);
47
  
48
  /* Initialize the main memory */
49
  top_reset(&main_mem);
50
  
51
  ISATTY = isatty(0);
52
  
53
  /* Infinite loop */
54
  while(1){
55
    fflush(stdout);
56
    in0 = _get_double("in0");
57
    top_step(in0, &x, &y, &main_mem);
58
    _put_double("x", x);
59
    _put_double("y", y);
60
  }
61
  return 1;
62
}