[r42]: / branches / SBSI / Vision_Game_PLC / Plc Logic / Application / Function Blocks / MessageQueue / AddMessageToQueue / svnobj  Maximize  Restore  History

Download this file

32 lines (30 with data), 3.1 kB

 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
METHOD AddMessageToQueue : BOOL
VAR_INPUT
	Command : CommandType;
	Value : STRING;	
END_VAR
VAR
IF InQueue >= 16 THEN
	AddMessageToQueue := FALSE;
ELSE
	IF InIndex = 0 THEN
		OldIndex := 15;
	ELSE
		OldIndex := InIndex -1;
	END_IF	
	
		IF NOT ( Values[OldIndex] = Value ) OR DuplicationTimeoutTimer.Q THEN
			Values[InIndex] := Value;
			Commands[InIndex] := Command;
			IF InIndex >= 15 THEN
				InIndex := 0;		
			ELSE		
				InIndex := InIndex + 1;		
			END_IF
			InQueue := InQueue + 1;
			AddMessageToQueue := TRUE;
		ELSE
			AddMessageToQueue := FALSE;			
		END_IF
		AddMessageToQueue := FALSE;	
	END_IF
END_IF