Last active
January 3, 2021 21:53
-
-
Save nikvoronin/2762f37b967562a7d473f14f0a2ed99d to your computer and use it in GitHub Desktop.
Custom FB_FileLoad to compare with original one and performance measurement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROGRAM MAIN | |
VAR_INPUT | |
pReadBuf: PVOID; | |
sPathName: STRING; | |
END_VAR | |
VAR | |
START: BOOL; | |
READ_AT_ONCE: UDINT := 65536; | |
Open: FB_FileOpen; | |
Read: FB_FileRead; | |
Close: FB_FileClose; | |
state: INT; | |
pCurrent: PVOID; | |
timeCounter: UDINT; | |
END_VAR | |
IF state >= 100 AND state <= 300 THEN | |
timeCounter := timeCounter + 1; | |
END_IF | |
CASE state OF | |
0: | |
IF START THEN | |
START := FALSE; | |
timeCounter := 0; | |
pCurrent := pReadBuf; | |
state := 100; | |
END_IF | |
100: | |
Open( | |
sNetId:= '', | |
sPathName:= sPathName, | |
nMode:= FOPEN_MODEREAD OR FOPEN_MODEBINARY, | |
ePath:= PATH_GENERIC, | |
bExecute:= TRUE | |
); | |
IF NOT open.bBusy THEN | |
Open(bExecute:= FALSE); | |
state := 200; | |
END_IF | |
200: | |
Read( | |
sNetId:= '', | |
hFile:= Open.hFile, | |
pReadBuff:= pCurrent, | |
cbReadLen:= READ_AT_ONCE, | |
bExecute:= TRUE | |
); | |
IF NOT Read.bBusy THEN | |
Read(bExecute:= FALSE); | |
IF Read.cbRead > 0 THEN | |
pCurrent := pCurrent + Read.cbRead; | |
ELSE | |
state := 300; | |
END_IF | |
END_IF | |
300: | |
Close( | |
sNetId:= '', | |
hFile:= Open.hFile, | |
bExecute:= TRUE | |
); | |
IF NOT Close.bBusy THEN | |
Close(bExecute:= FALSE); | |
state := 0; | |
END_IF | |
END_CASE | |
END_PROGRAM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment