[r76]: / branches / timvh / example / CODESYS_Control / Plc Logic / AppLowMemory / FB_ParseRecipes / svnobj  Maximize  Restore  History

Download this file

49 lines (47 with data), 7.6 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
FUNCTION_BLOCK FB_ParseRecipes
VAR_INPUT
    xParse : BOOL;
END_VAR
VAR_OUTPUT
    xParsingDone : BOOL;
    xParsingBusy : BOOL;
    xParsingError : BOOL;
VAR_IN_OUT
    astDataSet : ARRAY[0..999] OF ST_RECIPE_LIST;
VAR
	_Xml : FB_XmlControl;
	szFilename : STRING := './AppLowMemory/recipes.xml';
	// select your buffertype
CASE _iParseStep OF
    0: // read file and write into buffer
        IF xParse THEN
            xParsingBusy := TRUE;
            (* open file from start and read into buffer *)
            (* buffer is already set in FB_Init *)
    10: (* the buffer is now filled in memory and the original file has been closed.
            So we can iterate it 
        *)
        REPEAT
		    _sTag := _Xml.NextTag();
                // start of recipe found. remember name and position in file, then continue in the next cycle, not to stop the 
                astDataSet[_index].udiFilePos := _Xml.GetFilePos();
                _index := _index + 1;
                _xFoundRecipe := TRUE;
            ELSIF _sTag = '/recipes' THEN
                // Done
                _iParseStep := 100;
                EXIT;
			END_IF
            IF _Xml.SearchPos >= _Xml.Length THEN
                ReadNext();
        UNTIL _xFoundRecipe  END_REPEAT
        
    99: // error occured
        xParsingBusy := FALSE;
        xParsingError := TRUE;
        IF NOT xParse THEN
            xParsingError := FALSE;
            _iParseStep := 0;
    100: // done
        xParsingDone := TRUE;
            xParsingDone := FALSE;
END_CASE