You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
305 lines
7.2 KiB
305 lines
7.2 KiB
FUNCTION_BLOCK camera // Block definition (there may be more than one block per file)
|
|
|
|
VAR_INPUT // Define input variables
|
|
price : REAL;
|
|
pixelDepth : REAL;
|
|
pixels : REAL;
|
|
maxISO : REAL;
|
|
weight : REAL;
|
|
autoFocus : REAL;
|
|
launchDate : REAL;
|
|
frameRate : REAL;
|
|
touchScreen : REAL;
|
|
video : REAL;
|
|
flash : REAL;
|
|
waterproof : REAL;
|
|
bluetooth : REAL;
|
|
gps : REAL;
|
|
isMetal : REAL;
|
|
END_VAR
|
|
|
|
VAR_OUTPUT // Define output variable
|
|
travel : REAL;
|
|
event : REAL;
|
|
sports : REAL;
|
|
scenery : REAL;
|
|
portrait : REAL;
|
|
astronomy : REAL;
|
|
newModel : REAL;
|
|
durableBuild : REAL;
|
|
lightBuild : REAL;
|
|
lowPrice : REAL;
|
|
END_VAR
|
|
|
|
FUZZIFY price
|
|
TERM low := (0, 1) (1000, 0) ;
|
|
TERM medium := (600, 0) (800,1) (1500,1) (1700,0);
|
|
TERM high := (1500, 0) (1700, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY pixelDepth
|
|
TERM low := (0, 1) (16, 0) ;
|
|
TERM medium := (10, 0) (12,1) (20,1) (26,0);
|
|
TERM high := (18, 0) (36, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY pixels
|
|
TERM low := (0, 1) (12000000, 0) ;
|
|
TERM medium := (8000000, 0) (15000000,1) (20000000,1) (26000000,0);
|
|
TERM high := (20000000, 0) (40000000, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY maxISO
|
|
TERM low := (0, 1) (6400, 0) ;
|
|
TERM medium := (3200, 0) (6400,1) (12800,1) (25600,0);
|
|
TERM high := (12800, 0) (51200, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY weight
|
|
TERM light := (0, 1) (500, 0) ;
|
|
TERM medium := (300, 0) (500,1) (700,1) (1000,0);
|
|
TERM heavy := (800, 0) (1000, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY autoFocus
|
|
TERM low := (0, 1) (15, 0) ;
|
|
TERM medium := (10, 0) (15,1) (25,1) (30,0);
|
|
TERM high := (25, 0) (50, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY launchDate
|
|
TERM antique := (1000000000000, 1) (1300000000000, 0) ;
|
|
TERM earlier := (1200000000000, 0) (1300000000000,1) (1350000000000,1) (1450000000000,0);
|
|
TERM recent := (1400000000000, 0) (1500000000000, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY frameRate
|
|
TERM low := (0, 1) (4, 0) ;
|
|
TERM medium := (3, 0) (8,1) (10,1) (12,0);
|
|
TERM high := (10, 0) (12, 1);
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY touchScreen
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY video
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY flash
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY waterproof
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY bluetooth
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY gps
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
FUZZIFY isMetal
|
|
TERM no := (0, 1) (1, 0) ;
|
|
TERM yes := (0, 0) (1, 1) ;
|
|
END_FUZZIFY
|
|
|
|
DEFUZZIFY travel
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY event
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY sports
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY scenery
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY portrait
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY astronomy
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY newModel
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY durableBuild
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY lightBuild
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
DEFUZZIFY lowPrice
|
|
TERM veryBad := (0,1) (0.2,0);
|
|
TERM bad := (0,0) (0.1,1) (0.5,0);
|
|
TERM average:= (0,0) (0.5,1) (1,0);
|
|
TERM good:= (0.5,0) (0.9,1) (1,0);
|
|
TERM veryGood:= (0.8,0) (1,1);
|
|
METHOD : COG;
|
|
DEFAULT := 0.5;
|
|
END_DEFUZZIFY
|
|
|
|
RULEBLOCK travel
|
|
AND : MIN;
|
|
RULE 1 : IF weight IS light THEN travel IS good;
|
|
RULE 2 : IF video IS yes THEN travel IS good;
|
|
RULE 3 : IF gps IS yes THEN travel IS good;
|
|
RULE 4 : IF flash IS no THEN travel IS bad;
|
|
RULE 5 : IF weight IS heavy THEN travel IS veryBad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK event
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF frameRate IS high THEN event IS good;
|
|
RULE 2 : IF gps IS yes THEN event IS good;
|
|
RULE 3 : IF bluetooth IS yes THEN event IS good;
|
|
RULE 4 : IF flash IS no THEN event IS bad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK sports
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF frameRate IS high THEN sports IS veryGood;
|
|
RULE 2 : IF autoFocus IS high THEN sports IS veryGood;
|
|
RULE 3 : IF pixels IS high THEN sports IS good;
|
|
RULE 4 : IF frameRate IS low THEN sports IS veryBad;
|
|
RULE 5 : IF autoFocus IS low THEN sports IS veryBad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK scenery
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF pixels IS high THEN scenery IS veryGood;
|
|
RULE 2 : IF pixelDepth IS high THEN scenery IS veryGood;
|
|
RULE 3 : IF maxISO IS high THEN scenery IS good;
|
|
RULE 4 : IF gps IS yes THEN scenery IS good;
|
|
RULE 5 : IF pixelDepth IS low THEN scenery IS bad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK portrait
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF pixels IS high THEN portrait IS good;
|
|
RULE 2 : IF pixelDepth IS high THEN portrait IS good;
|
|
RULE 3 : IF pixelDepth IS low THEN portrait IS bad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK astronomy
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF pixels IS high THEN astronomy IS good;
|
|
RULE 2 : IF pixelDepth IS high THEN astronomy IS good;
|
|
RULE 3 : IF maxISO IS high THEN astronomy IS good;
|
|
RULE 4 : IF maxISO IS low THEN astronomy IS veryBad;
|
|
RULE 5 : IF pixels IS low THEN astronomy IS veryBad;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK newModel
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF launchDate IS antique THEN newModel IS bad;
|
|
RULE 2 : IF launchDate IS earlier THEN newModel IS average;
|
|
RULE 3 : IF launchDate IS recent THEN newModel IS good;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK durableBuild
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF isMetal IS no THEN durableBuild IS bad;
|
|
RULE 2 : IF isMetal IS yes THEN durableBuild IS good;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK lightBuild
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF weight IS heavy THEN lightBuild IS bad;
|
|
RULE 1 : IF weight IS medium THEN lightBuild IS average;
|
|
RULE 2 : IF weight IS light THEN lightBuild IS good;
|
|
END_RULEBLOCK
|
|
|
|
RULEBLOCK lowPrice
|
|
AND : MIN;
|
|
|
|
RULE 1 : IF price IS high THEN lowPrice IS bad;
|
|
RULE 1 : IF price IS medium THEN lowPrice IS average;
|
|
RULE 2 : IF price IS low THEN lowPrice IS good;
|
|
END_RULEBLOCK
|
|
|
|
END_FUNCTION_BLOCK
|