summaryrefslogtreecommitdiff
path: root/tests/source/DiffSystem.scade
blob: b1f3fb4af675f2ecea90d9ac00434655949b2c9b (plain) (blame)
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
node Body(Torq, Brake : real) returns (probe VehicleSpeed : real)
var pre_VS, Cmd : real;
let
  --assume h1: Brake = 0.;
  --assume h2: Torq >= 0. and Torq <= 1.;

  pre_VS = 0.0 -> pre VehicleSpeed;

  Cmd =
    (if Torq <= 1.0 then 150.0 else 0.0)
      + Brake * 200.0
      + pre_VS * pre_VS * 0.3
      + pre_VS * 2.5;

  VehicleSpeed =
    (Torq - (if pre_VS < - 0.1 then - Cmd else if pre_VS > 0.1 then Cmd else 0.0))
        * 0.1 * 2.5 / 1450.0
      + pre_VS;
tel

node test(i: int) returns(a, b, c: int; exit: bool)
var torq, brake, vs: real;
let
  torq = 1000.; --if i mod 311 > 240 then 2.0 else if i mod 211 > 170 then 0.9 else 0.5;
  brake = 0.; --if i mod 400 > 300 then 1.4 else 0.;
  vs = Body(torq, brake);

  a = int(torq);
  b = int(brake);
  c = int(vs * 10.);
  exit = (i > 2000);
tel