Вы находитесь на странице: 1из 4

SIMATIC

DaNang_PLC06_10072012\SIMATIC
300(1)\CPU 319-3 PN/DP\...\FC124 - <offline>

01/28/2015 11:14:16 AM

FC124 - <offline>
"FC_Search_TrackData"
Name: srchtrck
Author: HvdWe

GEN:
Family: General
Version: 0.0
Block version: 2
11/10/2012 02:15:32 AM
Time stamp Code:
11/10/2012 02:15:32 AM
Interface:
Lengths (block/logic/data): 00410 00264 00006

Name

Data Type

IN

Address

Comment

0.0
i_DB_Track

Int

0.0

Tracking DataBlock

i_Position

Int

2.0

SETT: [cm] Position in tracking

i_Open_Window_Offset

Int

4.0

SETT: [cm] Offset before position pec to open update window

i_Close_Window_Offset

Int

6.0

SETT: [cm] Offset after position pec to close update window

i_Data

Int

8.0

Data to search for in tracking

OUT

0.0

o_Position

Int

10.0

[cm] Tracking position where data is found

o_Entry

Int

12.0

Record-number in sorted tracking-list

o_Data_Found

Bool

14.0

Data found in tracking

IN_OUT

0.0

TEMP

0.0

t_Track_DB_Nr

Int

0.0

Copy of i_Track_DB_Nr

t_Search_Start_Position

Int

2.0

t_Search_Start_Position = i_Position + i_Close_Window_Offset

t_Search_End_Position

Int

4.0

t_Search_End_Position = i_Position - i_Open_Window_Offset

RETURN

0.0

RET_VAL

Block: FC124

0.0

%version: 1.5 % CN: 30

Function:
Search in a domain of the sorted tracking list for specific data.
Description:
This function searches for data in a specific search window of the tracking.
This search window is represented by a window that is referenced with an open
window offset and an close window offset regard to the position.
Open Window Close Window
Offset
Offset
|<---a---->|<---b---->|
____________________________________
===flow-direction===>
____________________________________
^
^
^
|
|
|
|
i_Position
|
Search-End
Search-Start
|
Position
t_Search_Start_Position = i_Position + i_Close_Window_Offset
t_Search_End_Position = i_Position - i_Open_Window_Offset
If the open offset = -1 than the tracking is searched until the first entry in
the tracking DB.
If the close offset = -1 than the search starts from the last used entry in the
tracking DB.
using -1 as open and close offset will perform a search through the complete

Page 1 of 4

SIMATIC

DaNang_PLC06_10072012\SIMATIC
300(1)\CPU 319-3 PN/DP\...\FC124 - <offline>

01/28/2015 11:14:16 AM

tracking DB
History:
This version

%created_by: %
%date_created: %

Modification History:
---------------------------------------------------Change-over from RCS to Synergy/CM;
Replaced RCS keywords for Synergy keywords.

By:
------nlHdL

Date:
-------28-01-08

Rev:
----1.5

Revision 1.4 2006/04/19 07:27:36 nltvh


Added -1 as valid input for open and close offset
Corrected Displacement offset in search window to be inline with FC_Read_Track
function
Revision 1.3 2004-10-22 08:40:22+02 nltvh
Corrected: Search start position not examined in current software
Revision 1.2 2004-05-04 16:51:24+02
Changed mm into cm

nlsve

Revision 1.1 2004-02-04 17:24:46+01 nlgm


Several modifications during SSS implementation phase 'B'.
Revision 1.0 2003-12-24 12:15:18+01
Initial revision

Network: 1
L
T
OPN

BA: Open tracking DB


#i_DB_Track
#t_Track_DB_Nr
DB [#t_Track_DB_Nr]

Network: 2

0
#o_Position

#o_Entry

CLR
=

#o_Data_Found

Network: 3

Network: 4

L
SLW
L
+D
LAR1

// Open tracking DB

#i_DB_Track
#t_Track_DB_Nr
#t_Track_DB_Nr

-- Tracking DataBlock
-- Copy of i_Track_DB_Nr
-- Copy of i_Track_DB_Nr

CA: Initialisation output variables

L
T

L
L
<=I
BEC

nlgm

// Initialisation of output variables


#o_Position
-- [cm] Tracking position w
here data is found
#o_Entry
-- Record-number in sorted
tracking-list
#o_Data_Found

-- Data found in tracking

DA: Check if there are entries filled in tracking DB

DBW
0

// Number of entries filled


// IF no entries present in tracking DB
// THEN no data to find, so End of block

FA: Calculate pointer to data in last record tracking DB

DBW
5
P#2.0

//
//
//
//
//

Number of entries used in tracking DB


Shift bytes to make pointer to last entry
6 (Header lenght) - 4 (record lenght) = offset
Add offset to jump over tracking DB header
Pointer to last used entry in tracking DB

Page 2 of 4

SIMATIC

DaNang_PLC06_10072012\SIMATIC
300(1)\CPU 319-3 PN/DP\...\FC124 - <offline>

Network: 5

GA: Calculate start- and end-position of search-window

L
L

-1
#i_Open_Window_Offset

==I
JCN
L
T

GA01
DBW
6
#t_Search_End_Position

JU

GA02

GA01: L

-I
T

#t_Search_End_Position

JU
GA03: L
L
+I
L
+I
T
GA99: NOP

L
<=I
JC
L
L

#t_Search_End_Position -- t_Search_End_P
osition = i_Position - i_Open_Window_Off
set
#i_Position
-- SETT: [cm] Positio
n in tracking
#i_Open_Window_Offset -- SETT: [cm] Offs
et before position pec to open update wi
ndow

// Search_End_Position = (Position - Upstr


eam offset)

