Test case R0300
Full test suiteDevice test case
Function Block initialization
This test case it part of the test suite proposed for new devices.
Test case ID: R0300
Language: ST
tests2/t0300.st(* to check FB/Fucntions initializtion *) PROGRAM R0300 VAR Y1 : INT := 20; I : INT ; FB1X : FB1_R0300; END_VAR FOR I := 1 TO 3 DO FB1X(X :=3 , Y:=4); Y1 := F1_R0300(3, 5); END_FOR; Y1 := F1_R0300(5, 3); FB1X(X :=3 , Y:=4); _GEB_ASSERT_(FB1X.C = 504); _GEB_ASSERT_(FB1X.X=3); _GEB_ASSERT_(FB1X.Y=4); _GEB_ASSERT_(FB1X.Z=7); _GEB_ASSERT_(Y1 = 8); END_PROGRAM FUNCTION F1_R0300 : INT (* just a very simple function that sums two integers *) VAR_INPUT X: INT; Y: INT; END_VAR VAR C: CTU; Z :INT :=2; END_VAR F1_R0300 := X + Y + Z - 2; Z := 3000; // to check that it is correctly initilized END_FUNCTION (* Z = X + Y ; C: counts invocations, starting from 500 *) FUNCTION_BLOCK FB1_R0300 VAR_INPUT X: INT; Y: INT; END_VAR VAR_TEMP Z10 : INT := 10; // just to check TEMP initialization END_VAR VAR CONT500 : INT := 500; // increments in each call END_VAR VAR_OUTPUT Z : INT; // sum of inputs C : INT; // same as CONT500 END_VAR Z := X + Y + Z10 - 10; CONT500 := CONT500 + 1; C := CONT500; Z10 := 1000; // This should have no effect END_FUNCTION_BLOCK