diff options
Diffstat (limited to 'test/monniaux/lustre-carlightV2/carlightV2_carlight_loop.c')
-rw-r--r-- | test/monniaux/lustre-carlightV2/carlightV2_carlight_loop.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/test/monniaux/lustre-carlightV2/carlightV2_carlight_loop.c b/test/monniaux/lustre-carlightV2/carlightV2_carlight_loop.c new file mode 100644 index 00000000..5040a5c6 --- /dev/null +++ b/test/monniaux/lustre-carlightV2/carlightV2_carlight_loop.c @@ -0,0 +1,133 @@ +/* This file was generated by lv6 version master.737 (2727a7744111c84f7984634d2bd3ad6f7c6c7ff9). */ +/* lv6 carlightV2.lus -n carlight --to-c */ +/* on vanoise the 08/05/2019 at 22:54:09 */ + +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include "carlightV2_carlight.h" +/* Print a promt ? ************************/ +static int ISATTY; +/* MACROS DEFINITIONS ****************/ +#ifndef TT +#define TT "1" +#endif +#ifndef FF +#define FF "0" +#endif +#ifndef BB +#define BB "bottom" +#endif +#ifdef CKCHECK +/* set this macro for testing output clocks */ +#endif + +/* Standard Input procedures **************/ +_boolean _get_bool(char* n){ + char b[512]; + _boolean r = 0; + int s = 1; + char c; + do { + if(ISATTY) { + if((s != 1)||(r == -1)) printf("\a"); + // printf("%s (1,t,T/0,f,F) ? ", n); + } + if(scanf("%s", b)==EOF) exit(0); + if (*b == 'q') exit(0); + s = sscanf(b, "%c", &c); + r = -1; + if((c == '0') || (c == 'f') || (c == 'F')) r = 0; + if((c == '1') || (c == 't') || (c == 'T')) r = 1; + } while((s != 1) || (r == -1)); + return r; +} +_integer _get_int(char* n){ + char b[512]; + _integer r; + int s = 1; + do { + if(ISATTY) { + if(s != 1) printf("\a"); + //printf("%s (integer) ? ", n); + } + if(scanf("%s", b)==EOF) exit(0); + if (*b == 'q') exit(0); + s = sscanf(b, "%d", &r); + } while(s != 1); + return r; +} +#define REALFORMAT ((sizeof(_real)==8)?"%lf":"%f") +_real _get_real(char* n){ + char b[512]; + _real r; + int s = 1; + do { + if(ISATTY) { + if(s != 1) printf("\a"); + //printf("%s (real) ? ", n); + } + if(scanf("%s", b)==EOF) exit(0); + if (*b == 'q') exit(0); + s = sscanf(b, REALFORMAT, &r); + } while(s != 1); + return r; +} +/* Standard Output procedures **************/ +void _put_bottom(char* n){ + if(ISATTY) printf("%s = ", n); + printf("%s ", BB); + if(ISATTY) printf("\n"); +} +void _put_bool(char* n, _boolean _V){ + if(ISATTY) printf("%s = ", n); + printf("%s ", (_V)? TT : FF); + if(ISATTY) printf("\n"); +} +void _put_int(char* n, _integer _V){ + if(ISATTY) printf("%s = ", n); + printf("%d ", _V); + if(ISATTY) printf("\n"); +} +void _put_real(char* n, _real _V){ + if(ISATTY) printf("%s = ", n); + printf("%f ", _V); + if(ISATTY) printf("\n"); +} +/* Output procedures **********************/ +#ifdef CKCHECK +void %s_BOT_n(void* cdata){ + _put_bottom("n"); +} +#endif +/* Output procedures **********************/ +void carlightV2_carlight_O_n(void* cdata, _integer _V) { + _put_int("n", _V); +} +/* Main procedure *************************/ +int main(){ + int _s = 0; + _integer switch_pos; + _real intensity; + _boolean is_on; + carlightV2_carlight_ctx_type* ctx = carlightV2_carlight_ctx_new_ctx(NULL); + + printf("#inputs \"switch_pos\":int \"intensity\":real\n"); + printf("#outputs \"is_on\":bool\n"); + + /* Main loop */ + ISATTY = isatty(0); + while(1){ + if (ISATTY) printf("#step %d \n", _s+1); + else if(_s) printf("\n"); + fflush(stdout); + ++_s; + switch_pos = _get_int("switch_pos"); + intensity = _get_real("intensity"); + carlightV2_carlight_step(switch_pos,intensity,&is_on,ctx); + // printf("%d %f #outs %d\n",switch_pos,intensity,is_on); + printf("%d\n",is_on); + } + return 1; + +} |