-1
#i_Close_Window_Offset

#t_Search_End_Position -- t_Search_End_P
osition = i_Position - i_Open_Window_Off
set

#i_Close_Window_Offset -- SETT: [cm] Off


set after position pec to close update w
indow
// IF close offset = -1

GA03
DBW [AR1,P#0.0]
1
#t_Search_Start_Position

// THEN search start position = last used


entry position + 1 in tracking db

#t_Search_Start_Position -- t_Search_Sta
rt_Position = i_Position + i_Close_Windo
w_Offset

GA99
#i_Position

#i_Position
-- SETT: [cm] Positio
n in tracking
#i_Close_Window_Offset -- SETT: [cm] Off
set after position pec to close update w
indow

#i_Close_Window_Offset

DBW

#t_Search_Start_Position

// Correction with displacement


// (note: don't care for "Search_End_Position")
// Search_Start_Position = (Position + Dow #t_Search_Start_Position -- t_Search_Sta
nstream offset) + Displacement
rt_Position = i_Position + i_Close_Windo
w_Offset

Network: 6

HA01: L

// THEN search end position = entry[1] pos


ition in tracking db

#i_Position
#i_Open_Window_Offset

==I
JCN
L
L
+I
T

#i_Open_Window_Offset -- SETT: [cm] Offs


et before position pec to open update wi
ndow
// IF open offset = -1

GA02: L
L

01/28/2015 11:14:16 AM

HA: Search for data in search-window

#t_Search_Start_Position

// START OF SEARCH-LOOP

DBW [AR1,P#0.0]

//
//
//
//

#t_Search_Start_Position -- t_Search_Sta
rt_Position = i_Position + i_Close_Windo
w_Offset

>=I
JC

HA02

Actual entry position


IF Search-Start-position < read position THEN jump to decrease pointer
THEN jump to decrement pointer
Actual-position
#t_Search_End_Position -- t_Search_End_P
osition = i_Position - i_Open_Window_Off
set
// ELSE Actual-position >= Search-End-Position jump to make outputs
// THEN data found

JU

HA99

// ELSE jump to no data found end of search-loop

DBW [AR1,P#2.0]
#i_Data

// Track-data

HA02: L
L
==I
JCN

HA03
DBW [AR1,P#0.0]
#t_Search_End_Position

HA03

#i_Data
in tracking

-- Data to search for

// IF Track-data == searched data


// THEN

Page 3 of 4

SIMATIC

DaNang_PLC06_10072012\SIMATIC
300(1)\CPU 319-3 PN/DP\...\FC124 - <offline>

L
T

DBW [AR1,P#0.0]
#o_Position

// Store position

SET
=

#o_Data_Found

// Set data found bit

TAR1
L
-D
SRW
T
JU
HA03: TAR1
L
-D
JMZ
L
+D
LAR1
JU
HA99: NOP

01/28/2015 11:14:16 AM

#o_Position
-- [cm] Tracking posi
tion where data is found
#o_Data_Found
king

-- Data found in trac

// Pointer to actual entry


P#2.0
// - (Length of header tracking DB - register length of one entry)
5
#o_Entry

// Store Entry-number

#o_Entry
-- Record-number in s
orted tracking-list

HA99

HA99

//
//
//
//

P#2.0

// THEN Entry pointer = Entry pointer + P#2.0

P#6.0

Read Entry pointer of address-register


6 bytes, because the header of a tracking DB is 6 bytes long.
Entry pointer = Entry pointer - P#6.0
IF Entry pointer > 0

// Store Entry pointer in address-register


HA01
0

// GOTO START OF SEARCH-LOOP

Page 4 of 4

Вам также может понравиться