Blame view

SanlienDataRecoder_01/Untitled1/POUs/ToolBox/FB_DataFifo.TcPOU 2.49 KB
03a3ca636   frank   初版
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <?xml version="1.0" encoding="utf-8"?>
  <TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.11">
    <POU Name="FB_DataFifo" Id="{d56a36d5-a9e2-464d-82c2-924a10cada6f}" SpecialFunc="None">
      <Declaration><![CDATA[FUNCTION_BLOCK FB_DataFifo
  VAR_INPUT
  	bPutData	:	BOOL;
  	bGetData	:	BOOL;
  	bClearFifo	:	BOOL;
  	pPutData	:	pvoid;
  	pGetData	:	pvoid;
  	nDataLen	:	UDINT;
  	pFifoMemory	:	pvoid;
  	nFifoSize	:	DINT;
  
  END_VAR
  VAR_OUTPUT
  	bFifoEmpty	:	BOOL;
  	bFifoFull	:	BOOL;
  	iFifoSizeLeft	: DINT;
  END_VAR
  VAR
  	fbGetTaskId	: GETCURTASKINDEX;
  	nTaskId		: BYTE;
  	
  	iPutIndex	:	DINT;
  	iGetIndex	:	DINT;
  
  	pPutIndex	:	DINT;
  	pGetIndex	:	DINT;
  	bIs1Sec : BOOL;
  
  END_VAR]]></Declaration>
      <Implementation>
        <ST><![CDATA[
  IF bClearFifo THEN
  	iPutIndex := 0; iGetIndex := 0;
  	iFifoSizeLeft := nFifoSize;
  	bFifoEmpty := TRUE;
  	RETURN;
  END_IF
  
  IF NOT(bFifoFull) THEN
  	IF bPutData THEN
  		IF iPutIndex >= nFifoSize THEN
  			iPutIndex := 0;
  		END_IF
  		pPutIndex := iPutIndex * nDataLen;
  		MEMCPY(pFifoMemory + pPutIndex, pPutData, nDataLen);
  		iPutIndex := iPutIndex + 1;
  		iFifoSizeLeft := iFifoSizeLeft - 1;
  	END_IF
  END_IF;
  
  IF NOT(bFifoEmpty) THEN
  	IF bGetData THEN
  		bIs1Sec := iGetIndex >= nFifoSize;
  		
  		IF bIs1Sec THEN
  			iGetIndex := 0;
  		END_IF
  		pGetIndex := iGetIndex * nDataLen;
  		MEMCPY(pGetData, pFifoMemory + pGetIndex , nDataLen);
  		iGetIndex := iGetIndex + 1;
  		iFifoSizeLeft := iFifoSizeLeft + 1;
  	END_IF
  END_IF;
  
  
  (*
   _TaskInfo[GETCURTASKINDEX()].FirstCycle;
  SystemTaskInfoArr[SystemInfo.RuntimeNo].firstCycle
  *)
  
  
  fbGetTaskId();	
  IF _TaskInfo[fbGetTaskId.index].FirstCycle THEN
  	iFifoSizeLeft  := nFifoSize;
  END_IF
4860ceec1   Johnny Yang   no file saving
79
80
81
82
83
  //IF iFifoSizeLeft = 0 THEN
  //	bFifoFull := TRUE;
  //ELSE
  //	bFifoFull := FALSE;
  //END_IF
03a3ca636   frank   初版
84

4860ceec1   Johnny Yang   no file saving
85
86
87
88
89
  //IF iFifoSizeLeft >= nFifoSize THEN
  //	bFifoEmpty := TRUE;
  //ELSE
  //	bFifoEmpty := FALSE;
  //END_IF
03a3ca636   frank   初版
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  ]]></ST>
      </Implementation>
      <LineIds Name="FB_DataFifo">
        <LineId Id="117" Count="1" />
        <LineId Id="122" Count="1" />
        <LineId Id="126" Count="0" />
        <LineId Id="124" Count="0" />
        <LineId Id="121" Count="0" />
        <LineId Id="36" Count="14" />
        <LineId Id="155" Count="1" />
        <LineId Id="51" Count="8" />
        <LineId Id="77" Count="0" />
        <LineId Id="84" Count="1" />
        <LineId Id="60" Count="0" />
        <LineId Id="81" Count="0" />
        <LineId Id="79" Count="0" />
        <LineId Id="87" Count="1" />
4860ceec1   Johnny Yang   no file saving
107
108
109
        <LineId Id="61" Count="4" />
        <LineId Id="185" Count="9" />
        <LineId Id="76" Count="0" />
03a3ca636   frank   初版
110
111
112
113
        <LineId Id="9" Count="0" />
      </LineIds>
    </POU>
  </TcPlcObject>