LSR/worker.fcl

69 lines
1.6 KiB
Plaintext
Raw Normal View History

2020-06-04 19:21:01 +02:00
FUNCTION_BLOCK worker
VAR_INPUT
form1: REAL;
form2: REAL;
points: REAL;
END_VAR
VAR_OUTPUT
result: REAL;
END_VAR
FUZZIFY form1
2020-06-04 21:29:51 +02:00
RANGE := (-1.000 .. 5.000);
TERM bad := (1,1)(2,0);
2020-06-04 19:21:01 +02:00
TERM avg := (1,0)(2,1)(3,1)(4,0);
2020-06-04 21:29:51 +02:00
TERM great := (4,0)(5,1);
2020-06-04 19:21:01 +02:00
END_FUZZIFY
FUZZIFY form2
2020-06-04 21:29:51 +02:00
RANGE := (-1.000 .. 5.000);
TERM bad := (1,1)(2,0);
2020-06-04 19:21:01 +02:00
TERM avg := (1,0)(2,1)(3,1)(4,0);
2020-06-04 21:29:51 +02:00
TERM great := (4,0)(5,1);
2020-06-04 19:21:01 +02:00
END_FUZZIFY
FUZZIFY points
RANGE := (-30.000 .. 30.000);
TERM low := (-20,1)(-5,0);
TERM avg := (-10,0)(-3,1)(3,1)(10,0);
TERM high := (10,0)(20,1);
END_FUZZIFY
DEFUZZIFY result
RANGE := (-1.000 .. 1.000);
TERM home := (-1,1) (0,0);
2020-06-09 17:11:27 +02:00
TERM draw := (-0.5,0) (0,1) (0.5,0);
2020-06-04 19:21:01 +02:00
TERM away := (0,0) (1,1);
METHOD : COG;
// ACCU : MAX;
DEFAULT := 0
END_DEFUZZIFY
RULEBLOCK
AND : MIN;
ACCU : MAX;
ACT : MIN;
2020-06-09 19:57:26 +02:00
RULE 0: if form1 is avg and form2 is avg then result is draw
2020-06-04 19:21:01 +02:00
RULE 1 : if form1 is great and form2 is bad then result is home
2020-06-04 21:29:51 +02:00
RULE 2 : if form1 is great and form2 is avg then result is home
RULE 3 : if form1 is great and form2 is great then result is draw
RULE 4 : if form1 is avg and form2 is bad then result is home
RULE 5 : if form1 is avg and form2 is avg then result is draw
RULE 6 : if form1 is avg and form2 is great then result is away
RULE 7 : if form1 is bad and form2 is bad then result is draw
RULE 8 : if form1 is bad and form2 is avg then result is away
RULE 9 : if form1 is bad and form2 is great then result is away
2020-06-09 19:57:26 +02:00
//RULE 10: if points is high then result is away
//RULE 11: if points is high then result is draw
//RULE 10: if form1 is great and form2 is bad and points is low then result is home
2020-06-04 19:21:01 +02:00
END_RULEBLOCK
END_FUNCTION_BLOCK