//Code automatically generated with fuzzylite 6.0.

FUNCTION_BLOCK SimpleDimmerInverse

VAR_INPUT
  Ambient: REAL;
END_VAR

VAR_OUTPUT
  Power: REAL;
  InversePower: REAL;
END_VAR

FUZZIFY Ambient
  RANGE := (0.000 .. 1.000);
  TERM DARK := Triangle 0.000 0.250 0.500;
  TERM MEDIUM := Triangle 0.250 0.500 0.750;
  TERM BRIGHT := Triangle 0.500 0.750 1.000;
END_FUZZIFY

DEFUZZIFY Power
  RANGE := (0.000 .. 1.000);
  TERM LOW := Triangle 0.000 0.250 0.500;
  TERM MEDIUM := Triangle 0.250 0.500 0.750;
  TERM HIGH := Triangle 0.500 0.750 1.000;
  METHOD : COG;
  ACCU : MAX;
  DEFAULT := nan;
END_DEFUZZIFY

DEFUZZIFY InversePower
  RANGE := (0.000 .. 1.000);
  TERM LOW := Cosine 0.200 0.500;
  TERM MEDIUM := Cosine 0.500 0.500;
  TERM HIGH := Cosine 0.800 0.500;
  METHOD : COG;
  ACCU : MAX;
  DEFAULT := nan;
END_DEFUZZIFY

RULEBLOCK 
  ACT : MIN;
  RULE 1 : if Ambient is DARK then Power is HIGH
  RULE 2 : if Ambient is MEDIUM then Power is MEDIUM
  RULE 3 : if Ambient is BRIGHT then Power is LOW
  RULE 4 : if Power is LOW then InversePower is HIGH
  RULE 5 : if Power is MEDIUM then InversePower is MEDIUM
  RULE 6 : if Power is HIGH then InversePower is LOW
END_RULEBLOCK

END_FUNCTION_BLOCK
