Workbook for Designing Distributed Control Applications using Rockwell Automation s HOLOBLOC Prototyping Software John Fischer and Thomas O.

Size: px
Start display at page:

Download "Workbook for Designing Distributed Control Applications using Rockwell Automation s HOLOBLOC Prototyping Software John Fischer and Thomas O."

Transcription

1 Workbook for Dsigning Distributd Control Applications using Rockwll Automation s HOLOBLOC Prototyping Softwar John Fischr and Thomas O. Bouchr Working Papr No

2 Introduction A nw paradigm for crating distributd control applications is currntly bing proposd undr th IEC standard. This standard mphasizs formal mthods basd on Unifid Modling Languag and objct orintd concpts. It maks a sparation btwn vnts, data, and algorithms. Algorithm xcution is initiatd by th arrival of vnts and th algorithm uss th currnt valus of data lmnts availabl whn th vnt occurs. Th programming is don using function blocks, a modling formalism originally proposd undr th standard IEC , but xtndd undr th currnt standard. Evnt propagation is accomplishd by conncting vnts among th various function blocks. This standard is currntly volving and has not yt bn usd in actual factory applications. Th prdominant standard today, IEC , dos not distinguish btwn vnts and data. Th arrival of nw data (snsory input) is itslf considrd an vnt. Th continuous scan of th PLC program xcuts th laddr logic rungs (algorithm) associatd with th data whn it arrivs. In contrast, IEC is vnt drivn and dos not ncssarily scan ach function block continuously. IEC was dvlopd to support distributd control. Distributd control is distinguishd from purly hirarchical control by th fact that th dcision procsss associatd with an application ar not running undr a singl procssor. Rathr, th dcision procsss ar dividd among svral procssors, ach having thir own thrad of control. Howvr, in ordr to xcut th application, ths procssors must xchang data and stat information with ach othr. Figur 1 is illustrativ of a distributd control dvlopmnt platform for IEC Componnts on th ntwork ar intllignt dvics with thir own microprocssor and ntwork drivrs. Componnts communicat pr-to-pr and dlivr timly information for th functioning of th ovrall systm. Control softwar is configurabl using a standard library of function blocks (FB) that can b assmbld in a plug-and-play fashion to dvlop th control programs that will run on th individual dvics. Standard function blocks for communication among dvics nabl pr-to-pr communication. 1

3 Softwar Tools Projct Rpository PORTABILITY Softwar Libraris CONFIGURABILITY INTEROPERABILITY Distributd intllignt dvics & machins Figur 1. Componnts in a distributd control procss Th distributd control architctur undr IEC dfins ky lmnts of a distributd control systm. Thy ar application, dvic, and rsourc. An application is a rlatd st of functions that must talk to ach othr in ordr to fulfill a control task. A dvic is a control unit having on or mor procssors. Th dvic intrfacs to th physical I/O and also communicats with othr dvics on th ntwork. A rsourc is ssntially a procssor on which part of a distributd application will run. W ar us to thinking about singl unit oprations consisting of a singl PLC running all th control functions of a machin. Such a PLC usually has a singl procssor. Th PLC, with its I/O and ntwork intrfac, is th dvic. Th procssor of th PLC is th rsourc. Th program on th procssor is th application. Thrfor, such a systm is a dvic with a singl rsourc and singl application. Figur 2 shows an xampl of distributd control on a singl dvic. Hr thr ar thr rsourcs that shar th procss I/O intrfac and communication intrfac of th dvic. Th procss I/O intrfac is for physical wiring of snsors and actuators. Th communication intrfac is th ntwork intrfac of th dvic ovr which th procssors can communicat with othr procssors on othr dvics. Procssors on th sam dvic can communicat with on anothr ovr th dvic back plan. Application C is distributd across rsourcs x, and y. Som of th xcution cod is handd by ach rsourc and th rsourcs must talk to on anothr for th application to run proprly. Applications A and B xtnd byond th dvic. Thy will hav functions on othr dvics (not shown) and will communicat with thm through th communication intrfac. 2

4 In th PLC world, a typical dvic usually has only on rsourc. For th tim bing w will assum that modl. Thrfor, distributd control consists in applications that ar running on mor than on PLC (dvic with a singl rsourc) and communicating with ach othr pr-to-pr on a ntwork. Th problm of distributing an application is dtrmining how th modl of an application will b dividd among th PLCs and how th PLCs will talk to on anothr. Communication link(s) Communication intrfac(s) Rsourc x Rsourc y Rsourc z Application A Application C Application B Procss intrfac(s) Controlld procss/machin Figur 2. A dvic with thr rsourcs and thr applications Th function block is th unit of programming. Thr ar thr typs of function blocks: basic function blocks, composit function blocks, and srvic intrfac function blocks. A basic function block xcuts an lmntal control function, such as rading a snsor or stting th stat of an actuator. Basic function blocks may b combind togthr to ncapsulat a highr-lvl control function. Such a combination is calld a composit function block. Th srvic intrfac function block provids th communication srvics among dvics. Figur 3 shows a modl of th componnts of a basic function block. Th modl distinguishs btwn vnts, data, and algorithms. Th uppr quadrant of Figur 3 shows th vnt stram, which initiats th xcution of th function block cod. Th arrival of an vnt xcuts on or mor function block algorithms. Each vnt input will triggr a diffrnt xcution scnario (combination of algorithms). Aftr th xcution of th scnario, th function block will typically nabl an output vnt. Input vnts com from othr function blocks and output vnts ar snt to othr function blocks in th application. 3

5 Th data flow is shown in th lowr quadrant of th FB in figur 3. Data inputs ar providd ithr from physical dvics or from othr function blocks. At th tim that an input vnt occurs, th data input valus ar rad and th appropriat algorithm is xcutd using th currnt data valus. Typically this rsults in a calculation or validation that yilds data outputs of a function block. Whn th output vnt is triggrd, th data output is mad availabl to anothr function block that continus th xcution of th application. Figur 3 Componnts of a Function Block A common xampl usd to illustrat a function block application is PID control as shown in figur 4. Th IO_Radr is a basic function block that scans th valu of an analog snsor ach tim th input vnt RSP is triggrd. Th data from th snsor is rad at th data input addrss SD_1. Th algorithm of th IO_Radr simply taks th valu at SD_1 and transfrs it to RD_1. Whn th transfr is complt, th output vnt IND is triggrd, providing th input vnt RUN to th PID algorithm function block. Whn th PID function block rads th procss variabl (PV) data input, it xcuts a standard PID control algorithm and outputs th valu of th control variabl (CV). IO_Writr is a basic function block for writing a valu to an actuator. Whn th PID FB xcuts OK, th vnt REQ bgins th IO_Writr algorithm, which rads th valu at SD_2 and th addrss of th actuator (SD_1), thn writs th valu of th control variabl to RD_1, th actuator physically connctd to th procss. 4

6 Figur 4 PID Controllr Programmd with Function Blocks Th abov xampl shows th lmnts of th function block and an application. Th xcution of th algorithm for a FB is dscribd by a stat machin, calld an xcution control chart (ECC). For xampl, figur 5 shows th ECC for th PID function block. Th initial stat is labld Start and drawn with a doubl-sidd rctangl. Th condition on th arc (RUN) is th input vnt that snds th FB to th stat RUN_PID. Th PID algorithm is xcutd in that stat. Th PID algorithm uss th currnt valus of th data inputs and sts th currnt valu of th control variabl output. Th action box attachd to th right of th algorithm action block is th nam of th output vnt that is triggrd upon compltion of th algorithm. Th labl 1 on th output arc mans tru always, dircting a transition back to th start stat whn th algorithm xcution is complt. Figur 5 Excution control chart of PID_SIMPLE function block 5

7 This is a basic introduction to th IEC standard. For a mor complt dscription, th radr is rfrrd to Modling Control Systms Using IEC by Robrt Lwis (Th Institution of Elctrical Enginrs, London: 2001). Th purpos of this workbook is to provid hands-on tutorials on th us of IEC in dsigning function blocks and distributd applications. Th cration of function blocks and th us of standard function blocks hav bn facilitatd by Rockwll Automation through th Holobloc IEC prototyping softwar. Th us of this softwar in dsigning function blocks will b dscribd in th lssons of this workbook. Th Function Block Dvlopmntal Kit can b found onlin at Holobloc s wbsit, Undr th link, Function Block Dvlopmntal Kit (FBDK), th softwar can b downloadd for fr, non-commrcial us. Aftr clicking on th link, you will b at a wb pag titld Gtting Startd. Th instructions on downloading and stting up th FBDK ar listd on this wb pag. Bfor downloading th FBDK, plas rad th Trms and Conditions of Us sction of th pag bfor downloading th softwar. Onc you click on th statmnt, I hav rad and agr to th following Trms and Conditions of Us, you will download a zip fil. This zip fil contains th FBDK xcutabl fil and othr fils for us with th FDBK (i.. function blocks). Rturn to th Gtting Startd wb pag and follow th rmaining stps for xtracting th fils from th zip fil and stting thos fils up on your computr. If you do not hav Java Dvlopr Kit 5.0, or an oldr Java Dvlopr Kit vrsion; it is highly rcommndd that you download and install th latst vrsion. Without it, it will not b possibl to crat your own function blocks. Onc thos stps ar compltd, you ar rady to procd through th following lssons to larn and us th FBDK. 6

8 TABLE OF CONTENTS LESSON PAGE IEC Tutorial 1: Introduction to IEC IEC Tutorial 2: Composit Function Block Tutorial 26 IEC Tutorial 3: Usr-Dfind Basic Function Block 37 IEC Tutorial 4: Publish and Subscrib Function Blocks 47 IEC Tutorial 5: Clint and Srvr Function Blocks 55 IEC Tutorial 6: Adding Java Cod to a Function Block 62 IEC Tutorial 7: Dsigning Databas Qury Function Blocks 74 7

9 IEC TUTORIAL 1: INTRODUCTION TO IEC Introduction Th IEC is an volving standard that uss function blocks in th distribution of control in industrial procsss. This tutorial will go through th basics of using function blocks as wll as xplaining th us of th softwar for dvloping and tsting control programs. SITUATION: Thr is a programmabl logic controllr that has switchs as inputs and lights as outputs. In this situation, thr ar two switchs (switch 3 and switch 2) and two lights (light 1 and light 2). Th systm must mt th following rquirmnts. 1) Both lights will b on if I:1/3 (switch 3) is turnd on and I:1/2 (switch 2) is turnd off. 2) If I:1/3 and I:1/2 ar both turnd on, thn O:2/1 (light 1) will b on and O:2/2 (light 2) will b off. 3) If I:1/3 is turnd off, thn both lights will b off, rgardlss of whthr I:1/2 is on or off Swi tch 3 I: 1 Th laddr logic for this PLC is as follows: I*16 Figur 1.1 Laddr Logic for Tutorial 1 In Boolan logic, th PLC follows ths quations. Light 1 = Switch 3 Light 2 = Switch 3 Switch 2 Switch 2 I:1 2 Light 1 O: O*16 Light 2 O: O* Stps in Using th Holobloc FBDK Softwar Now that th logic of th systm is ralizd, programming it in IEC can now bgin. First w must launch th function block ditor. Using Windows Explorr, go to th dirctory that contains th function block ditor: C:\fbdk. Th right sid of th scrn should look lik Fig. 1.2 in which th ditor is highlightd. Doubl click on th ditor. 8

10 Stp 1: Crating a Nw Systm Figur 1.2 Function Block Editor Onc th ditor is launchd, you will s a scrn that looks lik Fig. 1.3a. Th first stp is to bgin a nw systm configuration. Go th mnu bar and click on Fil -> Nw -> Systm. Th scrn should b similar to Fig. 1.3b. Figur 1.3a Dfault Scrn 9

11 Figur 1.3b Nw Systm Scrn Stp 2: Proprtis. On th lft sid of th scrn, thr is a list. This list rprsnts th dfault systm configuration. Th first ntry is titld Proprtis. Undr th Proprtis listing, thr ar thr ntris: Nam/Commnt, Idntification, and Vrsions. Th first ntry, Nam/Commnt, givs th nw systm a nam and adds any commnts about it. Th scond ntry, Idntification, is usd to add any xtra information about th systm (i.. th standard usd). Th third ntry, Vrsions, is usd to add information on th systm s author and th systm vrsion history. By doubl clicking on ach of thos ntris, windows will pop up on scrn to allow you to ntr th propr information. First, doubl click on Nam/Commnt ntry to bring up th window at th bottom scrn as shown in Figur 1.4a. Figur 1.4a Proprtis Nam/Commnt Window By insrting txt into th Nam fild, th systm can b givn a nam along with usr commnts. Th dfault nam is Systm. Giv th nw systm a nam. B sur not to us any spacs or spcial charactrs. For th purposs of this tutorial, it will b namd 10

12 Tutorial1. This nam will not only b th nam of th systm but also th nam of th fil that will b savd. Whn th information is ntrd, click OK and th systm will now hav a nw nam. Onc th systm has a nw nam, doubl click on th third ntry, Vrsions. Hr you will provid th nam of th organization programming th systm, th vrsion numbr, th dat, any commnts, and th author s nam can b addd. If thr ar any othr ntris thr, you can dlt thm by clicking on th row to highlight it, right click on th row, and slcting Cut. You can add an ntry by right clicking within th window and slcting Nw and clicking on ach fild to insrt th dsird information. Click OK whn finishd so th information can b savd. Whn you ar finishd, th Vrsions tab will look somthing lik Fig. 1.4b. Figur 1.4b Exampl Vrsion Sttings Doubl clicking on th ntry titld Idntification will opn up anothr window allowing you to ntr information. Howvr, for th purposs of this tutorial, nothing nds to b addd thr. Th systm now has a nam as wll as information on th systm s vrsion, th systm s author, th dat of th vrsion, and th organization th systm is for. Stp 3: Saving & Loading Systms. It is important to constantly sav th systm aftr ntring important information. Saving a systm allows you to avoid losing any progrss you hav mad on your systm. To sav a systm, go to th mnu bar, click on Fil -> Sav As -> XML. All systms ar savd as XML fils. For th purposs of this tutorial, it is rcommndd to sav ths XML fils undr th fil path C:\fbdk\src\studnt. If you want to sparat your fils from th othr fils alrady in that dirctory, you can crat anothr subdirctory within studnt. Plas sav th Tutorial1 systm. Figur 1.5a shows what th Sav As scrn will look lik. 11

13 Figur 1.5a Sav Systm as XML Scrn To load a systm, go to th mnu bar click on Fil -> Opn -> XML. A load XML fil scrn will appar. Whn st to IEC XML Fils, th Fils of Typ drop down mnu displays all of th XML fils that can b loadd. Figur 1.5b shows th scrn that appars to load up a XML fil as wll as th Tutorial1 systm fil that was just savd. Figur 1.5b Opn XML Fil Scrn 12

14 Stp 4: Dfining Dvics. Th nxt ntry on th list to th lft, blow Proprtis, is titld APP1. Mor dtails on this ntry will com latr. Th following ntry is th systm nam, as dfind in undr th Nam/Commnts ntry. Click on this nam and th workspac will display th dvics in th systm. Thr should b a block namd DEV1 with th nam DvicTyp. All systms ar mad up of dvics. Dvics ar mad up of on or mor indpndnt procssors with thir own mmory, I/O, and thrad of control. Ths indpndnt procssor units ar calld rsourcs. A PLC with on procssor is roughly quivalnt to a dvic with on rsourc. In this cas th dvic is shown with two rsourcs. By right clicking in th workspac, mor dvics can b addd by slcting Nw -> Dvic. For this tutorial, only on dvic is ndd; thus, th currnt dvic, DEV1, nds to b ditd. Right click on th nam at th top of th block, DEV1, and slct Edit. As Figur 1.6 shows, a window pops up with a st of txt filds and a drop down mnu. Th currnt typ of dvic is DvicTyp, which must b changd; th program will not run as a DvicTyp. Click on th drop down mnu titld Typ and slct FRAME_DEVICE to chang th typ to FRAME_DEVICE. This typ will mak th program run in a window. Whn finishd, click OK and you will s th changs mad to th dvic. Incidntally, to dlt a dvic, you can right click on th nam of th dvic and slct Dlt. Notic how th block changs, thr ar additional listings within it now. You can right click on th paramtrs within th block titld BOUNDS and GRID to configur th dvic. Slct Connct to giv thm bas valus of [0,0,0,0] and [0,0]. Figur 1.6 Programming Dvics 13

15 Ths two dvic paramtrs adjust program window display can b dfind. Th first listing, BOUNDS, has four valus. Th first two, x and y, dfins whr th window will appar with rspct to th top lft cornr of th scrn whn th program is run. Th last two, width and hight, dfins th initial siz of th window. To chang th valus aftr conncting th paramtr with a bas valu, simply doubl click on it. A window will pop up allowing you to dit th paramtr. For this tutorial, st th BOUNDS paramtr to [100,100,150,200], but fl fr to chang thm. Click OK to finish and updat th paramtr. Th scond listing, GRID, dtrmins th grid siz within this window. For this tutorial, and in gnral, [1,1] will suffic. Again, doubl click on th bas valu to hav a window pop up to dit th paramtrs. Whn finishd, click OK, and th dvic paramtr will b updatd. Th systm configuration now has a dfind window and layout for whn th program is run. Now th rsourcs within dvic can b dfind. Stp 5: Dfining Rsourcs Bfor dvloping this systm, click on DEV1 on th lft sid of th scrn. Figur 1.7 shows that thr is on rsourc currntly within th prviously dfind DEV1, namd RES2. RES2 is a rsourc. Dvics ar mad up of rsourcs, which ar usd to contain and xcut th function blocks ncssary for th program. Right click on th rsourc block s nam, RES2, slct Edit, and a window will pop up allowing you to dit th nam and rsourc typ of th rsourc. This is also shown in Figur 1.7. Figur 1.7 Programming Rsourcs 14

16 For this tutorial, only on rsourc is ndd. You can choos to giv it a nw nam, such as RES1; but it s not rquird. Click on th drop down mnu namd Typ and slct PANEL_RESOURCE. Similar to dfining th dvic as a FRAME_DEVICE, th rsourc must hav this typ in ordr for th program to run. Click OK whn finishd and th rsourc has bn ditd. Dlting rsourcs is similar to dlting dvics, simply right click on th nam of th rsourc and slct Dlt. To add rsourcs, right click on th workspac, and slct Nw -> Rsourc. Now that th dvic and rsourc for this tutorial is dfind, th systm can now b programmd. Sav your systm bfor doing so. Stp 6: Adding Function Blocks Th nxt stp is to program th application using function blocks. Thr ar thr typs of function blocks: 1) basic function blocks, 2) composit function blocks, and 3) srvic intrfac function blocks. In this xrcis w will us only basic function blocks. Basic function blocks rprsnt lmntal functions, such as logical and mathmatical oprations. Many basic function blocks ar dfind as part of th IEC standard. Composit function blocks ar constructd by combining basic function blocks and/or usr-dfind function blocks in a squnc to prform highr-lvl control oprations. Srvic intrfac function blocks dfin communication among rsourcs and dvics. Th programming of basic function blocks and composit function blocks will b dscribd in a latr tutorial. Th application, titld APP1, is whr th programming will tak plac; it is whr th sourc cod will b writtn. Click on th ntry titld APP1 and th workspac will b compltly mpty. Whn starting a nw systm, thr will b on application ntry and it will b mpty. This tutorial will program th systm dscribd in Figur 1.1. To start programming th systm dscribd in Figur 1.1, try adding a function block for on of th input switchs of th PLC program. According to th situation, th switch is ithr on or off; so th function block must rprsnt a Boolan input. Such a standard input block coms with th softwar. To add a nw function block, right click on th mpty workspac, slct Nw -> FB. Click on th button nxt to th pull down mnu namd Typ to add a nw function block typ. Any blocks prviously calld up whil th program has bn usd will b listd in th pull down mnu namd Typ. Clicking on th button nxt to th pull down mnu allows sarching through th dirctoris for th dsird block. For this xampl, th ncssary function block typ is a Boolan input. A scrn will pop up to load a nw function block typ. This is similar to loading a systm. Th function block typ ndd can b found through this path: fbdk-> src -> hmi. Th fil for this block is IN_BOOL.fbt. Click on it and it will not only b th typ for that block, but it will now b in that pull down mnu. Now this nw function block nds a nam. For th nam of a function block, b sur not to us any spacs (us undrscors instad) or spcial charactrs. For this tutorial, on suggstion would b to call it INPUT_3. Giv it that nam or any othr nam now. Click OK and thr will now b a Boolan input function block namd INPUT_3 in th workspac, as shown in Figur

17 Figur 1.8 Workspac Aftr Adding an IN_BOOL Function Block To mov a function block in th workspac, simply click on th nam of th function block and drag it to th dsird location. Editing and dlting a function block can b don by right clicking on th function block s nam and slcting th propr choic in th rsulting mnu. EXERCISE: In this situation, anothr Boolan input function block is ndd as wll as two Boolan output function blocks (lights ar ithr on or off; thus, thy ar Boolan outputs). Th fil nam for th Boolan output function block is OUT_BOOL.fbt and it is in th sam dirctory as th IN_BOOL.fbt fil. According to th logic of th problm, AND and NOT functions ar involvd, so function blocks for thm ar ndd. Insrt ths fiv additional function blocks on your own. Th function blocks for AND and NOT functions ar in th dirctory fbdk -> src -> math, th fils ar FB_AND.fbt and FB_NOT.fbt rspctivly. You may nd to mov th blocks to s thm all clarly. This can b don by clicking and dragging thm in th workspac. Sav th systm whn finishd Figur 1.9 shows all of th blocks ndd for this systm. 16

18 Figur 1.9 Function Blocks Rquird for Systm Stp 7: Evnts Function blocks ar controlld by vnts. Evnts ar shown at th top, or had, of th block. Think of vnts as pulss. Whn a function block xcuts an vnt, it snds out a puls to any function block connctd to th output of that vnt. Whnvr an vnt rachs a function block, data that corrsponds with th arrival of that vnt gts rad, th algorithm within th function block is xcutd basd on th typ of vnt, and an vnt is outputtd from that function block to th nxt on. Click on APP1 and notic in th workspac that non of th function block vnts ar connctd with any othr function block vnts. Conncting function block vnts is simply don by holding th Alt ky on th kyboard, clicking on th vnt of on function block, and dragging th cursor to a scond vnt on anothr function block. A connction will appar btwn th vnts in th workspac. For xampl, an vnt is ncssary btwn th IND vnt in INPUT_3 and th REQ vnt in NOT. IND stands for indication; whnvr thr is a chang in INPUT_3 (switch is turnd on or off), this vnt will occur and go to its dstination. REQ stands for rqust; whnvr an vnt coms to REQ, th algorithm associatd with it is activatd. What is ndd is that whnvr thr is a chang in INPUT_3, NOT should b activatd and xcuts its algorithm. Hold th Alt ky, click on th IND vnt on th INPUT_3 function block, and thn drag th cursor to th REQ vnt on th NOT function block. A lin will appar conncting th two vnts, as sn in Figur

19 Figur 1.10 Workspac Aftr Conncting Two Function Block Evnts Evnt connctions ar always displayd as grn lins. Dlting a connction btwn vnts is don by clicking on th connction lin itslf. Th connction will turn rd; it can thn b dltd by holding th Alt ky and prssing th Dlt ky or by right clicking on th connction and clicking on Dlt. It should b notd that both input and output function blocks hav additional vnts namd INIT and INITO. Ths vnts ar calld initialization vnts; thy ar usd in th initialization of th program and nsur that th blocks will b activ and in thir initial stats whn th program is startd. Most function blocks hav ths vnts, so it is rcommndd that thos vnts ar always connctd. EXERCISE: Connct th rmaining ncssary vnts. Us Figur 1.11 as your guid. Connct th INIT and INITO vnts by starting with th INITO vnt in INPUT_3 with th INIT vnt in INPUT_2. Connct th INITO vnt in INPUT_2 with th INIT vnt of OUTPUT_1; and thn connct th INITO vnt in OUTPUT_1 with th INIT vnt of OUTPUT_2. Connct th IND vnt in INPUT_3 with th REQ vnt for OUTPUT_1, as wll. Connct th IND vnt in INPUT_2 with th REQ vnt for NOT. Connct th CNF vnt in NOT with th REQ vnt in AND. Connct th CNF vnt in AND with th REQ vnt in OUTPUT_2. Ignor th INIT vnt for INPUT_3 and INITO vnt for OUTPUT_2. Also ignor th REQ and CNF vnts for th two input blocks as wll as th CNF vnts for th two output blocks. Th final rsult should b similar to Figur

20 Figur 1.11 Workspac Aftr All Evnt Connctions Ar Mad If th connctions gt too visibly confusing, right click on th main scrn and slct Rdraw -> Connctions. That should mak th diagram clarr. Stp 8: Conncting Data Th data in a function block is rprsntd in th bottom, or body, of th function block. Data gts rad whn an vnt arrivs, is procssd through an algorithm, and a rsult is outputtd. Lik vnts, data nds to b connctd btwn function blocks. For this tutorial, th data outputtd from th two input blocks nd to b usd with th logic to control th final output. Conncting data is don with th sam mthod usd for conncting vnts. According to th logic, OUTPUT_1 is only affctd by INPUT_3. Thrfor, whatvr is outputtd from INPUT_3 should go into OUTPUT_1. Connct th OUT in INPUT_3 to th IN in OUTPUT_1 using th sam mthod to connct vnts. Hold th Alt ky, click on OUT in INPUT_3, and drag th cursor to IN in OUTPUT_1. That part of th logic is now succssfully implmntd in th program, as shown in Figur Data connctions ar always displayd as blu lins, and can b dltd in th sam way as vnt connctions. 19

21 Figur 1.12 Workspac Aftr First Data Connction EXERCISE: Mak all of th ncssary data connctions to complt th logic for th rst of th program. Rmmbr that data, lik vnts, can go to multipl dstinations. Whn finishd, all th ncssary data connctions will b mad and th systm should look similar to Figur Figur 1.13 Workspac with Evnt and Data Connctions 20

22 Stp 9: Assigning Data Whil all th data connctions ar mad, th systm is still not complt. Thr ar multipl data inputs that hav nothing assignd to it. Whil vnts nd only to b connctd to othr vnts, som data inputs rquir thir own valus. For xampl, both th input and output function blocks hav a data input calld QI. QI activats th block whn it is dfind as 1 so that th function block will run whn th program is xcutd. By stting QI=0, th usr prvnts th function block from xcuting whn th program is running. This is similar to commnting out a lin of cod in a program. Thrfor, all of th QIs should b dfind as 1. To do this, right click on th QI data input for INPUT_3, and slct Connct. Thr should b a display similar to th on shown in Figur Figur 1.14 Assigning A Data Input Slct 1 for QI and th data input will display a 1 for that data input. To dit this valu, doubl click on th valu of th data input, and a window will pop up allowing th paramtr to b ditd. Rpat this procss for th othr data inputs titld QI in th systm. B carful not to assign mor than on sourc to on dstination, othrwis thr will b an rror. Othr data inputs can b dfind by right clicking on th data input nam on th function block, slct Connct, and th bas valu that appars. Editing a data input valu is don th sam way as diting a dvic paramtr. Doubl click on th data input valu, a window will pop up, and th paramtr can b ditd. If th bas valu is, that mans th data input is a string; insrt txt in btwn th quotation marks. Som function blocks hav spcific data inputs, such as th OUT_BOOL function block. Th data inputs C0 and C1 rfr to color whn th output is a 0 or a 1. Thrfor, th valu should corrspond to a rd-grn-blu valu (i.. [0,0,0] is black, [255,0,0] is rd, tc.). EXERCISE: Connct and assign valus to th data inputs for th rmaining input and output function blocks. Giv labls to ach function block, so whn th program is run thr will b a nam assignd to that input or output. For th input function blocks, st IN to 0, sinc th switchs will b off whn th program first starts. For th output 21

23 function blocks, choos a diffrnt color ach for C0 (whn th light is off) and C1 (whn th light is on). Onc finishd with this xrcis, th program should look similar to Figur Do not worry about QO, thr is no us for that data output in this situation. Th cod in program is finishd, and th logic of th situation is ralizd. Figur 1.15 Compltd Data and Evnt Configuration Stp 10: Mapping and Running th Program Chck for any rrors mad in th program. Any rrors that do occur will appar in a txt box at th top of th scrn. If thr ar no rrors, this program can now b mappd to th rsourc that was prviously dfind. Function blocks hav to b downloadd (mappd) to th rsourc on which thy will run. To map a function block, right click on th nam of function block and slct Map. Th following mnu will ask whr to map th function block. Whil it is possibl to map it to th dvic dirctly whn thr is only on rsourc on th dvic, which may caus rrors in th program. Thrfor, map it to DEV1.RES1 as shown in Figur

24 Figur 1.16 Mapping th INPUT_3 Function Blocks to RES1 Click on RES1 on th list lft of th workspac now. Th block should appar thr just as it was in APP1. Th only chang that may b mad is to mov th block, but that is a minor chang. EXERCISE: Map th othr blocks in APP1 to th rsourc RES1 in dvic DEV1. Click on RES1 and notic that all of th blocks in APP1 ar in RES1 with th sam connctions and data assignmnts. Also notic that thr is an E_RESTART block prsnt. This block is in all rsourcs, it controls th starting and stopping of th program. Th E_RESTART block only has thr vnts: COLD, WARM, STOP. Th COLD vnt initially starts th program, similar to turning on a computr aftr it has bn off. Th WARM vnt starts th program ovr aftr it has alrady bn startd, similar to rstarting a computr. Th STOP vnt nds th running of th program, similar to turning a computr off. For this program, only th COLD vnt is ndd; connct that vnt with th INIT vnt of th INPUT_3 block. Onc that is complt, th rsourc should look similar to Figur Sav th systm now, just bfor running it. 23

25 Figur 1.17 Systm Downloadd to a Rsourc To run a systm, go to th mnu bar and click on Run -> Launch -> th systm nam, Tutorial1. For this systm, th window shown in Figur 1.18 should appar at th dfind coordinats with th dfind dimnsions from Stp 3. Figur 1.18 Dvic Running th Program Th two switchs, bing Boolan inputs, appar as chckboxs. Th two lights, bing Boolan outputs, appar as lights. Chck th boxs in all possibl combinations to s if th program follows th ncssary logic and works corrctly. Figur 1.19 shows what should happn if all 10 stps wr followd proprly. 24

26 Figur 1.19 Various Combinations Tsting th Program If th program dos not run corrctly, thr is somthing wrong with th program. Mak any changs to corrct ths rrors in APP1, but th program will not run with ths changs until th original program is dltd from th rsourc and th updatd program is mappd again to that rsourc. This nds th tutorial on using function blocks in th IEC standard. 1.3 Summary In summary, this tutorial has shown th following squntial stps on basic us of th IEC softwar. To dsign a systm on this softwar: 1. Configur th nw systm by adding proprtis. 2. Dfin dvics by thir typ (usually FRAME_DEVICE) and thir bounds and grid paramtrs. 3. Dfin rsourcs in th dvic(s) and thir typ (usually PANEL_RESOURCE). 4. Add function blocks that will b usd. 5. Connct th vnts of th function blocks 6. Connct th data inputs and outputs of th function blocks. 7. Dfin th ncssary data inputs for crtain function blocks. 8. Map th function blocks to th propr rsourc(s) in th dvic(s). 9. Connct th E_RESTART function block to th othr function blocks in th rsourc(s). 10. Click on Run at th mnu bar, slct Launch and thn slct th systm s nam to launch th program. Do not forgt to sav th systm by clicking Fil -> Sav As -> XML. 25

27 IEC TUTORIAL 2: COMPOSITE FUNCTION BLOCK TUTORIAL 2.1 Introduction In th IEC standard, thr ar thr main typs of function blocks: 1) basic function blocks, 2) composit function blocks, and 3) srvic intrfac function blocks. Basic function blocks dscrib lmntal logical and mathmatical oprations. Thy consist of vnts; data; algorithms to procss data; and an xcution control chart to control what algorithms ar usd basd on what vnts ar inputtd into th block. Composit function blocks consist of multipl basic function blocks, but do not hav an xcution control chart. Ths blocks ar usful for larg programs, sinc many functions can b combind into a singl block. SITUATION: Crat a composit function block calld ON_OFF_OC that will tak two Boolan inputs and yild on Boolan output. Th notation usd to nam th composit function block typ is usr dtrmind. Hr w indicat that it is for on/off opration and consists of on opn (O) and on closd (C) contact. Th laddr logic for this function block is as follows in Figur 2.1a. Figur 2.1a Laddr Logic for Composit Function Block Bfor w bgin to crat a composit function block, lt us look at how th logic of Figur 2.1a would b implmntd using basic function blocks. This is shown in Figur 2.1b. Th start and stop switchs and th output lamp function blocks ar usd to mulat inputs and outputs. Th control logic is givn by th FB_NOT and FB_AND function blocks. Th logic is as follows: Start Stop = Out Thrfor, a composit function block to xcut this logic is composd of on NOT function block and on AND function block. This is th composit function block, ON_OFF_OC, which w will crat in this tutorial. 26

28 Figur 2.1b Function Block Equivalnt of Figur 2.1a 2.2 Stps in Crating a Composit Function Block Stp 1: Crating a Nw Composit Function Block Go to th mnu bar, click on Fil -> Nw -> FB Typ -> Composit to crat a nw Composit Function Block. Th composit function block Composit will thn appar, alrady with input data, output data, input vnts, and output vnts. Th nw window should appar lik Figur

29 Stp 2: Stting th Proprtis Figur 2.2 Dfault Nw Composit Function Block On th lft sid of th scrn, thr is a list of ntris for this nw composit function block. Th first ntry is calld Proprtis, and it has fiv ntris blow it. Notic that th first thr ntris listd ar xactly th sam for th proprtis of a systm: Nam/Commnts, Idntification, and Vrsions. For now, giv this composit function block th nam ON_OFF_OC and input th vrsion information in th sam mannr don in IEC Tutorial 1. To do that, simply doubl click on th dsird ntry and input th ncssary information. Click OK on th window whn finishd with ach. Figur 2.3 Proprtis - Compilr Info Window Thr is fourth ntry calld Compilr Info with an ntry listd blow calld Compilrs, which is xtrmly important. This composit function block can not b usd unlss it is ultimatly compild. Thrfor, a compilr must b dfind. For this tutorial, this 28

30 composit function block will b mad up of xisting basic function blocks. Thrfor, th fil-path to ths basic function blocks also must b dfind for th compilr. This information must b typd into th hadr fild. First, doubl click on th ntry calld Compilr Info and a window will pop up with txt filds for th compilr hadr and class dfinition. For this tutorial, only th hadr nds a dfinition. Th compilr is dfind as (without th quots) packag fb.rt.studnt;. Th function blocks ndd ar in th math foldr in th src dirctory. To dfin that, put in th hadr (without th quots) import fb.rt.math.*;. Any function blocks from that dirctory can now b usd. Th fild should b lik Figur 2.3. Now click on OK. Th Compilr Info will b updatd. If it is not updatd, simply look at th XML cod at th bottom of th scrn for th ntry that bgins with <Compilr Info. Th information for th compilr can b mad thr as wll; just b sur to pars th nw XML cod by clicking on th button with a circl of arrows (or Alt+S). Now click on th ntry calld Compilrs. A window will pop up with no listings in it. Right click in th mpty spac and slct Nw to add a compilr. It should look lik Figur 2.4. Stp 3: Intrfac Evnts & Data Points Figur 2.4 Proprtis - Compilr Window Th nxt ntry on th list to th lft of th scrn aftr th ntris undr Proprtis is calld Intrfac. Click on Intrfac and this workspac will display th composit function block itslf. This is whr vnts, data inputs, and data outputs can b cratd, dltd, and modifid. Th dfault nw composit function block alrady has four vnts: INIT and INITO vnts for initialization, a REQ vnt for rqusting of information, and a CNF vnt for confirmation. In gnral, thr should always b INIT and INITO vnts for function blocks that rtain intrnal information in ordr to mak sur th function block dos not us data from prvious program runs. Howvr, this function block only has data coming in from othr function blocks; thus, th INIT and INITO vnts ar not ncssary. Th radr can confirm this by looking at Figur 2.1b. Th FB_NOT and FB_AND function blocks do not rquir an INIT vnt. Rmov th INIT and INITO vnts by right clicking on ach vnt nam and slct Dlt. This composit function block will b rqusting vnts for data, so thr dos not nd to b any chang to REQ. In addition, data from th composit function block will b snt along with rqusting vnts, so thr nds to b a confirmation vnt that th data is rcivd. As a rsult, thr is no nd to chang CNF. 29

31 Howvr, thr is only on data input and on data output currntly for this dfault function block. QI is th input and QO is th output. Gnrally, thy ar important for som function blocks to actually function in a program; but in this cas thy ar not ncssary. Look at Figur 2.1b to confirm that thy ar not rquird for th FB_NOT and FB_AND function blocks. Thrfor, ths data inputs and outputs must b dltd. Right click on ach of th nams of th data input and data output and slct Dlt to dlt thm. Th composit function should now look lik Figur 2.5 blow. Figur 2.5 Composit Function Block with Input and Output Evnts For this ON_OFF_OC function block, thr nds to b two data inputs and on data output. Crating data inputs and data outputs ar don by simply right clicking within th composit function block and click on Nw. Undr Nw, thr ar two options: Evnts and Variabl. Slcting Evnts allows nw input and output vnts to b mad; whr as Variabl is for crating nw data inputs and data outputs. Click on Variabl and click on Input to crat a nw data input. A window will pop up to dfin th nam and data typ for this input. For this tutorial, nam this nw data input IN1O-this will rprsnt th opn contact from Figur 2.1a. Click on Typ and a pull down mnu will appar to mak th input a particular typ. In this instanc, both data inputs should b Boolan, so slct BOOL to mak IN1O a Boolan data input. Click OK whn finishd and th nw data input should appar on th composit function block. Rpat this procss for a data output namd IN2C. This data input will rprsnt th closd contact from Figur 2.1a to complt th ncssary data inputs for th composit function block. Whn finishd with th dfining th data input, click on OK to s th updatd rsults. EXERCISE: Giv th composit function block a singl data output calld OUT. Rmmbr, th inputs for th composit function block and th basic function blocks that will b usd ar Boolan, so th output should also b Boolan. Aftr finishing th xrcis, th ON_OFF_OC composit function block should look lik Figur 2.6. Figur 2.6 Composit Function Block with Data Inputs and an Data Output You may hav th sam information but not organizd th sam way. To mov vnts and data within a block, right click on th nam of th vnt or data in th composit function block and slct ithr Mov Up or Mov Down to mov it up or down. 30

32 Stp 4: Intrfac Data Connctions Whil th composit function block ON_OFF_OC now has vnts and data inputs, th two ar sparat from ach othr. Whn an vnt is rad into any function block, th data that it is associatd with is rad bfor it xcuts a particular algorithm. Thrfor, data connctions ar ncssary. Whn vnts or data ar dltd, th data connctions ar automatically dltd. Howvr, thy must b addd sparatly aftr crating nw vnts and data. Sinc, thr is only on vnt going into th function block, both data inputs must b connctd to that vnt. To do this, hold th Alt ky and click on th word EVENT associatd with th vnt you want to mak a connction for. Th cursor will chang and by dragging it to th dsird data input or output nam (or th data typ of th data input or output nam), a connction btwn an vnt and data will b mad. If th sam procdur is don on th sam connction, th connction will b dltd. Thr is only on input vnt for this composit function block; thus both data inputs should b connctd to this singl input vnt. Hold down th Alt ky and click on EVENT nxt to th REQ vnt. Drag th cursor onto th word BOOL nxt to IN1O and that data input will thn b connctd to th REQ vnt. Whnvr an vnt coms to REQ, IN1O will thn b rad and go through th composit function block. By using th sam procss, connct th REQ vnt to th IN2C data input and th CNF vnt to th OUT data output. Whn finishd, th composit function block should look lik Figur 2.7. Figur 2.7 Composit Function Block with Data Connctd to Evnts Now that th data is connctd to th vnts for th composit function block, all that nds to b don is to put basic function blocks in th composit function block for this function block to prform th dsird opration. Stp 5: Filling th Composit Function Block Whil thr is input and output data, as wll as input and output vnts, currntly nothing is bing don with th information coming to or laving th composit function block. In ordr to hav th composit function block to hav any actual us, thr must b function blocks (basic or othr composit function blocks) within it. On th lft sid of th scrn, th last ntry in th list is th nam of th block, ON_OFF_OC. Click on it and th workspac will show what is currntly in th composit function block. Right now, only a function block namd E_DELAY should b in th workspac. This workspac is xactly lik th on that appars whn on clicks on APP or a rsourc ntry in a systm; this is whr function blocks, data connctions, and vnt connctions tak plac. 31

33 For this ON_OFF_OC function block, th E_DELAY function block is not ncssary, so dlt it. Add a FB_AND and a FB_NOT function block and thn click on Updat. If you click on Updat aftr rmoving th E_DELAY function block but bfor adding any othrs, th listing on th sid of th scrn for this window disappars. This is don xactly as it was don undr Stp 6 in IEC Tutorial 1. Rmmbr that both blocks can b found on th following dirctory path: fbdk->src->math. Whn finishd, th scrn should b lik Figur 2.8. Figur 2.8 Basic Function Blocks for ON_OFF_OC Composit Function Block EXERCISE: Connct ths two blocks togthr with on data connction and on vnt connction. B sur to follow th laddr logic shown in Figur 2.1a. Whn finishd with th xrcis, th two blocks should b connctd as shown in Figur 2.9. Figur 2.9 Basic Function Blocks with Connctions for ON_OFF_OC 32

34 Stp 6: Complting th Connctions. Now th ncssary function blocks ar in th ON_OFF_OC composit function block. Th two ar connctd in th right ordr (NOT thn AND function). Howvr, thr is still th issu with th data and vnts dfind in th composit function block. Currntly, th NOT and AND function blocks hav no data connctd to its inputs; th AND function block has no dstination for its CNF vnt; and th NOT function block has no sourc for its REQ vnt. Furthr connctions must b mad so th data and vnts coming in and out of th composit function block will go through ths function blocks insid of it. Start with th vnts. Th composit function block, ON_OFF_OC, has an vnt input calld REQ to rciv vnts and an vnt output CNF to output thm. Sinc th FB_NOT function block should b accssd first, th REQ vnt from th composit function block should b connctd with th REQ vnt of th function block namd NOT. Right click on th REQ vnt on th NOT function block, click on Connct, and slct REQ. By doing this, an vnt coming into REQ of th ON_OFF_OC composit function block will go dirctly to REQ of th FB_NOT function block within it. This connction is st. Thr nds to b a connction to th CNF vnt of th composit function block to output an vnt. Sinc th AND function block is th last function block to b usd, th CNF vnt of that function block should b connctd with to th CNF vnt of th composit function block. Right click on th CNF vnt on th AND function block, click on Connct, and slct CNF. An vnt laving through th CNF vnt of th AND function block will b th CNF vnt of ON_OFF_OC. Th function block systm within ON_OFF_OC should look lik th systm shown in Figur 2.10, Figur 2.10 Evnts of Function Blocks Connctd to th Evnts of ON_OFF_OC Th data inputtd to and outputtd from th ON_OFF_OC composit function block must also b connctd to th basic function blocks. To start, connct IN2C of th ON_OFF_OC function block to th FB_NOT function block. IN2C rprsnts a closd contact, so it nds to go through th IN data input of th NOT function block. Right click on th IN data input nam, click on Connct, and slct IN2C. Th IN2C data input of ON_OFF_OC is now connctd to th IN data input of NOT. 33

35 EXERCISE: Connct th IN1O data input of ON_OFF_OC to th IN1 data input of th AND function block and th OUT data output of th AND function block to th OUT data output of th ON_OFF_OC function block. Onc finishd with that xrcis, Figur 2.11 shows what should b within th composit function block ON_OFF_OC. Figur 2.11 Linking Basic Function Block Data to Composit Function Block Data Stp 7: Compiling Th vnts, data, and logic of th ON_OFF_OC composit function block ar now complt. Howvr, ON_OFF_OC can not b usd yt. Th final stp is to compil this function block so it can b usd in othr programs. Earlir, th compilr was dfind as packag fb.rt.studnt;. This is whr th Java compilr within th program will chck for this fil and compil it. First, sav this ON_OFF_OC composit function block as a Java fil. This can b don by going to th mnu bar and clicking on th following path: Fil -> Sav As -> Java. Mak absolutly crtain th fil is savd in th alrady dfind dirctory. If, for som rason, th program dos not automatically tak you thr, it can b found by this pathway: fbdk -> lib -> fb -> rt -> studnt. Th nam of th function block will b savd with th xtnsion.java. Th fil will automatically b compild. A window will appar, shown in Figur 2.12, if it is succssful. 34

36 Figur 2.12 Java Succssfully Compild As it says in th window for Figur 2.12, bfor using this composit function block, th program usd for making this composit function block must b closd. Sav th ON_OFF_OC composit function block as an XML so it has th propr.fbt xtnsion. It is suggstd that you sav this function block in a nw dirctory undr th src foldr. Now it can b usd lik any othr function block in any othr systm. For xampl, stablish a dirctory with your nam on it whr you will sav your function blocks. Aftr following this tutorial, you hav succssfully cratd a composit function block. EXERCISE: Implmnt this ON_OFF_OC composit function block in th following systm in Figur In this xampl w hav givn th nam Control to this instanc of th composit function block of typ ON_OFF_OC. Figur 2.13 Exampl Using Basic Function Blocks 35

37 SOLUTION: Th propr implmntation of this function block systm is in Figur Summary Figur 2.14 Exampl Using ON_OFF_OC Composit Function Block This tutorial has shown th following squntial stps for crating and using a composit function block. To crat a composit function block: 1. Dfin th proprtis of th composit function block. 2. Dfin th compilr information, whr th compilr will look for th fil, and th fil path of othr function blocks usd in th composit function block. 3. Dfin th intrfac of th composit function blocks: vnts, data inputs, and data outputs. 4. Connct data inputs and outputs with corrsponding vnts. 5. Insrt all of th function blocks th composit function block will us and mak any data and vnt connctions within thos function blocks. 6. Connct vnts dfind in th intrfac to th propr function blocks insid th composit function block. 7. Connct data inputs and outputs dfind in th intrfac to th propr function blocks insid th composit function block. 8. Sav th function block as a Java fil in th sam dirctory dfind for th compilr. Th Java fil will automatically b compild. 9. If th fil was succssfully compild, sav th function block as an XML fil. 10. Clos th diting of th composit function block and add it to a systm lik any othr function block. 36

38 IEC TUTORIAL 3: USER-DEFINED BASIC FUNCTION BLOCK 3.1 Introduction In th IEC standard, thr ar two main typs of function blocks: basic and composit function blocks. In addition to rciving and snding vnts and data, basic function blocks hav algorithms to procss th data rcivd and xcution control charts to control which algorithms ar usd dpnding on th vnt rcivd. Composit function blocks ar mad up of combinations of basic function blocks. Thr ar svral basic function block typs that ar part of th IEC standard, such as logical and mathmatical function blocks. In addition, usrs can crat thir own basic function blocks for particular functions. To do so, it is ncssary to dfin th xcution control chart and th algorithms in addition to th vnts and data it will us. In this xrcis w will crat a usr-dfind basic function block. SITUATION: Crat a basic function block calld ON_OFF_OC_B that implmnts th following laddr logic shown in Figur 3.1. Figur 3.1 Laddr Logic for Basic Function Block 3.2 Stps in Crating a Basic Function Block Stp 1: Crating a Nw Basic Function Block Go to th mnu bar and click on Fil -> Nw -> FB Typ -> Basic FB to crat a nw Basic Function Block. Th basic function block NEWBASICFB will appar, alrady with input data, output data, input vnts, and output vnts. Th nw window should look lik Figur

39 Stp 2: Stting th Proprtis Figur 3.2 Dfault Basic Function Block On th lft sid of th scrn, thr is a list of ntris rlatd to this nw basic function block. Th first ntry is calld Proprtis, with fiv ntris blow it. Notic that th first thr ntris undr Proprtis ar xactly th sam for th proprtis of a systm: Nam/Commnt, Idntification, and Vrsions. For now, giv this basic function block th nam ON_OFF_OC_B (Not: This xtra _B is ndd if you followd th composit function block tutorial first and you do not want to ovrwrit that function block) and input th vrsion information. Click OK whn finishd. Figur 3.3 Proprtis Compilr Info Window 38

40 Th rmaining two ntris ar calld Compilr Info and Compilrs that ar xtrmly important. This basic function block can not b usd unlss it is ultimatly compild. Thrfor, lik with a composit function block, a compilr must b dfind. This information must b typd into th hadr fild. Th compilr is dfind as (and without th quots) packag fb.rt.studnt;. Th fild should b lik Figur 3.3. No othr dirctory paths nd to b importd sinc a basic function block dos not us othr function blocks. Click OK to updat th compilr information. Again, if th compilr information is not updatd, modify th hadr in th XML fil at th bottom of th scrn and click on th circl of arrows to pars th cod (or hit Alt+S). Doubl click on th Compilrs ntry and right click on th mpty spac and slct Nw. This will add a compilr for th function block; click OK to finish adding th compilr. Stp 3: Intrfac Evnts and Data Th nxt ntry blow Proprtis on th lft sid of th scrn is calld Intrfac. Click on that and th workspac will show th basic function block. This window is whr vnt and data inputs and outputs can b cratd, dltd, and modifid. Th dfault nw basic function block alrady has two input vnts: an INIT vnt for initialization and a REQ vnt for rqusting of information. In gnral, thr should always b an INIT vnt to mak sur th function block dos not us data that has bn stord intrnally from prvious running of th program. Howvr, this function block only has data coming in from othr blocks; an INIT vnt is not ncssary. This basic function block will b rciving information, so thr dos not nd to b any chang to REQ. Th basic function block has two output vnts: an INITO vnt for an output of an initialization and a CNF vnt for confirmation. Sinc thr is no INIT vnt, thr should b no INITO vnt. Data is bing rqustd, so thr nds to b a confirmation vnt, CNF, that th data is rcivd. Howvr, thr ar only on data input and on data output currntly for this function block. QI is th input and QO is th output. Gnrally, thy ar important for som function blocks to actually function in a program; but in this cas thy ar not ncssary. Right click on th QI data input and slct Dlt to dlt th data input, and do th sam for th QO data output. This will dlt both th data as wll as th data connction btwn th vnt and th data. It is not possibl to dlt any vnts that ar in th xcution control chart. This will b xplaind latr. Th basic function block should now look lik Figur 3.4. Figur 3.4 Basic Function Block with Input and Output Evnts For th ON_OFF_OC_B function block, thr nds to b two data inputs and on data output. Crating data inputs and data outputs is don by right clicking on th function 39

41 block, clicking on Nw, and clicking on Variabl. Slct input to crat a nw data input. A window will pop up to nam and dfin th data typ for th nw data input. For this tutorial, nam it IN1; which will rprsnt th opn contact shown in Figur 3.1. Click on drop down mnu nxt to th Nam txt fild to slct a data typ for th data input. In this tutorial, both data inputs should b Boolan, so slct BOOL to mak IN1 a Boolan data input. Click on OK and th nw data input IN1 will appar on th function block. Rpat this procss for IN2, which will rprsnt th closd contact shown in Figur 3.1. Now, th ncssary data inputs for th basic function block ar compltd. EXERCISE: Giv th basic function block a singl data output. Rmmbr, th inputs for th basic function block and ar Boolan, so th output should also b Boolan. Aftr finishing th xrcis, th ON_OFF_OC_B function block should look lik Figur 3.5. Figur 3.5 Basic Function Block with Input and Output Data You may hav th sam information but not organizd in th sam way. To mov vnts and data within a function block, right click on th nam of th vnt or data and slct ithr Mov Up or Mov Down to mov it up or down. Stp 4: Intrfac Data Connctions Whil th basic function block ON_OFF_OC_B now has vnts and data inputs, th two ar sparat from ach othr. Whn an vnt is rad into any function block, th data that it is associatd with is rad bfor it follows a particular algorithm. Thrfor, data connctions ar ncssary. Whn vnts or data ar dltd, th data connctions ar automatically dltd. Howvr, thy must b addd sparatly aftr crating nw vnts and data. Sinc, thr is only on vnt going into th function block, both data inputs must b connctd to that vnt. To do this, hold th Alt ky and click on th word EVENT associatd with th vnt you want to mak a connction for. Th cursor will chang and by dragging it to th dsird data input or output nam (or th data typ of th data input or output nam), a connction btwn an vnt and data will b mad. If th sam procdur is don on th sam connction, th connction will b dltd. Hold th Alt ky and click on EVENT nxt to th REQ vnt. Th cursor will chang and drag it ovr to IN1 or th BOOL nxt to IN1. Th data input IN1 is now connctd to th REQ vnt. Whnvr an vnt coms to REQ, IN1 will thn b rad and go through th basic function block. By using th sam mthod, connct th REQ vnt to 40

42 th IN2 data input and th CNF vnt to th OUT data output. Do not mak any data connctions with th INIT or INITO vnts. Whn finishd, th basic function block should look lik Figur 3.7. Figur 3.7 Function Block Data Connctd to Evnts Now that th data is connctd to th vnts for th basic function block, it is ncssary to st up an xcution control chart for th vnts. Stp 5: Excution Control Charts Whn vnts go into a basic function block, thr is an xcution control chart to dtrmin what happns nxt, what algorithms ar run, and what vnts should b outputtd. For xampl, if vnt A is rcivd, th chart will show that vnt A changs th stat of th function block from its initial stat (usually calld START) to a nw stat that causs a crtain algorithm to b activatd. Th xcution control chart displays all this and can b ditd to allow for diffrnt stats, vnts, and pathways. In Stp 3, it was dtrmind that th INIT and INITO vnts wr not ncssary. Whn Updat was clickd on that point, an rror appard. That is bcaus th dfault xcution control chart still had a stat, two transitions, and an algorithm assignd to INIT. Click on th ntry namd ECC on th lft sid of th scrn and th workspac will display th dfault xcution control chart. In ordr to dlt th INIT and INITO vnts, th stat, transitions, and algorithm assignd to INIT must b dltd. Right click on th box namd INIT, which rprsnts th stat INIT. Click on Dlt and click OK to dlt th stat, transitions with th stat, and any algorithms associatd with it. You can now go back to Intrfac and dlt th INIT and INITO vnts. Right click on th box namd REQ, slct Dlt, and click OK in ordr to mak an xcution control chart from scratch. Thr should now only b a singl box displayd that is namd START in th workspac. Th vnts for this basic function block ON_OFF_OC_B ar REQ and CNF. Thrfor, thr should b a stat REQ. Right click in th mpty workspac, click Nw, and slct Stat. A window will pop up to dfin th nw stat. Nam th stat REQ and giv a commnt to know what REQ stands for, such as Rqust Stat; click OK whn you ar finishd. To mak a stat th initial stat for th function block, click on th chck box markd Initial Stat. Howvr, th START stat alrady in th xcution control chart is th initial stat for th basic function block, so thr is no nd to assign a nw initial stat. Now this nw REQ stat, thr nds to b a transition to that stat. A transition 41

43 provids th mans that has th function block chang from on stat to anothr. Crating a transition rquirs holding th Alt ky, clicking on th sourc stat of th transition, and dragging th nw cursor to th dstination stat. Do so now with START as th sourc stat and REQ as th dstination stat. Transitions not only rquir a sourc and a dstination, but also a condition. This condition is th arrival of th vnt itslf, whnvr this vnt arrivs, this transition among stats will b mad. Th arrival of th REQ vnt will caus a transition btwn ths stats; thus, right click on th transition itslf, click on Edit, and a window will pop up allowing th transition condition to b changd. By dfault, th condition vnt is 1; click on th drop down mnu undr Evnt and slct REQ as th vnt condition. Click OK whn finishd assigning th nw vnt condition. This mans whnvr th vnt arrivs at REQ, th function block will go from th START stat (assuming it is in that stat to bgin with) to th REQ stat. Evntually, th basic function block should rturn to th initial stat to avoid rmaining th REQ stat whn thr is no REQ vnt. Crat a transition to rturn th function block to its initial stat. Hold th Alt ky, click on th sourc stat REQ, and drag th cursor to th dstination stat START. Aftr th REQ stat, th basic function block will always rturn to th initial stat. Thrfor, th condition for this transition should b 1. Th dfault condition for a transition is 1, so thr is no nd to dit it. That mans aftr th algorithm is run, th function block will always rturn to th START stat from th REQ stat. Now an algorithm must b dfind bfor assigning algorithms to vnt. Thr ar alrady two algorithms pr-dfind for th dfault basic function block, INIT and REQ. Doubl click on ach and slct Dlt to rmov ths algorithms. Click OK on th Algorithm window and thn click on th circl of arrows blow th list on th lft sid of th main scrn to updat th basic function block; th two algorithms in th list will thn b dltd. Now, to crat a nw algorithm namd REQ, which will b usd for th REQ stat. Right click on th mpty workspac, click on Nw, and slct Algorithm. A window will pop up to dfin a nw algorithm. Nam it REQ in th txt fild namd Nam. Undrnath Nam, thr is a list of four languags for this algorithm. Th four languags that can b usd for algorithms in basic function blocks ar structur txt (ST), function block diagrams (FBD), laddr logic (LD), and Java. Sinc Figur 3.1 has is a laddr logic diagram, w will us laddr logic (LD) to dfin th REQ algorithm. Whn finishd, th scrn should look lik Figur 3.8. Figur 3.8 Nw Algorithm Dfinition Window 42

44 Now that th algorithm nam and languag for th algorithm hav bn dfind, th REQ stat should hav its algorithm assignd to run whnvr th function block rachs th REQ stat. Th output vnt of th function block should also b fird at this stat. To do this, an action nds to b assignd to th REQ stat. An action assigns an algorithm to b run and/or an vnt to b outputtd whnvr th function block rachs a particular stat. Right click on th REQ stat, click on Nw, and slct Action. A window will pop up to dfin an algorithm and vnt for th action. Slct CNF as th vnt and REQ as th algorithm, click OK whn finishd. This mans onc th basic function block is in th REQ stat, th REQ algorithm will xcut, and th CNF vnt will b launchd in th nd. W do not nd an action for th START stat, sinc it is acting as an initial stat and thrfor dos not nd an algorithm or an vnt to output. If it is hard to s th transitions and stats, simply click and drag on th stats and transitions to mov thm. Th xcution control chart for ON_OFF_OC_B should look lik Figur 3.9 blow. Figur 3.9 Excution Control Chart of ON_OFF_OC_B Function Block Stp 6: Th REQ Algorithm Click on th REQ at th bottom of th list on th lft sid of th scrn and th workspac will bcom blank. Sinc th REQ algorithm was originally dfind to us laddr logic, th workspac will b usd to insrt, modify, and dlt th rungs for th laddr logic. This way, th laddr logic can b implmntd into th basic function block. For this tutorial, th laddr logic shown in Figur 3.1 will b implmntd in this algorithm. Right click on th mpty workspac, click on Nw, and slct Rung. A window will pop up to dfin th output of th rung and th xprssion of th rung. Th output of th function block is OUT, so th output of this algorithm should also b OUT. For th xprssion, th laddr logic has an opn switch calld Start and a closd switch calld Stop. Th two switchs ar in succssion, so both must b tru in ordr to yild an output. This function block has two Boolan inputs, IN1 and IN2. IN1 should rprsnt th opn switch calld Start and IN2 should rprsnt th closd switch calld Stop. Closd switchs (and othr NOT functions) can b codd by putting an xclamation mark (!) aftr th variabl. In this cas, th! is ndd for IN2 sinc it is a closd contact. To includ succssiv switchs in laddr logic, an amprsand (&) is usd aftr IN2. A spac must b btwn any charactrs and th variabl, othrwis th algorithm will not work proprly. Th xprssion, with th output, is shown in Figur 3.10 blow. 43

45 Figur 3.10 Laddr Logic Exprssion, Output, and Rung for Basic Function Block Th basic function block ON_OFF_OC_B now has th algorithm that follows th laddr logic rquird, an xcution control chart that will hav th algorithm b usd, and th ncssary vnts and data. Stp 7: Compiling Whil vrything ndd is now in th basic function block, ON_OFF_OC_B can not b usd yt. Th final stp is to compil this function block so it can b usd in othr programs. Earlir, th compilr was dfind as packag fb.rt.studnt;. This is whr th Java compilr with th program will chck for this fil and compil it. First, sav this ON_OFF_OC_B basic function block as Java. This can b don by going to th mnu bar and slcting Fil -> Sav As -> Java. Mak absolutly crtain th fil is savd in th alrady dfind dirctory. If, for som rason, th program dos not automatically tak you thr, it can b found by this pathway: fbdk -> lib -> fb -> rt -> studnt. Th nam of th function block will b savd with th xtnsion.java and automatically compild. A window will appar, shown in Figur 3.11, if th fil was succssfully compild. Figur 3.11 Java Succssfully Compild 44

46 As it says in th window for Figur 3.11, bfor using this basic function block, th program usd for making this basic function block must b closd. Sav th ON_OFF_OC_B basic function block as an XML fil so it has th propr.fbt xtnsion. Mak sur to sav th XML fil in th sam dirctory as your othr function blocks (suggstion: C:\fbdk\src\studnt). Now it can b usd lik any othr function block in any othr systm. Aftr following this tutorial, you hav succssfully cratd a basic function block. EXERCISE: Implmnt th basic function block ON_OFF_OC_B within th systm shown in Figur Figur 3.12 Exampl using Gnric Basic Function Blocks SOLUTION: Th propr implmntation of this function block is shown in Figur

47 Figur 3.13 Exampl Using Cratd Basic Function Block, ON_OFF_OC_B 3.3 Summary In summary, this tutorial has shown th following squntial stps for crating and using a basic function block. To crat a basic function block: 1. St th proprtis of th basic function block. 2. Dfin th compilr information for th basic function block. 3. Dfin th intrfac of th basic function blocks: vnts, data inputs, and data outputs. 4. Connct data inputs and outputs with corrsponding vnts. 5. Modify th xcution control chart to includ th stats of all vnts of th basic function block. 6. Dfin all th transitions btwn th stats in th xcution control chart. 7. Dfin th algorithms and thir languags. 8. Assign th vnt outputs and algorithms to ach stat undr Actions in th xcution control chart. 9. Dfin th algorithm and its output. 10. Sav th function block as a Java fil in th sam dirctory as th compilr. Th Java fil will b compild automatically. 11. Sav th basic function block as a XML fil. 12. Clos th basic function block ditor and it to a systm lik any othr function block. 46

48 IEC TUTORIAL 4: PUBLISH AND SUBSCRIBE FUNCTION BLOCKS 4.1 Introduction Th IEC standard is for distributd control. In tutorials 1 through 3 w hav programmd function block applications but hav not distributd thos applications ovr mor than on dvic. In this tutorial w show th us of multipl dvics in a ntwork. Th IEC standard includs function blocks for nabling communication among dvics in a ntwork. Th function block pair publish and subscrib ar usd whn dvics and thir rsourcs communicat with ach othr ovr a ntwork, such as Ethrnt, fild bus, Alln Bradly data highway, or similar. Th publish function block roughly corrsponds to th mssag snd (MSG) block in laddr logic. Th mssag snd transmits a word to an addrss in anothr nod (dvic, rsourc) on th ntwork. Th subscrib function block nabls a rad at th rcipint nod of th contnts of th addrss to which th mssag has bn transmittd. SITUATION: Thr is a smiautomatic drill prss that has two controllrs. Th first controllr (Dvic 1) runs a mastr panl with two buttons that control whthr th systm is on or off. On switch is Systm Start. Th othr switch is Systm Stop. Th scond controllr (Dvic 2) runs th oprating cycl of th drill prss. Th two controllrs must communicat with ach othr. Thrfor, th data coming from th mastr panl nds to indicat whthr th systm has bn startd or not. Dvic 1 can do this by latching an ON indicator bit whn th Systm Start switch is opn and th Systm Stop switch is closd, and unlatching that bit whn th Systm Start switch is closd and th Systm Stop switch is opn. Th status of that bit is thn snt to Dvic 2. A diagram of th drill prss and control panls is shown in Figur 4.1a. Th laddr logic for th mastr panl is shown blow in Figur 4.1b. Smiautomatic Drill Prss Opration: 1. Systm Start button (I1) turns th pilot light on. 2. A part to b drilld is placd undr th spindl by th oprator. 3. With a part in plac, th oprator must prss both th lft and th right start buttons simultanously. Th shild down solnoid (O2) is nabld. Start buttons must b hld down until shild is down. 4. Whn th shild is down, th drill spindl starts to rotat and th drill had coms down. Th downward forc is from an air cylindr (O4). 5. Whn th drill had is compltly down, LSDD snsor is activatd (I9). 6. Th activation of LSDD turns off th drill down solnoid, th shild down solnoid, and th drill motor. Th spindl automatically rturns to th up position and th shild is raisd. 7. If at any tim you hit a lft or right stop button, th oprating cycl should shut down. 8. If at any tim you hit th mastr panl stop button, th systm should shut down. 47

49 Mastr Panl Start Stop LSDD LSPP Shild Part LSSD Opration Panl LAMP Right Lft BASE Figur 4.1a Drill Prss Problm Systm Start I:1 1 Systm Stop I:1 2 Ntwork Snd MSG Rad/Writ Mssag Rad/Writ Writ Targt Dvic 500CPU Control Block N7:100 Control Block Lngth 7 Stup Scrn Ntwork Snd MSG Rad/Writ Mssag Rad/Writ Writ Targt Dvic 500CPU Control Block N7:100 Control Block Lngth 7 Stup Scrn ON Indicator Bit B3:0 L 0 EN DN ER ON Indicator Bit B3:0 U 0 EN DN ER 0002 END 48

50 Figur 4.1b Mastr Control Panl Laddr Logic (Dvic 1) Th controllr of th oprating cycl (Dvic 2) must rciv bit B3/0 and thn us it in conjunction with th logic of two closd switchs, Lft Stop and Right Stop. Ultimatly, it will control th pilot lamp. Th laddr logic for th first rung of Dvic 2 is shown blow in Figur 4.2. Figur 4.2 Laddr Logic of First Rung of Dvic 2 Crat a systm of function blocks that ralizs th abov logic. Us both publish and subscrib function blocks to control th communication of both controllrs. 4.2 Stps in Implmnting Publish and Subscrib Function Blocks Stp 1: Dfining Multipl Dvics. Bgin by crating a nw systm configuration and stting th proprtis. S Tutorial 1 for furthr dtails in doing so. Now, click on th ntry blow proprtis (th systm nam) to dit th ovrall systm. As don prviously in Tutorial 1, dit th first dvic to mak it a FRAME_DEVICE and nam it DEVICE_1. In prior tutorials, all of th ncssary function blocks and logic wr placd on on dvic having on rsourc. Howvr, for this tutorial, two sparat controllrs that communicat with ach othr ar ndd. Thrfor, thr nds to b two dvics with on rsourc ach. On dvic will b for th mastr panl, th othr for th oprations panl. Right click on th mpty workspac, click on Nw, and thn click on Dvic. A window will pop up allowing th nw dvic to b givn a nam and a dvic typ. Giv th nw dvic th nam 49

51 DEVICE_2, and st it as a FRAME_DEVICE. Two dvics will appar, similar to Figur 4.3. Figur 4.3 Establishing Two Dvics in a Systm As in Tutorial 1, ths dvics must hav thir boundaris dfind. Just for th sak of this tutorial, it would b good to hav both dvics appar nxt to ach othr. For th first dvic, us [100,100,150,150] for th Bounds and [1,1] for th Grid. For th scond dvic, us [250,100,150,150] for th Bounds and [1,1] for th Grid. Now whn th program is launchd latr, two windows of th sam siz will appar right nxt to ach othr. Bfor moving on, mak sur that ach dvic has on rsourc, and mak sur th rsourc typ is dfind as PANEL_RESOURCE. Stp 2: Stting Up For & Using Publish Function Blocks Th asist way to crat a systm involving both PUBLISH and SUSCRIBE function blocks is to start by stting up what nds to b publishd. Go into APP and insrt two IN_EVENT function blocks, call on Systm_Start and th othr Systm_Stop. Ths function blocks can b found in th dirctory fbdk-> src -> hmi; th sam dirctory as input and output Boolan function blocks. Ths two function blocks ar th buttons on th mastr panl. Now, as shown in Figur 4.1b, th data nds to b latchd. Insrt an E_RS function block, which will act as a latch. Latchs ar vnt drivn function blocks, all vnt drivn function blocks can b found in th dirctory fbdk -> src -> vnts. Insrt an OUT_BOOL function block to rprsnt th ON indicator bit. Call it Systm_On, th rason for that nam will b xplaind latr. Now, to rprsnt th logic of this part of th program, th Systm_Start function block sts th latch, whras th Systm_Stop function block unsts th latch. To do that, connct th IND vnt of th Systm_Start function block to vnt S of th E_RS function block and connct th IND vnt of th Systm_Stop function block to vnt R of th E_RS function block. Connct th data output Q to th IN data input of th OUT_BOOL function block to hav th OUT_BOOL function block work proprly. Connct th vnt EO of th latch to th REQ vnt of th OUT_BOOL function block. Th compltd logic is shown in Figur 4.4 blow. 50

52 Figur 4.4 Compltd Application program for Mastr Control Panl Now th function block diagram for th mastr panl is narly complt. This tutorial will us DEVICE_1 as th mastr panl, so map all of th blocks xcpt for th Systm_On function block to th rsourc in DEVICE_1. Connct E_RESTART to th first function block mappd to DEVICE_1 (this will probably b Systm_Start) to nsur that blocks with INIT vnts ar initializd. Now, th publish function block can b implmntd. Whil th data outputtd from th latch normally would go to an output function block, th scond dvic-th oprating panl-nds that data. As a rsult, this dvic will publish that data output. That is, this dvic will always tak th data coming from th latch availabl to any subscribrs-dvics that rad data from th publishr. Insrt a nw function block, th publishing (and subscribing) function blocks ar found through th dirctory path: fbdk -> src -> nt. Slct PUBL_1, sinc only thr is only on data input ncssary (SD_1) and th ntwork connction will b local. Nam this function block Pub1. Publish function blocks nd an IP addrss and a port so data can b writtn to a spcific addrss. It is important to mak sur th IP addrss and port usd is not usd by any othr dvics, othrwis data and mssags will gt caught up and com in conflict with othr data and mssags bing movd on that addrss and port. For this tutorial, th IP addrss and th port 0001 is usd to kp th data bing writtn to and rad from a local addrss. Mak th ncssary data and vnt connctions; th compltd mastr panl rsourc is shown in Figur

53 Figur 4.5 Mastr Panl Application Program with Ntwork Communication Stp 3: Using A Subscrib Function Block Go back to APP and map th Systm_On function block to th rsourc in DEVICE_2. Th rason why this function block is going to th othr dvic is to chck whthr th communication btwn th two rsourcs is succssful. Th output function block is calld Systm_On, sinc whnvr th Systm_Start button is prssd, that output rcivd from th mastr panl will b 1, rprsnting that th systm is on. If Systm_Stop is prssd, th output rcivd from th mastr panl will b 0, rprsnting that th systm is off. In DEVICE_1, th rsourc is outputting this data from th latch to a PUBL_1 function block. To rciv data from a publish function block, thr nds to b a subscrib function block. In th sam dirctory whr th publish function blocks ar locatd, insrt a SUBL_1 function block and nam it Sub1. Th publish function block has on data input bing writtn; thrfor, only on data output nds to b subscribd from th publishr. Exactly lik th publish function block, th subscrib function block nds an IP addrss and a port to rad data from. Mak absolutly crtain that th IP addrss and port dfind for th Subscrib function block is xactly th sam as th IP addrss and port dfind for th Publish function block. Othrwis, th SUBL_1 function block will not rciv th data from th PUBL_1 function block. Connct th data and vnts and th rsourc for th scond dvic should look lik Figur 4.6 blow. 52

54 Figur 4.6 Oprations Panl Rsourc with Ntwork Communication Stp 4: Complting th Systm Now, to complt th systm, th data that coms from th SUBSCRIBE_1 function block acts as an opn switch that coms in succssion with two closd switchs, Lft Stop and Right Stop. Insrt two IN_BOOL function blocks, calld Lft_Stop and Right_Stop, into th rsourc in DEVICE_2. If you hav compltd th Smiautomatic Drill Prss xampl, you should hav a composit function block that has th logic of two succssiv closd switchs calld AND_2_CC. If not, simply crat a nw composit function block with that nam. Th dtails on how to mak a composit function block ar in Tutorial 2. Mak sur th composit function block has th following intrfac and systm within it, shown in Figurs 4.7a and 4.7b. Lft: Figur 4.7a, AND_2_CC Intrfac; Right: Figur 4.7b, AND_2_CC Systm Sav and compil th AND_2_CC function block first as a Java fil and thn as a XML fil. If it is succssful, insrt th AND_2_CC function block and connct it with th two IN_BOOL function blocks. In this tutorial, ClosClos is th nam for th AND_2_CC function block. Th data that coms from th subscribr is in succssion with th two closd switchs, so th data output of AND_2_CC and th data from SUBSCRIBE_1 nds to b connctd with a FB_AND function block. In this tutorial, this FB_AND function block is namd And1. Th output of that function block should b connctd with th final output, th Pilot Lamp. Insrt an OUT_BOOL function block for th Pilot 53

55 Lamp (namd Pilot_Lamp) and mak th final connctions to complt th oprations panl. Th rsourc in DEVICE_2 should now look lik Figur 4.8. Figur 4.8 Compltd Application Program for th Oprations Panl Rsourc Now that th rsourcs in both dvics ar complt, launch th program. By prssing Systm Start, both lights will turn on. If you thn slct Lft Stop and/or Right Stop, th Pilot Lamp will turn off but th Systm On should b on. If you prss Systm Stop, both lights will turn off. 4.3 Summary This tutorial has shown th following squntial stps for basic us of publish and subscrib function blocks. Ths stps ar: 1. Crat a nw systm. 2. Dfin as many dvics and rsourcs as ncssary. 3. First program th function blocks that will yild th data that will b publishd. 4. Insrt th ncssary publish function blocks in rsourcs to publish th data. 5. Dfin a propr IP addrss and port for ach publish function block. 6. Insrt th subscribing function blocks in othr rsourcs. 7. Dfin th xact sam IP addrss and port as th publish function blocks for th subscribr function blocks to rciv th data bing publishd. 8. Using this data, program additional function blocks that may us this rcivd data. 54

56 IEC TUTORIAL 5: CLIENT AND SERVER FUNCTION BLOCKS 5.1 Introduction In addition to publish and subscrib function blocks, th IEC standard includs clint and clint function blocks. Similar to publish and subscrib function blocks, clint and srvr function blocks ar usd in ordr for rsourcs within dvics to communicat with othr rsourcs in othr dvics on a ntwork. What maks thm diffrnt is how th communication works. Th clint function block communicats with th srvr function block, but not with othr clint function blocks. Whn a clint function block rqusts information, th srvr function block rsponds by rciving and rturning data to th addrss of th clint function block. SITUATION: Thr is a smiautomatic drill prss that has two controllrs. Th first controllr acts as a mastr panl, two switchs that control whthr th systm is on or off. On switch is calld Systm Start, whn activatd, th systm will start. Th othr switch is calld Systm Stop. Whnvr Systm Stop is activatd, th ntir systm should stop in spit of th stat of othr switchs. Thr is a lamp on th mastr panl to indicat whthr th systm is on or not. Th scond controllr acts as an opration panl, complt with any inputs and outputs that affct th opration cycl, but not controlling th ntir systm. Th two controllrs must communicat with ach othr. Thrfor, th data coming from th mastr panl nds to indicat whthr th systm is on or not. It can do this by switching on th opn switch Systm Start, or by turning on th systm s lamp (th lamp acts as an opn switch). Th laddr logic for th mastr panl is shown blow in Figur Systm Start I:1 1 Lamp O:2 1 Systm Stop I:1 2 Lamp O:2 1 ON Indicator Bit B3: END Figur 5.1 Mastr Panl Laddr Logic Diagram Th controllr panl must rciv th ON Indicator Bit and will control th Pilot Lamp in conjunction with two closd switchs, Lft Stop and Right Stop. Whthr th Pilot Lamp is on or not will control whthr th Safty Down Solnoid is on in conjunction with th opn switchs Lft Start, Right Start, LSPP Part in Plac, LSSD Drill Down, and LSSD Shild Down. Th Safty Down Solnoid in conjunction with th LSSD Shild Down opn switch will control th Spindl Motor, which will ultimatly control th Drill Down Solnoid. Th laddr logic for th controllr is shown blow in Figur 5.2. (Not: 55

57 This is th xact sam laddr logic as sn in th Smiautomatic Drill Prss xampl. It is suggstd that you complt th xampl first in Tutorial 4, as this tutorial will only covr th usag of clint and srvr function blocks.) 0000 Enabl Pilot Lamp Systm On Indicator Lft Stop B3:0 I: Bring Safty Shild into Position LSPP Pilot Lamp Part in Plac O:2 I: Enabl Drill Motor Rotation Shild Down LSSD Solnoid Shild Down O:2 I: Mov Drill Down Spindl Motor O: Right Stop I:1 7 Lft Start I:1 4 LSSD Shild Down I:1 8 Mssag Gt MSG Rad/Writ Mssag Rad/Writ Rad Targt Dvic 500CPU Control Block N7:100 Control Block Lngth 7 Stup Scrn Right Start I:1 5 LSSD Drill Down I:1 9 EN DN ER Pilot Lamp O:2 1 Shild Down Solnoid O:2 2 Spindl Motor O:2 3 Drill Down Solnoid O: END 4 Figur 5.2 Laddr Logic of a Smiautomatic Drill Prss STEP 1: Dfin Dvics and Rsourcs Crat a nw systm and dfin thir proprtis, as don in Tutorial 1. Crat two dvics and dfin thm as FRAME_DEVICES. It may b usful to dnot on dvic as th mastr panl and th othr as th controllr panl. For configuring th dvics, DEV1 (th mastr panl) will hav th bounds [100,100,150,150] and a grid of [1,1]. DEV2 (th controllr panl) will hav th bounds [250,100,150,295] and a grid of [1,1]. 56

58 Onc finishd, mak sur ach dvic has on rsourc, both dfind as PANEL_RESOURCE. STEP 2: Stting Up & Using Clint Function Blocks Whn working with multipl rsourcs, it is somtims asir to just st up th application within th rsourcs thmslvs as opposd to using APP1 and thn mapping ach function block to th propr rsourc. It is asir to chck whthr th systm works proprly, sinc launching th systm only carris out what is in th rsourcs and dvics. Mor apt to this tutorial, it is asir to focus on using a clint function block. As mntiond arlir, clint function blocks only communicat with th srvr function block. Not just rciving information from th srvr, but also assigning information to th srvr. For this tutorial, th ON Indicator Bit is going to b communicatd btwn th two dvics, so th clint and srvr function blocks will b passing that information btwn ach othr. On its own, a srvr function block dos not hav any information, which is why a clint function block (or othr function blocks in that rsourc) must assign data to it. Thrfor, data from th mastr panl acts as th clint and th controllr panl acts as th srvr. It will not work if th rols ar rvrsd. Go into RES1 in DEV1 and insrt function blocks to accomplish th laddr logic shown in Figur 5.1. Idally, two IN_BOOL function blocks will b usd for th switchs; and a FB_AND function block, a FB_OR function block, and a FB_NOT function block will accomplish th logic of th systm. Not that unlik Tutorial 4, th lamp is not bing latchd. Th mastr panl, without th mans for communication, is shown in Figur 5.3 blow. Figur 5.3 Application of Mastr Panl Rsourc 57

59 Launch th systm and chck to s if th systm works; th light namd lamp should turn on whn Systm Start is chckd on (you may nd to chck ach input, somtims it dos not work right away). Now th clint function block can b addd to this rsourc. As with th publish and subscrib function blocks, th clint function blocks can b found by following dirctory path: fbdk -> src -> nt. For this tutorial, load up th CLIENT_2_1 function block, call it Clint, and insrt it into th rsourc for th mastr panl. Th CLIENT_2_1 function block, unlik a publish function block, contains both data inputs and data outputs. This particular function block allows for two data inputs, which will b rad and snt th srvr at th spcifid addrss whn thr is a REQ vnt. Data on th corrsponding srvr (ithr rad into or stord on it) can b outputtd through th singl data output. Thr ar multipl clint function blocks with varying amounts of data inputs and outputs. Howvr, for this tutorial, th mastr panl only nds to output th OUT Indicator Bit to th controllr panl. Thrfor, only a singl data input of th Clint function block will b usd. Connct th OUT data output of th And function block to th SD_1 data input of th Clint function block. Connct th CNF vnt of th FB_AND function block to th REQ vnt of th Clint function block, and connct th INIT vnt of th Clint function block from th INITO vnt of th Lamp function block. Onc th vnt and data connctions ar finishd, assign 1 to th QI of th Clint function block. Right click on th Clint function block to configur it and giv it th ID localhost:1499. An IP addrss is unncssary sinc this will run on a solitary computr is th port that will b usd for transfrring data. Th mastr panl rsourc should look lik Figur 5.4 blow. Figur 5.4 Mastr Panl Rsourc with Ntwork Connction 58

60 STEP 3: Stting Up & Using Srvr Function Blocks Now th mastr panl dvic is complt and th controllr panl dvic must b st up. Th mastr panl dvic usd a CLIENT_2_1 function block, and sinc clint function blocks only communicat with corrsponding srvr function blocks, th controllr panl must hav a srvr function block. In th sam dirctory as th clint function blocks, load and insrt a SERVER_1_2 function block and call it Srvr. Just lik th CLIENT_2_1 function block, th SERVER_1_2 function block has both data inputs and data outputs. If thr is data coming into data input of th Srvr function block, th Srvr function block will snd that data to Clint function blocks that rqust data. Data that coms to th srvr can b outputtd through its data outputs. For this tutorial, thr is no nd to snd any information to th Clint function block as th CLIENT_2_1 function block is snding th ON Indicator Bit data. Thrfor, only on data output nds to b usd. Configur th SERVER_1_2 function block and giv it th sam ID as th CLIENT_2_1 function block. Th ID for both th Clint and th Srvr must b th sam; othrwis thr will b no communication btwn th two dvics. Also mak sur to assign 1 to th QI data input of th SERVER_1_2 function block and connct it with th E_RESTART function block in th rsourc. Whn finishd, th controllr panl rsourc should look lik Figur 5.5. To chck whthr th two dvics will communicat proprly, insrt an OUT_BOOL function block into th rsourc in DEV2. If th communication works proprly, both th Lamp and Chck (th nam for this OUT_BOOL function block) will turn on whn Systm Start is prssd; both will turn off whn Systm Stop is prssd. Configur th function block, assign QI th paramtr of 1, and connct it with th SERVER_1_2 function block. Sav th systm and thn go to th mnu bar, click on Run, click on Launch, and click on th systm nam. Figur 5.5 Controllr Panl Rsourc with Ntwork Communication Whn th Systm Start chck box is chckd on, both th Lamp and th Chck should both turn on (turn rd, in this cas). Whn Systm Stop is chckd on, thy should turn off (turn black, in this cas). If this occurs, th communication btwn th two dvics is working. 59

61 At this point, you can dlt th connctions and th OUT_BOOL function block usd for tsting th communication btwn th two dvics. Now th rst of th controllr panl s logic can b fulfilld. As mntiond arlir, this logic is th sam as th Smiautomatic Drill Prss xampl. If you hav not don that xampl, it is advisd that you go complt th xampl. If you hav compltd that xampl, simply copy what was don in that xampl into th scond rsourc xcpt for th Systm Start, Systm Stop, and Control1 function blocks as th SERVER_1_2 function block rplacs thos thr function blocks. Connct th SERVER_1_2 function block to that systm of function blocks to complt th controllr panl. Figur 5.6 shows how that is accomplishd. Only a part of th controllr panl logic in th rsourc in DEV2 is shown in Figur 5.6 with th SERVER_1_2 function block. Figur 5.6 Application of Controllr Panl Logic with Ntwork Connction Onc th connction is mad, sav th systm, and launch it to s if it works proprly. If th systm don for th Smiautomatic Drill Prss xampl is corrct and usd hr, thn it should work proprly sinc th communication btwn th two dvics alrady works. 60

62 5.3 Summary This tutorial has shown th following squntial stps for basic us of clint and srvr function blocks. To dsign a systm that uss clint and srvr function blocks. 1. Crat a nw systm. 2. Dfin as many dvics and rsourcs as ncssary. 3. First program th function blocks that will yild th data that th clint will snd. 4. Insrt th CLIENT function blocks in rsourcs to snd and rciv th dsird data. 5. Dfin a propr IP addrss and port for ach CLIENT function block. 6. Insrt th SERVER function block in othr rsourcs or dvics. 7. Dfin th xact sam IP addrss and port as th CLIENT function blocks for th SERVER function block to rciv th data from th clints and snd data right back. 8. Using this data, program additional function blocks that may us this rcivd data. 61

63 IEC TUTORIAL 6: ADDING JAVA CODE TO A FUNCTION BLOCK 6.1 Introduction Whn crating basic function blocks, it is important to input a propr algorithm so it can prform th dsird action. In som cass it is ncssary to program th algorithm in a high lvl programming languag. Th Holobloc softwar supports programming in Java. This lsson will provid an xampl on how to incorporat a Java algorithm into a function block. SITUATION: An Automatd Guidd Vhicl (AGV) is an autonomous matrials handling dvic that travls on a guidd path, calld a ntwork. Figur 6.1 shows a ntwork of 9 nods that ar connctd by links. Links ar idntifid by nod labls. For xampl, link 12 is th link btwn nods 1 and Figur 6.1 Automatd Guidd Vhicl Ntwork Information on th status of a link is kpt in a databas tabl. Th databas is namd TC_DB and th tabl, shown in Figur 6.2, is calld LINK_STATUS. Th tabl has two filds. LINK_ID is th link idntification and L_STATUS indicats whthr th link is currntly occupid by an AGV (1) or is not occupid (0). Th objctiv of th xrcis is to crat a function block that will tak an inquiry about th status of a particular LINK_ID and rturn th currnt L_STATUS of th spcifid link. (Not: This tutorial assums th valus in LINK_ID ar in th databas as a numbr data typ, spcifically as an intgr. Othrwis, mor modification to th final Java cod will b ncssary to gt th final program to work proprly.) LINK_ID L_STATUS LINK_ID (Numbr, Long Int.) L_STATUS (Numbr, Long Int.) 62

64 LINK_ID L_STATUS Figur 6.2 LINK_STATUS Tabl This xrcis will illustrat an important function in a distributd systm, i.., prforming a databas qury. Such a function is usually codd in a high lvl languag. Thrfor, this xampl is an appropriat vhicl to illustrat th us of a Java algorithm within a function block. Crat a basic function block that accomplishs thos tasks and implmnt it into a systm. Th usr should b abl to input a LINK_ID and thr should b an output L_STATUS. For this w will us txt boxs. In addition th systm should b controlld by a momntary contact button such that, whn it is toggld on, th function block (which w shall call TC_Agnt) will rad from th databas. 6.2 Stps to Add Java Cod to a Function Block Stp 1: Stting Up th Framwork Controlling th Systm Th first thing w ar going to do is to stablish th framwork for inputting rquirmnts to th TC_AGENT function block and displaying th output from th function block. Latr w will dsign th TC_AGENT function block and mbd it within th framwork. Start a nw systm configuration and giv it a nam such as TC_AGENT_1. Complt th Vrsions information and configur th dvic as a singl rsourc dvic. Configur DEV1 as a FRAME_DEVICE and RES1 as a PANEL_RESOURCE as don in th prvious tutorials. Do not forgt to dfin th bounds and grid paramtrs for th dvic (us any valus you wish, thy can b asily ditd in th futur). For this systm, a button (an IN_EVENT function block) will control whn th TC_AGENT will prform its function. Thrfor, in th application diting window, insrt in an IN_EVENT function block. Th IN_EVENT function block can b found using th following dirctory path: src -> hmi Labl it BUTTON. For th txt input for th LINK_ID, load and insrt an IN_ANY function block. Labl it LINK_IN. Thr xists a function blocks for txt inputs and txt outputs, but th advantag to using IN_ANY (and OUT_ANY) function blocks is that th typ of data that coms in or coms out can dfind as any data typ without. For this lsson, configur th IN_ANY function block as WSTRING data typ, but it can just as asily b 63

65 REAL or STRING or any othr typ. Givn that all of th LINK_ID valus hav two digits (s Figur 6.2), dfin W as 2. W rprsnts th width of th txt box for th input. By making it 2 thr will b a limit as to how many charactrs (or digits in this cas) you can typ in. Sinc th input is an IN_ANY function block, insrt an OUT_ANY function block and dfin th typ as WSTRING. Labl it LINK_OUT. Thr is no nd, howvr, to dfin a width for th txt box for th output. Th IVAL configuration itm is for an initial valu. By laving it blank, th initial valu dfaults to NULL. Evntually a basic function block will b cratd to rprsnt th TC_AGENT that will tak a LINK_ID from th IN_ANY function block and output L_STATUS to th OUT_ANY function blocks. Th IN_EVENT function block will control whn th inputtd txt from th IN_ANY function block will go into th TCAGENT basic function block and thn onto th OUT_ANY function block. Connct th function blocks as shown in Figur 6.3a. This will allow us to tst th basic framwork. Mak sur that th QI input is st qual to 1 for ach function block to mak sur thy will all fir. Map th application to DEV1.RES1, assuming that th framwork was not dirctly programmd in th rsourc. Mak sur to connct th COLD vnt output of E_RESTART to th INIT vnt input of BUTTON, and run th application. By ntring a link in th LINK_ID txt box and clicking on th ON/OFF momntary contact button, an idntical string should appar in th LINK_OUT txt box. This is shown in Figur 6.3b. Figur 6.3a Framwork Connctd for Tsting Figur 6.3b Tsting Panl for Function Block Framwork 64

66 Stp 2: Crating th TCAGENT Basic Function Block Sav th systm configuration (framwork) for TC_AGENT_1. Th nxt stp is to crat a nw basic function block for TC_AGENT. Th procdur for doing so follows closly that of Tutorial 3, xcpt hr w will us Java as th languag for th algorithm. This tutorial will continu with th assumption that Tutorial 3 has bn compltd. If not, it is highly rcommndd that Tutorial 3 should b compltd bfor moving on, as it will dmonstrat stp by stp how to crat a nw function block. At th mnu bar, click on Fil -> Nw -> FB Typ -> Basic FB to crat a nw Basic Function Block. Nam this function block TC_AGENT and input th propr vrsion information. For th Compilr Info, dfin th hadr as packag fb.rt.rutgrs.b1;. If such a dirctory dos not xist, ithr chang th nam of th dirctory (.g. if you wish to us th studnt dirctory alrady within th FBDK dirctory, chang th hadr to packag fb.rt.studnt) or crat th sub dirctoris rutgrs and b1 within th rt dirctory. Bfor continuing on, mak sur to input th propr information also for Compilrs. Th TC_AGENT function block will not rquir INIT and INITO vnts; it will also not nd th data input QI and th data output QO. First, dlt th two data inputs. Thn, click on th xcution control chart for th function block and dlt th INIT stat and click OK to dlt any connctions with it. Aftrwards, dlt th INIT algorithm by doubl clicking on th INIT algorithm on th lft sid of th scrn and slct Dlt. Aftr complting all of this, dlt both th INIT and INITO vnts. Go back to th Intrfac ntry and right click on th function block to crat a nw data input and a nw data output. Mak sur both variabls hav th data typ WSTRING. Whil th function block ditor has a data typ calld STRING, it is not th sam as th String data typ in Java. Sinc it is compatibl with th String data typ in Java, WSTRING is th appropriat data typ. Nam th data input, INPUT, and th data output, OUTPUT. Connct th REQ vnt with th INPUT data input and connct th CNF vnt with th OUTPUT data output. Th basic function should now look lik Figur 6.4. Figur 6.4 Partially Configurd TC_AGENT Function Block For th xcution control chart, th only chang that nds to b mad is th algorithm. Doubl click on th REQ algorithm on th list to th lft and slct Java as th languag. Do not put anything into th REQ algorithm, lav it blank for now. Evrything should b compltd and th xcution control chart should look lik Figur 6.5 blow. 65

67 Figur 6.5 Excution Control Chart Evrything that had to b don to configur TC_AGENT function block is now complt. Sav th TC_AGENT function block as a Java fil in th dirctory spcifid for th Compilr Info hadr. Whil no algorithm has bn addd yt, th fil should b compild succssfully. Sav th TC_AGENT function block as a XML fil, and thn xit th function block ditor. Opn up th function block ditor and opn th systm configuration TC_AGENT_1 and insrt th TC_AGENT function block into th workspac (us any nam for th function block, hr it will b calld CONTROL). Connct th TC_AGENT function block with th LINK_IN as its input and LINK_OUT as its output. Th framwork is now fully compltd; it should look lik Figur 6.6. Sav th framwork and clos th softwar. Figur 6.6 Framwork with TC_AGENT Basic Function Block Stp 3: Editing th TC_AGENT Algorithm Part I Whn th Java fil was savd, it was savd into th sam fil path as dfind in th packag. To find th fil, assuming th packag fb.rt.rutgrs.b1; was dfind as th hadr, follow th fil path C:\> fbdk -> lib -> fb -> rt -> rutgrs-> b1. Opn up th b1 foldr for all fil typs and you can s th Java fil and class for TC_AGENT. Opn up th TC_AGENT.java fil by right clicking on th fil nam, click on Opn With, and slct Notpad. With Notpad, th Java cod writtn for th basic function block TC_AGENT can b ditd. Notic th cod alrady in th fil. It rprsnts th vnts, data, and connctions programmd for this function block typ. Scroll all th way down to th nd of th fil and you will find th following lins, shown in Figur 6.7 blow. 66

68 Figur 6.7 Java Cod for REQ Algorithm within TC_AGENT In btwn th brackts is whr th cod for th REQ algorithm would go if cod was ntrd into th larg txt spac at th bottom of th REQ algorithm window. Whn crating th basic function block, nothing was put in for th algorithm. At this point, w can dvlop our own cod and hav th function block call othr Java fils. For rading a databas, thr must b a modul that actually prforms th rading function as wll as a modul that controls connctions to th Agnt databas. To accomplish this, considr th following list of Java moduls calld. TCAGENT.java is th main program which will call: A modul which will rad from a databas. To do this, it will call: o A modul which will connct and disconnct th databas from th Rad modul. That will rquir: Th Agnt databas, that nds to b dfind. Th bst way to accomplish this is to work from th bottom of th list and up. That way no important stps such as dfining th databas ar missd. Furthrmor, th moduls that will b calld in othr programs will alrady b writtn and hav spcific nams to b calld by so thy can b usd again. Stp 4: Dfining a Databas First, mak sur you hav a databas st up in Accss calld Agnt with a tabl calld LINK_STATUS. In that tabl thr should b th data givn in Figur 6.2. Sav it to th sam dirctory as th TC_AGENT.java fil. For Java fils to call othr Java fils or othr programs, thy nd to b in th sam dirctory or hav thir xact dirctory path dfind othrwis thy will not b found. In ordr to us a databas in Java programs, th databas nds to b dfind with a data sourc nam. Othrwis, it will not b rcognizd by any program that tris to opn or clos a connction to th databas. Undr Control Panl on th computr, thr should b an icon for Administrativ Tools. Click on it and thn click on Data Sourcs (ODBC). A window will appar with a sris of tabs. For this cas, only b concrnd with Usr DSN. Click on Add to add anothr data sourc. Slct Microsoft Accss Drivr (*.mdb) and click on Finish. Nam th databas sourc Agnt or th nam of th databas itslf. Click on Slct, locat th targt databas, and slct it to dfin th location of th databas. Click on OK whn finishd, which will rturn you to th ODBC Microsoft Accss Stup. To finish th procss, click on OK. Onc finishd, th window undr th Usr DSN tab should look lik Figur 6.8 blow. Click on OK to clos th ODBC Data Sourc Administrator. 67

69 Figur 6.8 Data Sourc Nam Window Stp 5: Adding Moduls Onc th databas has bn dfind, now a Java program can b writtn that will us it. Start with th program that will opn and clos a connction th Agnt databas. This fil will b vital, as opning a connction to th Agnt databas will allow its contnts to b rad by othr programs. Opn up a nw fil in Notpad and immdiatly slct Sav As, chang th fil typ to All Fils, and sav th fil as ConnctToDataBas.java. Th fil typ must b listd as All Fils to nsur that th fil is savd as a Java fil and not a txt fil. By including th.java xtnsion, it will automatically b dfind as a Java fil. Sinc this fil will b calld by anothr fil which will b calld by th TC_AGENT.java fil, sav it in th sam dirctory as th TC_AGENT.java fil. Just lik with th databas, th Java fil nds to b in th sam dirctory so th fil calld can b found and b usd whn th program runs. Howvr, unlik th databas, you absolutly nd to includ th compilr information for th function block that will call it as th first lin of th Java fil. Thrfor, insrt packag fb.rt.rutgrs.b1; without th quots as th first lin of cod for ConnctToDataBas.java. Now you can program th rst of th cod to opn and clos a connction to a databas fil. Th dtaild cod for ConnctToDataBas.java is in sction 6.4.A. Whn finishd, do not forgt to sav ConnctToDataBas.java. It is a good ida to chck for any syntax or othr rrors in th program bfor moving on. Compil th ConnctToDataBas.java fil with th Java compilr installd on your computr. Onc th ConnctToDataBas.java fil is complt, crat a nw Java fil in Notpad for th modul that will rad from th Agnt databas. Sav it as Rad.java in th sam 68

70 dirctory as th TC_AGENT.java fil, ConnctToDataBas.java fil, and th TC_DB databas. Now writ th cod for Rad.java. Do not forgt that this modul must call th ConnctToDataBas modul and it must hav its first lin b packag fb.rt.rutgrs.b1; without th quots. Th complt cod for Rad.java is in sction 6.4.B. (Not: In sction 6.4.B, notic that th Rad modul s input is an intgr and th output is a string. Sinc th TC_AGENT function block s input and output ar strings, you may want to mak som altrations to th cod givn in sction 6.4.B.) If an rror occurs compiling th Rad modul, thn it is ncssary to writ th TC_AGENT.java fil-whr it should compil corrctly aftrwards. Stp 6: Editing th TC_AGENT Algorithm Part II Now that th Rad.java and ConnctToDataBas.java fils ar cratd and in th sam dirctory as th TC_AGENT.java fil, now th cod can b writtn for th REQ algorithm for th TC_AGENT basic function block. Th fbdk softwar dos not hav its own compilr; thus, any Java cod that is in th algorithm must b insrtd into th txt spac providd in th algorithm window, which will b compild whn th Java fil is savd. Cod can not b inputtd into th rsulting Java fil in Notpad; it will not b thr whn th Java fil is savd again in th fbdk softwar. Thrfor, opn th fbdk ditor, load th TC_AGENT function, and doubl click on th REQ algorithm at th bottom of th list on th lft. Now th cod can b writtn in th larg txt spac at th bottom of th window that will pop up from doubl clicking on th REQ algorithm. This cod will tak th data coming into th function block, call th Rad modul, which will call th ConnctToDataBas modul, chck for th corrsponding L_STATUS for th inputtd LINK_ID, and output that L_STATUS from th function block. All that is ncssary to do this is to quat a variabl to th INPUT.valu (th valu of th data coming into th INPUT data input), call th Rad modul (which will tak car of vrything but th output), and quat th OUTPUT.valu (th valu of th data that will com from th OUTPUT data output) from a string variabl. Mak sur that th lin that calls th Rad modul is put in at th bginning of th program, just aftr th first opn brackt undr th class dfinition. Th complt, dtaild cod for th REQ algorithm of th TC_AGENT is shown in sction 6.4.C. Sav th TC_AGENT function block again as a Java fil and it will b compild automatically. Any rrors in ithr of th TC_AGENT.java, Rad.java, or ConnctToDataBas.java fils will b found and th program will tll you whr th problm is. Th rason why rrors in ths othr moduls ar also found whn compiling TC_AGENT is bcaus whn TC_AGENT is run, thos othr moduls ar calld. If thy hav rrors, thn TC_AGENT will not work at all. If thr ar no rrors, sav th TC_AGENT function block as an XML fil. Clos th program to nsur that th TC_AGENT function block works with th most rcnt Java class fil whn usd. Start th program and load th TC_AGENT_1 systm configuration, chck to mak sur th framwork is in ordr, and run th program. Tst th program by typing in 12 in th input txtbox and thn clicking on th On/Off chckbox. If 0 coms up in th othr txtbox, thn th program works. 69

71 EXERCISE: If you insrt a numbr that is not in th databas for LINK_ID or a lttr in th input txtbox, nothing will chang or nothing will appar in th output txtbox. By chcking th corrsponding cmd.x window, thr will b th lin java.lang.numbrformatexcption: null. Whil it is not wrong, it dos not dirctly tll th usr that thr is an rror. Edit th Rad.java and TCAGENT.java fils in a way such that whnvr a numbr not in th databas or a lttr is typd in, th output txtbox yilds th word Error. 6.3 Summary This tutorial has shown th following squntial stps to implmnt Java cod and moduls with function blocks. To implmnt Java cod with function blocks: 1. Crat a nw basic function block and st up th ncssary proprtis, intrfac, and xcution control chart. 2. Dfin th algorithm(s) as Java languag. 3. Whn finishd stting up th basic function block, sav it first as a Java fil and compil it. Sav it as an XML fil aftrwards. 4. Dfin any databass or othr fils that th Java program will gt and rciv any information from. Mak sur thy ar savd in th sam dirctory as th Java fil. 5. Opn up th dirctory whr th Java fil was savd and opn up th Java fil in Notpad (or any othr applicabl Java-diting program). 6. Writ any Java moduls and programs that th function block will us. You may choos to compil ach fil sparatly to chck for any rrors. 7. Sav any moduls and programs with th xtnsion.java undr th fil typ All Fils. 8. Writ th Java cod within th function block for th algorithm(s) by doubl clicking on th algorithm nam on th lft sid of th scrn and inputting th Java cod into th txt box at th bottom of th algorithm s window. 9. Sav and ovrwrit th Java fil for th function block, th Java fil will automatically b compild. 10. Implmnt th function block in a systm and run it to tst if it works. If not, you may hav to modify th Java cod, which will rquir rstarting th function block ditor program and r-compiling th fil. 70

72 6.4.A Cod for th Modul ConnctToDataBas.java packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; public class ConnctToDataBas{ protctd Connction connction; public void opnconnction(){ try{ Class.forNam("sun.jdbc.odbc.JdbcOdbcDrivr"); String url ="jdbc:odbc:agnt"; connction = DrivrManagr.gtConnction(url); catch(classnotfoundexcption cnf){ Systm.rr.println(cnf); catch(sqlexcption sql){ Systm.rr.println(sql); public void closconnction(){ if(connction!= null) try{ connction.clos(); connction = null; catch(sqlexcption sql){ Systm.rr.println(sql); 71

73 6.4.B Cod for th Modul Rad.java packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; class Rad xtnds ConnctToDataBas{ public String rad_databas(int poll){ try{ opnconnction(); Statmnt statmnt = connction.cratstatmnt(); String qury = "slct L_STATUS from LINK_STATUS whr LINK_ID = " + poll; RsultSt rs = statmnt.xcutqury(qury); if(rs.nxt()){ String rsult = rs.gtstring("l_status"); closconnction(); rturn rsult; ls{ rturn null; catch(sqlexcption sql){ rturn null; public static void main(string[] args){ Rad r = nw Rad(); Systm.out.println(r.rad_databas(12)); 72

74 6.4.C Cod for th Function Block Java Fil TCAGENT.java REQ Algorithm int in = 0; try{ in = Intgr.parsInt(""+INPUT.valu); catch(numbrformatexcption ){ Systm.rr.println(); Rad raddb = nw Rad(); try{ int out1 = Intgr.parsInt(radDB.rad_databas(in)); String out2 = Intgr.toString(out1); OUTPUT.valu = out2; CNF.srvicEvnt(this); catch(numbrformatexcption 1){ Systm.rr.println(1); 73

75 IEC TUTORIAL 7: DESIGNING DATABASE QUERY FUNCTION BLOCKS 7.1 Introduction Crtain situations rquir th us of a databas within a function block s algorithm. Howvr, th function block ditor program dos not hav a function block availabl that works with databass. As a rsult, function blocks must b mad that conncts to th databas and runs commands using it. This was don in Tutorial 6. Howvr, th databas, th tabl, and th conditions usd in that tutorial wr codd dirctly into th function block. Th function block dos not account for situations whr thr ar othr or multipl databass that ar usd-th on cratd in Tutorial 6 only works with th databas TC_DB. Th function block dos not qury th usr for a databas that may b somthing othr than Agnt. This lsson will provid an xampl on how to mak a function block that quris a databas that th usr dfins within th function block. SITUATION: An Automatd Guidd Vhicl (AGV) is an autonomous matrials handling dvic that travls on a guidd path, calld a ntwork. Figur 7.1 shows a ntwork of 9 nods that ar connctd by links. Links ar idntifid by nod labls. For xampl, link 12 is th link btwn nods1 and Figur 7.1 Automatd Guidd Vhicl Ntwork Information on th status of a link is kpt in a databas tabl. Th databas is namd Agnt and th tabl, shown in Figur 7.2, is calld LINK_STATUS. Th tabl has two filds. LINK_ID is th link idntification and L_STATUS indicats whthr th link is currntly occupid by an AGV (1) or is not occupid (0). Th objctiv of th xrcis is to crat a function block that will tak an inquiry about th status of a particular LINK_ID and rturn th currnt L_STATUS of th spcifid link. LINK_ID L_STATUS LINK_ID (Numbr, Long Int.) L_STATUS (Numbr, Long Int.) 74

76 LINK_ID L_STATUS Figur 7.2 LINK_STATUS Tabl This xrcis will prform a databas qury with variabls for th databas, tabl, and conditions as opposd to static figurs for ach. A high lvl programming languag is ncssary to accomplish this. A Java algorithm will b usd within th function block as a rsult. Crat a basic function block calld DB_SELECT_1 that accomplishs th task rcognizing and rading from a databas that th usr dfins. Th usr should b abl to input a LINK_ID and thr should b an output L_STATUS. For this w will us txt boxs. To dfin th databas, th usr will provid th nam of th databas that will b usd, th tabl within that databas, and th SELECT and WHERE conditions usd to rtriv th L_STATUS. In addition, th systm should b controlld by a momntary contact button such that, whn it is toggld on, th function block will rad from th databas. 7.2 Stps in Crating a Databas Qury Function Block Stp 1: Stting Up th Framwork Controlling th Systm Th first thing w ar going to do is to stablish th framwork for inputting rquirmnts to th DB_SELECT_1 function block and displaying th output from th function block. Latr, th DB_SELECT_1 function block will b cratd, dsignd, and vntually mbddd within th framwork. Start a nw systm configuration and giv it a nam such as DB_Slct. Complt th Vrsions information, dfin th dfault dvic DEV1 as a FRAME_DEVICE, and dfin th rsourc within DEV1 as a PANEL_RESOURCE calld RES1. Do not forgt to dfin th bounds and grid paramtrs for th dvic (thr is no spcific siz ncssary). For this systm, a button (an IN_EVENT function block) will control whn th DB_SELECT_1 function block will prform its function. Thrfor, in th application diting window, insrt in an IN_EVENT function block. Labl it On_Off. For th txt input for th LINK_ID, insrt an IN_ANY function block and nam it Input. Configur th IN_ANY function block as WSTRING data typ, sinc th inputtd information will b a string. Whil th function block ditor has a data typ calld STRING, it is not th 75

77 sam as th String data typ in Java. Sinc it is compatibl with th String data typ in Java, WSTRING is th appropriat data typ. Givn that w know that all of th LINK_ID valus hav two digits (s Figur 7.2), st W as 2. Sinc th input is an IN_ANY function block, insrt an OUT_ANY function block into th workspac. Nam this function block Output and dfin th typ as WSTRING. Thr is no nd, howvr, to dfin a width for th txt box for th output. Thr is also no nd to dfin an initial valu for ithr of th IN_ANY and OUT_ANY function blocks. Do not forgt to assign 1 to all thr function block s QI data input to mak sur thy will all function proprly whn th program is run. Evntually, a basic function block will b dvlopd to rprsnt th DB_SELECT_1 that will tak a LINK_ID from th IN_ANY function block and output L_STATUS to th OUT_ANY function blocks. Unlik in Tutorial 6, th usr will hav to assign to th function block th databas (Agnt), th tabl (LINK_STATUS), and th conditions to gt th information (L_STATUS, LINK_ID). Th IN_EVENT function block will control whn th inputtd txt from th IN_ANY function block will go into th DB_SELECT_1 basic function block and thn onto th OUT_ANY function block. Connct th function blocks as shown in Figur 7.3a. This will allow us to tst th basic framwork. Map th application to DEV1.RES1. Go to RES1, connct th COLD vnt output of START to th INIT vnt input of BUTTON, and run th application. By ntring a link in th Input txt box and clicking on th On/Off momntary contact button, an idntical string should appar in th Output txt box. This is shown in Figur 7.3b. Figur 7.3a Framwork Connctd for Tsting Figur 7.3b Tsting Panl for Function Block Framwork 76

78 Stp 2: Crating th DB_SELECT_1 Basic Function Block Sav th systm configuration (framwork) for DB_Slct. In this sction w ar going to dfin a nw basic function block calld DB_SELECT_1. Th procdur for doing so follows closly that of Tutorial 3, xcpt that th algorithm will b writtn in Java. This tutorial will continu with th assumption that Tutorial 3 has bn compltd. If not, it is highly rcommndd that Tutorial 3 should b compltd bfor moving on, as it will dmonstrat stp by stp how to crat a nw function block. At th mnu bar, click on Fil -> Nw -> FB Typ -> Basic FB to crat a nw Basic Function Block. Nam this function block DB_SELECT_1 and input th propr vrsion information. For th Compilr Info, dfin th hadr as packag fb.rt.rutgrs.b1;. If such a dirctory dos not xist, ithr chang th nam of th dirctory (.g. if you wish to us th studnt dirctory alrady within th FBDK dirctory, chang th hadr to packag fb.rt.studnt) or crat th sub dirctoris rutgrs and b1 within th rt dirctory. Bfor continuing on, mak sur to input th propr information also for Compilrs. Th DB_SELECT_1 function block will not rquir INIT and INITO vnts; it will also not nd th data input QI and th data output QO. First, dlt th two data inputs. Thn, click on th xcution control chart for th function block and dlt th INIT stat and click OK to dlt any connctions with it. Aftrwards, dlt th INIT algorithm by doubl clicking on th INIT algorithm on th lft sid of th scrn and slct Dlt. Aftr complting all of this, dlt both th INIT and INITO vnts. For th DB_SELECT_1 function block, 5 data inputs and a singl data output ar ncssary. Go back to th Intrfac ntry and right click on th function block to crat a nw data input. All of th data inputs and th data output for DB_SELECT_1 will work with th data typ WSTRING; b sur to dfin WSTRING as th data typ for all data. Crat th first data input and nam it DB; this data input will control which databas is bing usd. Crat a scond data input, and nam it TABLE. This data input will spcify which tabl in th databas th function block will us. Crat a third data input namd SELECT_Attribut, which spcifis th column in th databas tabl that data will b rtrivd from basd on th databas qury. Crat a fourth data input namd WHERE_Attrribut, which spcifis th WHERE condition for th databas qury. Crat th fifth and final data input namd INPUT_VAL, which will b similar to th TC_AGENT data input INPUT from Tutorial 6. For this function block, this data input will vntually b th valu of LINK_ID that will b chckd in th Agnt databas. Crat a data output namd OUTPUT_VAL, which will b th valu of L_STATUS in th Agnt databas. Connct th REQ vnt with th INPUT_VAL data input and connct th CNF vnt with th OUTPUT_VAL data output. Th basic function should now look similar to Figur

79 Figur 7.4 Partially Configurd DB_SELECT_1 Function Block Notic that only on of th data inputs is connctd with th REQ vnt. Th othr four data inputs ar not connctd to th REQ vnt on purpos. By not conncting th data with th vnts, this mans th databas, tabl, and SELECT and WHERE constraints will hav to b givn during th dsign of th systm. Having to cod ach xact constraint in th Java algorithm rquirs changing th actual Java cod, rcompiling th function block, and rloading th systm numrous tims anytim a chang is mad. Instad, by stting up th function block in this way, th usr can right click on th data input, slct Connct to assign it a bas valu (doubl quots for WSTRING), and doubl click on th rsulting doubl quots to assign th ncssary databas nam, tabl, and SELECT and WHERE constraints. This way, th function block can b run without having to rcompil th Java algorithm or rload th ntir systm. This, in addition to th Java algorithm, maks this DB_SELECT_1 function block a databas qury function block. For th xcution control chart, th only chang that nds to b mad is th algorithm. St th REQ algorithm to us Java as its languag by doubl clicking on it at th bottom of th list on th lft and slcting Java as its languag. Do not put anything into th REQ algorithm, lav it blank for now. Evrything should b compltd and th xcution control chart should look lik Figur 7.5. Figur 7.5 Excution Control Chart Evrything that had to b don to configur TC_AGENT function block is now complt. Sav th DB_SELECT_1 function block as a Java fil in th dirctory spcifid for th Compilr Info hadr. Whil no algorithm has bn addd yt, th fil should b compild succssfully. Sav th DB_SELECT_1 function block as a XML fil, and thn xit th function block ditor. Opn up th function block ditor and opn th systm configuration DB_Slct and insrt th DB_SELECT_1 function block into th workspac (us any nam for th function block, hr it will b calld DBSlct). Connct th TC_AGENT function block with Input and Output. Th framwork is now 78

80 fully compltd; it should look lik Figur 7.6. Sav th framwork and clos th softwar. Figur 7.6 Framwork with DB_SELECT_1 Basic Function Block Stp 3: Editing th DB_SELECT_1 Algorithm Part I Whn th Java fil was savd, it s savd into th sam fil path as dfind in th packag. To find that fil, follow th path C:\ -> fbdk -> lib -> fb -> rt -> rutgrs-> b1. Opn up th b1 foldr for all fil typs and you can s th Java fil and class for DB_SELECT_1. Opn up th DB_SELECT_1.java fil by using Notpad. With Notpad, th Java cod writtn for th basic function block DB_SELECT_1 can b sn and ditd. Notic th cod alrady in th fil. It rprsnts th vnts, data, and connctions programmd for this function block typ. Scroll all th way down to th nd of th fil and you will find th following lins, shown in Figur 7.7. Figur 7.7 Program Cod In btwn thos two brackts is whr th cod for th REQ algorithm gos. Whn crating th basic function block, nothing was put in for th algorithm. At this point, w can put in our own cod and hav th function block call othr Java fils. For rading a databas, thr must b a modul that actually prforms th rading function as wll as a modul that controls connctions to th Agnt databas. In addition, th databas, its tabls, and th columns in th databas will hav to b dfind as variabls givn that th spcification for ach will com from th function block. To accomplish this, considr th following list of Java moduls calld. 79

81 DB_SELECT_1.java is th main program which will call: A modul which will rad from a databas. To do this, it will call: A modul which will connct and disconnct th databas from th RadDB modul. That will rquir: Th Agnt databas, that nds to b dfind. Th bst way to accomplish this is to work from th bottom of th list and up. That way no important stps such as dfining th databas ar missd. Furthrmor, th moduls that will b calld in othr programs will alrady b writtn and hav nams to b calld by. Stp 4: Conncting to a Variabl Databas First, mak sur you hav a databas st up in Accss calld Agnt with a tabl calld LINK_STATUS. In that tabl thr should b th data givn in Figur 7.2. Sav it to th sam dirctory as th DB_SELECT_1.java fil. Giv it a data sourc nam aftr saving it, as don prviously in Tutorial 6. If you hav don Tutorial 6 prviously, you may alrady hav that databas availabl and with a data sourc nam. Copy th Agnt.mdb fil and past it in th sam dirctory. Thn, rnam th fil Agnt2.mdb and dfin it with a data sourc nam (s Tutorial 6 for mor dtails). This Agnt2 databas will b usd for th purposs of tsting th DB_SELECT_1 function block latr. In Tutorial 6, in addition to a Java algorithm for TC_AGENT, two moduls wr also programmd in Java. For th purposs of this tutorial, w will modify thos moduls to mak th formrly static attributs involving th us th databas variabl. Opn up ConnctToDataBas.java, immdiatly sav it as ConnctToDataBasGn.java (mak sur All Fils is listd as Sav as typ in th rsulting window or th fil will b savd as a txt fil instad of a Java fil), and clos Notpad. This will nsur that th original fil rmains unchangd and not caus rrors in othr programs and function blocks that us that fil. Opn up ConnctToDataBasGn.java in Notpad and add th ncssary cod such that th fil will opn and clos connctions to a variabl databas nam (assuming th inputtd databas nam alrady has a dfind data sourc). Th dtaild cod for th fil ConnctToDataBasGn.java is listd in sction 7.4.A. Stp 5: Modifying SQL to Rad from a Variabl Databas Now that w hav writtn Java modul can connct to any availabl databas basd off its nam, w can writ a Java modul that will us it to rad information from that databas. A similar Java modul was writtn for this purpos in Tutorial 6 calld Rad.java, so w shall modify it to account for th nw variabls. Opn up Rad.java, sav it as RadDB.java (mak sur All Fils is listd as Sav as typ in th rsulting window), and clos Notpad. Again, this nsurs that th contnts of Rad.java ar not changd and dos not affct othr programs and function blocks that us it. Now opn up RadDB.java in Notpad to mak th ncssary changs to th cod. In this modul, it is imprativ that th ConnctToDataBasGn.java modul is run first and 80

82 conncts to th databas that th usr will dfin in th DB_SELECT_1 function block. In addition, th SQL command must b ditd to includ th nw variabls. Th lin that is qual to String qury is in th SQL languag. SQL languag, among othr uss, is usd to rtriv information from a databas basd on a st of conditions. Th original qury slcts th tabl LINK_STATUS and rtrivs th valu of th column L_STATUS whr th LINK_ID is qual to th inputtd intgr poll. Whatvr poll is qual to, th program will find that valu in th LINK_ID column in th LINK_STATUS tabl, and thn locat th corrsponding valu in th L_STATUS column. Originally, th tabl nam and th nams of th columns for th conditions wr alrady dfind within th SQL command. For this function block, thos nams bcom variabls. Thrfor, modify th command to mak th nam of th tabl and th conditions to b variabls that th usr will dfin in th DB_SELECT_1 function block. Th dtaild cod for RadDB.java is listd in sction 7.4.B. Stp 6: Writing th DB_SELECT_1 REQ algorithm. Now that th RadDB.java and ConnctToDataBasGn.java fils ar cratd and in th sam dirctory as th DB_SELECT_1.java fil, now th cod can b writtn for th REQ algorithm for th DB_SELECT_1 basic function block. Opn th DB_SELECT_1 function block and doubl click on th REQ algorithm at th bottom of th lft sid of th scrn. A window will pop up with a larg, blank txt spac at th bottom. In this txt spac, th Java cod for th REQ algorithm will b implmntd hr. This cod must b writtn such that it will tak th data coming into th function block, call th RadDB modul, which will call th ConnctToDataBasGn modul, chck for th corrsponding for th inputtd INPUT_VAL in th column spcifid by th WHERE_Attribut, and output th valu from SELECT_Attribut to th OUTPUT_VAL of th function block. All that is ncssary to do this is to quat a variabl to th INPUT_VAL.valu (th valu of th data coming into th INPUT data input), call th RadDB modul (which will tak car of vrything but th output), and quat th OUTPUT.valu (th valu of th data that will com from th OUTPUT data output) from a string variabl. Mak sur that th RadDB modul is calld not just with th valu of INPUT_VAL, but also th valus of DB, TABLE, SELECT_Attribut, and WHERE_Attribut. Th complt, dtaild cod for th REQ algorithm of th DB_SELECT_1 is shown in sction 7.4.C. Sav th DB_SELECT_1.java fil and th fil will automatically b compild. If thr ar any rrors in ithr of th two moduls, go back to Notpad, fix thm, and rcompil thm. If th rror is with th cod spcifically for th REQ algorithm, doubl click on th REQ algorithm and fix th rrors in th txt spac availabl. If thr ar no rrors, sav DB_SELECT_1 as a XML fil, clos th program, opn up th program again, and load th DB_Slct systm configuration. Th program nds to b closd so that th DB_SELECT_1 function block in th systm will work with th most rcnt compild Java class fil. Click on RES1 to bring up th framwork in th rsourc, and right click on th data inputs DB, TABLE, SELECT_Attribut, and WHERE_Attribut sparatly and connct thm with doubl quots. Doubl click on ach st of doubl quots to dfin th paramtrs. Whn finishd, th function block should look lik Figur

83 Figur 7.8 Fully Configurd DB_SELECT_1 Function Block in Framwork Whn finishd dfining ach paramtr, sav th systm configuration, and launch th program. Typ in a LINK_ID such as 12 or 14, click on th On/Off button, and chck th rsulting valu with th valus in th Agnt databas. If thy match, thn th DB_SELECT_1 function block and th program work proprly. To furthr tst it, clos th Java pop-up window (not th function block ditor) and opn up Agnt2 (which w dfind arlir) in Accss and giv som nw numric valus to L_STATUS. Go back to th rsourc RES1 in th function block ditor, doubl click on th string nxt to DB to rdfin th paramtr, and chang th paramtr to Agnt2. Launch th program again and input diffrnt LINK_ID valus for various rsulting outputs. If it works proprly, th outputs from th usr-inputtd LINK_ID should match with th L_STATUS valus for ach LINK_ID in th Agnt2 databas. 7.3 Summary This tutorial has shown th following squntial stps for dsigning and using a databas qury function block. To crat a databas qury function block: 1. St up a systm as a framwork for th function block. 2. Crat a nw basic function block and dfin its compilr information. 3. Dfin th intrfac of th composit function blocks: vnts, data inputs, and data outputs. 4. Connct data inputs and outputs with corrsponding vnts. B sur not to link vnts to data inputs that th usr will hav to configur. 5. Mak sur th Excution Control Chart has all th ncssary stats and transitions. Espcially mak sur that th algorithm for th vnt is dfind as Java. 6. Sav th function block as Java, compil it, and thn sav it as XML. 7. Insrt this function block into th systm framwork. Sav th framwork and clos th program. 8. Writ th ncssary Java moduls that th function block will call. B sur to mak th nam of th databas, th tabl, and th conditions variabl sinc th usr will spcify that in th function block. 9. Mak sur that any databass that can/will b usd hav a dfind data sourc. 82

84 10. Opn up th program and th function block, doubl click on th algorithm nam, and implmnt th Java cod for that spcific algorithm. 11. Sav th function block as a Java fil, whr th Java fil will automatically b compild. If thr ar no rrors, sav th function block again as an XML fil. Clos th program, and thn opn it again and load th systm configuration. 12. Bfor launching th program, configur th function block with th nam of th databas to b usd, th nam of th tabl that will b usd, and th nams of th columns to chck for and rtriv data from. EXERCISE: Th DB_SELECT_1 function block rtrivs information from a usr dfind databas. It is possibl, howvr, to updat a databas in th sam way. Dfining a databas, tabl, and conditions to b usd is don xactly th sam way it was don in this tutorial. Howvr, additional inputs and a nw SQL command ar ncssary for updating a databas. Crat a nw function block calld DB_UPDATE_1 and writ or dit th ncssary Java algorithms and moduls to accomplish this task. (Not: Th answr to this xrcis, complt with Java cod, is in sction 7.4.D.) EXERCISE: Th DB_SELECT_1 function block only rturns on valu from a column in a usr dfind databas. Howvr, it is possibl to slct and rturn mor than on valu in an SQL qury. SQL quris can b modifid to slct information from mor than on column. In addition, th WHERE condition in an SQL qury dos not hav to b a valu of a column. An ntir SQL qury for that WHERE condition, a sub-qury, can furthr spcify th constraint. Crat a nw function block calld DB_NEST_1_SELECT_3 and writ or dit th ncssary Java algorithms and moduls so that th function block can accomplish th following: 1) rturn 3 valus from 3 sparat columns and 2) instad of a solitary whr valu, implmnt a sub-qury in its plac. B sur to hav th SQL qury slct all thr columns at on tim. Also, th sub-qury only nds to hav on valu for th WHERE condition. (Not: Th answr to this xrcis, complt with Java cod, is in sction 7.4.E.) 83

85 7.4.A Cod for th Modul ConnctToDataBasGn.java packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; public class ConnctToDataBasGn{ privat String db = nw String(); protctd Connction connction; public ConnctToDataBasGn(String dbnam){ db = dbnam; public void opnconnction(){ try{ Class.forNam("sun.jdbc.odbc.JdbcOdbcDrivr"); String url ="jdbc:odbc:" + db; connction = DrivrManagr.gtConnction(url); catch(classnotfoundexcption cnf){ Systm.rr.println(cnf); catch(sqlexcption sql){ Systm.rr.println(sql); public void closconnction(){ if(connction!= null) try{ connction.clos(); connction = null; catch(sqlexcption sql){ Systm.rr.println(sql); 84

86 7.4.B Cod for th Modul RadDB.java packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; class RadDB xtnds ConnctToDataBasGn{ public RadDB(String dbnam){ supr(dbnam); public String rad_databas(int poll, String Tabl, String Slct, String Whr){ try{ opnconnction(); Statmnt statmnt = connction.cratstatmnt(); String qury = "SELECT " + Slct + " FROM " + Tabl + " WHERE " + Whr + "=" + poll; RsultSt rs = statmnt.xcutqury(qury); if(rs.nxt()){ String rsult = rs.gtstring(slct); closconnction(); rturn rsult; ls{ rturn null; catch(sqlexcption sql){ Systm.rr.println(sql); rturn null; 85

87 7.4.C Cod for th Function Block DB_SELECT_1.java int in = 0; String Tabl; String Slct; String Whr; try{ in = Intgr.parsInt(""+INPUT_VAL.valu); catch(numbrformatexcption ){ Systm.rr.println(); Tabl = TABLE.valu; Slct = SELECT_Attribut.valu; Whr = WHERE_Attribut.valu; RadDB raddb = nw RadDB(""+DB.valu); try{ String out = raddb.rad_databas(in, Tabl, Slct, Whr); OUTPUT_VAL.valu = out; CNF.srvicEvnt(this); catch(numbrformatexcption ){ Systm.rr.println(); 86

88 7.4.D DB_UPDATE_1 Intrfac & Java Cod Figur 7.9 Intrfac of DB_UPDATE_1 Function Block Th DB_UPDATE_1 function block uss th fil ConnctToDataBasGn.java, dtaild in sction 7.4.A. It uss its own Java modul calld WritDB. Th WritDB.java cod is as follows: packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; class WritDB xtnds ConnctToDataBasGn{ public WritDB(String dbnam){ supr(dbnam); public String writ_databas(int in1, int in2, String Tabl, String Updat, String Whr){ try{ opnconnction(); Statmnt statmnt = connction.cratstatmnt(); String updat = "UPDATE " + Tabl + " SET " + Updat + " = " + in1 + " WHERE " + Whr + "=" + in2; statmnt.xcutupdat(updat); closconnction(); String OK = "OK"; rturn OK; catch(sqlexcption sql){ Systm.rr.println(sql); rturn null; 87

89 Th Java algorithm for th REQ stat (th only non-initial stat ndd) of th DB_UPDATE_1 function block uss th WritDB Java modul and is shown blow. This cod is to b ntrd in th txt spac for th REQ algorithm (th only algorithm ndd) in th DB_UPDATE_1 function block. int in1 = 0; //Input int in2 = 0; //Updat String Tabl; String Updat; String Whr; try{ in1 = Intgr.parsInt(""+INPUT_VAL.valu); catch(numbrformatexcption ){ Systm.rr.println(); try{ in2 = Intgr.parsInt(""+WHERE_VAL.valu); catch(numbrformatexcption ){ Systm.rr.println(); Tabl = TABLE.valu; Updat = UPDATE_Attribut.valu; Whr = WHERE_Attribut.valu; WritDB writdb = nw WritDB(""+DB.valu); try{ String out = writdb.writ_databas(in1, in2, Tabl, Updat, Whr); CNF.srvicEvnt(this); catch(numbrformatexcption ){ Systm.rr.println(); 88

90 7.4.E DB_NEST_1_SELECT_3 Intrfac & Java Cod Figur 7.10 Intrfac of DB_NEST_1_SELECT_3 Function Block Th DB_NEST_1_SELECT_3 function block uss th fil ConnctToDataBasGn.java, dtaild in sction 7.4.A. It uss its own Java modul calld NstRadDB3. Th NstRadDB3.java cod is as follows: packag fb.rt.rutgrs.b1; import java.sql.*; import java.util.*; class NstRadDB3 xtnds ConnctToDataBasGn{ public NstRadDB3(String dbnam){ supr(dbnam); Systm.out.println(dbNam); public String[] rad_databas(string Slct1, String Slct2, String Slct3, String Tabl, String WhrAtt, String NstSlct, String NstTabl, String NstSlFunction, String NstWhrAtt, String NstWhrCond, String NstWhrValS){ String [] Array = nw String[3]; try{ opnconnction(); Statmnt statmnt = connction.cratstatmnt(); String qury = "SELECT " + Slct1 + ", " + Slct2 + ", " + Slct3 + " FROM " + Tabl + " WHERE " + WhrAtt + " IN (SELECT " + NstSlFunction + "(" + NstSlct + ") FROM " + NstTabl + " WHERE " + NstWhrAtt + " " + NstWhrCond + " " + NstWhrValS + ")"; Systm.out.println(qury); RsultSt rs = statmnt.xcutqury(qury); 89

2018 How to Apply. Application Guide. BrandAdvantage

2018 How to Apply. Application Guide. BrandAdvantage 2018 How to Apply Application Guid BrandAdvantag Contnts Accssing th Grant Sit... 3 Wlcom pag... 3 Logging in To Pub Charity... 4 Rgistration for Nw Applicants ( rgistr now )... 5 Organisation Rgistration...

More information

Reimbursement Requests in WORKS

Reimbursement Requests in WORKS Rimbursmnt Rqusts in WORKS Important points about Rimbursmnts in Works Rimbursmnt Rqust is th procss by which UD mploys will b rimbursd for businss xpnss paid using prsonal funds. Rimbursmnt Rqust can

More information

Systems in Three Variables. No solution No point lies in all three planes. One solution The planes intersect at one point.

Systems in Three Variables. No solution No point lies in all three planes. One solution The planes intersect at one point. 3-5 Systms in Thr Variabls TEKS FOCUS VOCABULARY TEKS (3)(B) Solv systms of thr linar quations in thr variabls by using Gaussian limination, tchnology with matrics, and substitution. Rprsntation a way

More information

Objectives. Two Ways to Implement Lists. Lists. Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues

Objectives. Two Ways to Implement Lists. Lists. Chapter 24 Implementing Lists, Stacks, Queues, and Priority Queues Chaptr 24 Implmnting Lists, Stacks, Quus, and Priority Quus CS2: Data Structurs and Algorithms Colorado Stat Univrsity Original slids by Danil Liang Modifid slids by Chris Wilcox Objctivs q To dsign common

More information

i e ai E ig e v / gh E la ES h E A X h ES va / A SX il E A X a S

i e ai E ig e v / gh E la ES h E A X h ES va / A SX il E A X a S isto C o C or Co r op ra p a py ag yr g ri g g gh ht S S S V V K r V K r M K v M r v M rn v MW n W S r W Sa r W K af r: W K f : a H a M r T H r M rn w T H r Mo ns w T i o S ww c ig on a w c g nd af ww

More information

Problem Set 1 (Due: Friday, Sept. 29, 2017)

Problem Set 1 (Due: Friday, Sept. 29, 2017) Elctrical and Computr Enginring Mmorial Univrsity of Nwfoundland ENGI 9876 - Advancd Data Ntworks Fall 2017 Problm St 1 (Du: Friday, Spt. 29, 2017) Qustion 1 Considr a communications path through a packt

More information

RFC Java Class Library (BC-FES-AIT)

RFC Java Class Library (BC-FES-AIT) RFC Java Class Library (BC-FES-AIT) HELP.BCFESDEG Rlas 4.6C SAP AG Copyright Copyright 2001 SAP AG. All Rcht vorbhaltn. Witrgab und Vrvilfältigung disr Publikation odr von Tiln daraus sind, zu wlchm Zwck

More information

Recorder Variables. Defining Variables

Recorder Variables. Defining Variables Rcordr Variabls Dfining Variabls Simpl Typs Complx Typs List of Rsrvd Words Using Variabls Stting Action Paramtrs Parsing Lists and Tabls Gtting Valu from Lists and Tabls Using Indxs with Lists Using Indxs

More information

About Notes And Symbols

About Notes And Symbols About Nots And Symbols by Batric Wildr Contnts Sht 1 Sht 2 Sht 3 Sht 4 Sht 5 Sht 6 Sht 7 Sht 8 Sht 9 Sht 10 Sht 11 Sht 12 Sht 13 Sht 14 Sht 15 Sht 16 Sht 17 Sht 18 Sht 19 Sht 20 Sht 21 Sht 22 Sht 23 Sht

More information

Midterm 2 - Solutions 1

Midterm 2 - Solutions 1 COS 26 Gnral Computr Scinc Spring 999 Midtrm 2 - Solutions. Writ a C function int count(char s[ ]) that taks as input a \ trminatd string and outputs th numbr of charactrs in th string (not including th

More information

DTRB Editor, Support Software for Cell Master

DTRB Editor, Support Software for Cell Master X903594 Vr.1.0 DTRB Editor, Support Softar for Cll Mastr DTRBP-SW-HTC Onr s Manual Vr.1.0 Contnts Chaptr 1 Installation Guid 1. Introduction 1 1-1 Nots 2 1-2 What Is DTRB Editor? 2 1-3 What Is Includd

More information

A Brief Summary of Draw Tools in MS Word with Examples! ( Page 1 )

A Brief Summary of Draw Tools in MS Word with Examples! ( Page 1 ) A Brif Summary of Draw Tools in MS Word with Exampls! ( Pag 1 ) Click Viw command at top of pag thn Click Toolbars thn Click Drawing! A chckmark appars in front of Drawing! A toolbar appars at bottom of

More information

2 Mega Pixel. HD-SDI Bullet Camera. User Manual

2 Mega Pixel. HD-SDI Bullet Camera. User Manual 2 Mga Pixl HD-SDI Bullt Camra Usr Manual Thank you for purchasing our product. This manual is only applicabl to SDI bullt camras. Thr may b svral tchnically incorrct placs or printing rrors in this manual.

More information

Lesson Focus: Finding Equivalent Fractions

Lesson Focus: Finding Equivalent Fractions Lsson Plans: Wk of 1-26-15 M o n Bindrs: /Math;; complt on own, thn chck togthr Basic Fact Practic Topic #10 Lsson #5 Lsson Focus: Finding Equivalnt Fractions *Intractiv Larning/Guidd Practic-togthr in

More information

XML Publisher with connected query: A Primer. Session #30459 March 19, 2012

XML Publisher with connected query: A Primer. Session #30459 March 19, 2012 XML Publishr with connctd qury: A Primr Sssion #30459 March 19, 2012 Agnda/ Contnts Introduction Ovrviw of XMLP Gtting Startd Bst practics for building a basic XMLP rport Connctd Qury Basics Building a

More information

The Network Layer: Routing Algorithms. The Network Layer: Routing & Addressing Outline

The Network Layer: Routing Algorithms. The Network Layer: Routing & Addressing Outline PS 6 Ntwork Programming Th Ntwork Layr: Routing lgorithms Michl Wigl partmnt of omputr Scinc lmson Univrsity mwigl@cs.clmson.du http://www.cs.clmson.du/~mwigl/courss/cpsc6 Th Ntwork Layr: Routing & ddrssing

More information

CPSC 826 Internetworking. The Network Layer: Routing & Addressing Outline. The Network Layer: Routing Algorithms. Routing Algorithms Taxonomy

CPSC 826 Internetworking. The Network Layer: Routing & Addressing Outline. The Network Layer: Routing Algorithms. Routing Algorithms Taxonomy PS Intrntworking Th Ntwork Layr: Routing & ddrssing Outlin Th Ntwork Layr: Routing lgorithms Michl Wigl partmnt of omputr Scinc lmson Univrsity mwigl@cs.clmson.du Novmbr, Ntwork layr functions Routr architctur

More information

" dx v(x) $ % You may also have seen this written in shorthand form as. & ' v(x) + u(x) '# % ! d

 dx v(x) $ % You may also have seen this written in shorthand form as. & ' v(x) + u(x) '# % ! d Calculus II MAT 146 Mthods of Intgration: Intgration by Parts Just as th mthod of substitution is an intgration tchniqu that rvrss th drivativ procss calld th chain rul, Intgration by parts is a mthod

More information

DO NOW Geometry Regents Lomac Date. due. Similar by Transformation 6.1 J'' J''' J'''

DO NOW Geometry Regents Lomac Date. due. Similar by Transformation 6.1 J'' J''' J''' DO NOW Gomtry Rgnts Lomac 2014-2015 Dat. du. Similar by Transformation 6.1 (DN) Nam th thr rigid transformations and sktch an xampl that illustrats ach on. Nam Pr LO: I can dscrib a similarity transformation,

More information

Linked Data meet Sensor Networks

Linked Data meet Sensor Networks Digital Entrpris Rsarch Institut www.dri.i Linkd Data mt Snsor Ntworks Myriam Lggiri DERI NUI Galway, Irland Copyright 2008 Digital Entrpris Rsarch Institut. All rights rsrvd. Linkd Data mt Snsor Ntworks

More information

CSE 272 Assignment 1

CSE 272 Assignment 1 CSE 7 Assignmnt 1 Kui-Chun Hsu Task 1: Comput th irradianc at A analytically (point light) For point light, first th nrgy rachd A was calculatd, thn th nrgy was rducd by a factor according to th angl btwn

More information

Interfacing the DP8420A 21A 22A to the AN-538

Interfacing the DP8420A 21A 22A to the AN-538 Intrfacing th DP8420A 21A 22A to th 68000 008 010 INTRODUCTION This application not xplains intrfacing th DP8420A 21A 22A DRAM controllr to th 68000 Thr diffrnt dsigns ar shown and xplaind It is assumd

More information

An Agent-Based Architecture for Service Discovery and Negotiation in Wireless Networks

An Agent-Based Architecture for Service Discovery and Negotiation in Wireless Networks An Agnt-Basd Architctur for Srvic Discovry and Ngotiation in Wirlss Ntworks Abstract Erich Birchr and Torstn Braun Univrsity of Brn, Nubrückstrass 10, 3012 Brn, Switzrland Email: braun@iam.unib.ch This

More information

Oracle Data Relationship Management Suite User's Guide. Release

Oracle Data Relationship Management Suite User's Guide. Release Oracl Data Rlationship Managmnt Suit Usr's Guid Rlas 11.1.2.4.346 E75912-02 Jun 2018 Oracl Data Rlationship Managmnt Suit Usr's Guid, Rlas 11.1.2.4.346 E75912-02 Copyright 1999, 2018, Oracl and/or its

More information

Shift. Reduce. Review: Shift-Reduce Parsing. Bottom-up parsing uses two actions: Bottom-Up Parsing II. ABC xyz ABCx yz. Lecture 8.

Shift. Reduce. Review: Shift-Reduce Parsing. Bottom-up parsing uses two actions: Bottom-Up Parsing II. ABC xyz ABCx yz. Lecture 8. Rviw: Shift-Rduc Parsing Bottom-up parsing uss two actions: Bottom-Up Parsing II Lctur 8 Shift ABC xyz ABCx yz Rduc Cbxy ijk CbA ijk Prof. Aikn CS 13 Lctur 8 1 Prof. Aikn CS 13 Lctur 8 2 Rcall: h Stack

More information

8.3 INTEGRATION BY PARTS

8.3 INTEGRATION BY PARTS 8.3 Intgration By Parts Contmporary Calculus 8.3 INTEGRATION BY PARTS Intgration by parts is an intgration mthod which nabls us to find antidrivativs of som nw functions such as ln(x) and arctan(x) as

More information

I - Pre Board Examination

I - Pre Board Examination Cod No: S-080 () Total Pags: 06 KENDRIYA VIDYALAYA SANGATHAN,GUWHATI REGION I - Pr Board Examination - 04-5 Subjct Informatics Practics (Thory) Class - XII Tim: 3 hours Maximum Marks : 70 Instruction :

More information

Register Allocation. Register Allocation

Register Allocation. Register Allocation Rgistr Allocation Jingk Li Portlan Stat Univrsity Jingk Li (Portlan Stat Univrsity) CS322 Rgistr Allocation 1 / 28 Rgistr Allocation Assign an unboun numbr of tmporaris to a fix numbr of rgistrs. Exampl:

More information

KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION CLASS XII COMMON PRE-BOARD EXAMINATION

KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION CLASS XII COMMON PRE-BOARD EXAMINATION KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION CLASS XII COMMON PRE-BOARD EXAMINATION 03-4 Sub : Informatics Practics (065) Tim allowd : 3 hours Maximum Marks : 70 Instruction : (i) All qustions ar compulsory

More information

running at 133 MHz bus. A Pentium III 1.26GHz with 512K cache running at 133 MHz bus is an available option. Fits Your Needs

running at 133 MHz bus. A Pentium III 1.26GHz with 512K cache running at 133 MHz bus is an available option. Fits Your Needs 3715 Industrial PCs 15.0" LCD Flat Panl Display DS-371500(E) Xycom Automation's nwst gnration of Industrial PCs is dsignd and tstd for th tough nvironmnts rquird for plant floor us. Our standard PC configurations

More information

Design Methodologies and Tools

Design Methodologies and Tools Dsign Mthodologis and Tools Dsign styls Full-custom dsign Standard-cll dsign Programmabl logic Gat arrays and fild-programmabl gat arrays (FPGAs) Sa of gats Systm-on-a-chip (mbddd cors) Dsign tools 1 Full-Custom

More information

QuickBird files are courtesy of DigitalGlobe and may not be reproduced without explicit permission from DigitalGlobe.

QuickBird files are courtesy of DigitalGlobe and may not be reproduced without explicit permission from DigitalGlobe. Calibrating Imags Tutorial In this tutorial, you will calibrat a QuickBird Lvl-1 imag to spctral radianc and rflctanc whil larning about th various mtadata filds that ENVI uss to prform calibration. Fils

More information

Motivation. Synthetic OOD concepts and reuse Lecture 4: Separation of concerns. Problem. Solution. Deleting composites that share parts. Or is it?

Motivation. Synthetic OOD concepts and reuse Lecture 4: Separation of concerns. Problem. Solution. Deleting composites that share parts. Or is it? Synthtic OOD concpts and rus Lctur 4: Sparation of concrns Topics: Complx concrn: Mmory managmnt Exampl: Complx oprations on composit structurs Problm: Mmory laks Solution: Rfrnc counting Motivation Suppos

More information

Extending z/tpf using IBM API Management (APIM)

Extending z/tpf using IBM API Management (APIM) Extnding using API Managmnt (APIM) Mark Gambino, TPF Dvlopmnt Lab March 23, 2015 TPFUG Dallas, TX Th Big Pictur Goal Mobil Applications Cloud APIs Cloud-basd Srvics On-Prmis Entrpris APIs E n t r p r I

More information

NVR Quick Start Guide (QSG): DS-7604NI-EV1/4P, DS-7608NI-EV2/8P. Figure 1, DS-760xNI-EVx/xP Front Panel

NVR Quick Start Guide (QSG): DS-7604NI-EV1/4P, DS-7608NI-EV2/8P. Figure 1, DS-760xNI-EVx/xP Front Panel NVR Quick Start Guid (QSG): DS-7604NI-EV1/4P, DS-7608NI-EV2/8P WHAT S IN THE BOX Mak sur th following itms ar in your box: NVR Mous Rmot 7604: Powr Supply HDD Scrws 7608: AC Cord (Installd) MENU TREE HDD

More information

SPECIFIC CRITERIA FOR THE GENERAL MOTORS GLOBAL TRADING PARTNER LABEL TEMPLATE:

SPECIFIC CRITERIA FOR THE GENERAL MOTORS GLOBAL TRADING PARTNER LABEL TEMPLATE: SPCIFIC CRITRIA FOR TH GNRAL MOTORS GLOBAL TRADING PARTNR LABL TMPLAT: TH TMPLAT IDNTIFIS HOW AND WHR DATA IS TO B PLACD ON TH LABL WHN IT IS RQUIRD AS PART OF A GM BUSINSS RQUIRMNT FONT SIZS AR SPCIFID

More information

ADC7480 SERIES. 3000W Battery Chargers and Power Supplies

ADC7480 SERIES. 3000W Battery Chargers and Power Supplies ADC748 SERIES 3W Battry Chargrs and Powr Supplis Wid output adjustmnt rang 32VDC Analog control by xtrnal -5VDC voltag Tmp.comp charging, sns as on option Powr fail rlay alarm Mastr-Slav connction Analog

More information

Spectral sensitivity and color formats

Spectral sensitivity and color formats FirWir camras Spctral snsitivity and color formats At th "input" of a camra, w hav a CCD chip. It transforms photons into lctrons. Th spctral snsitivity of this transformation is an important charactristic

More information

EE 231 Fall EE 231 Homework 10 Due November 5, 2010

EE 231 Fall EE 231 Homework 10 Due November 5, 2010 EE 23 Fall 2 EE 23 Homwork Du Novmbr 5, 2. Dsign a synhronous squntial iruit whih gnrats th following squn. (Th squn should rpat itslf.) (a) Draw a stat transition diagram for th iruit. This is a systm

More information

Driver for netgear wn111v2 wireless usb adapter Get file - Driver for netgear wn111v2 wireless usb adapter

Driver for netgear wn111v2 wireless usb adapter Get file - Driver for netgear wn111v2 wireless usb adapter Drivr for ntgar wn111v2 wirlss usb adaptr. Fr FILE Download My IE dosn t work. Drivr for ntgar wn111v2 wirlss usb adaptr Gt fil - Drivr for ntgar wn111v2 wirlss usb adaptr But somtims thy grow back. RAR

More information

Nimsoft Monitor. ldap_response Guide. v1.3 series

Nimsoft Monitor. ldap_response Guide. v1.3 series Nimsoft Monitor ldap_rspons Guid v1.3 sris Lgal Notics Copyright 2012, Nimsoft Corporation Warranty Th matrial containd in this documnt is providd "as is," and is subjct to bing changd, without notic,

More information

Greedy Algorithms. Interval Scheduling. Greedy Algorithm. Optimality. Greedy Algorithm (cntd) Greed is good. Greed is right. Greed works.

Greedy Algorithms. Interval Scheduling. Greedy Algorithm. Optimality. Greedy Algorithm (cntd) Greed is good. Greed is right. Greed works. Algorithm Grdy Algorithm 5- Grdy Algorithm Grd i good. Grd i right. Grd work. Wall Strt Data Structur and Algorithm Andri Bulatov Algorithm Grdy Algorithm 5- Algorithm Grdy Algorithm 5- Intrval Schduling

More information

1. Trace the array for Bubble sort 34, 8, 64, 51, 32, 21. And fill in the following table

1. Trace the array for Bubble sort 34, 8, 64, 51, 32, 21. And fill in the following table 1. Trac th array for Bubbl sort 34, 8, 64, 51, 3, 1. And fill in th following tabl bubbl(intgr Array x, Intgr n) Stp 1: Intgr hold, j, pass; Stp : Boolan switchd = TRUE; Stp 3: for pass = 0 to (n - 1 &&

More information

Principles of Programming Languages Topic: Formal Languages II

Principles of Programming Languages Topic: Formal Languages II Principls of Programming Languags Topic: Formal Languags II CS 34,LS, LTM, BR: Formal Languags II Rviw A grammar can b ambiguous i.. mor than on pars tr for sam string of trminals in a PL w want to bas

More information

A New Algorithm for Solving Shortest Path Problem on a Network with Imprecise Edge Weight

A New Algorithm for Solving Shortest Path Problem on a Network with Imprecise Edge Weight Availabl at http://pvamudu/aam Appl Appl Math ISSN: 193-9466 Vol 6, Issu (Dcmbr 011), pp 60 619 Applications and Applid Mathmatics: An Intrnational Journal (AAM) A Nw Algorithm for Solving Shortst Path

More information

Comment (justification for change) by the MB

Comment (justification for change) by the MB Editor's disposition s CD2 19763-12 as at 2013-11-03 Srial Annx (.g. 3.1) Figur/ Tabl/t (.g. Tabl 1) 001 CA 00 All All - G Canada disapprovs th draft for th rasons blow. 002 GB 01 Gnral d numbring has

More information

LAB1: DMVPN Theory. DMVPN Theory. Disclaimer. Pag e

LAB1: DMVPN Theory. DMVPN Theory. Disclaimer. Pag e LAB1: DMVPN Thory Disclaimr This Configuration Guid is dsignd to assist mmbrs to nhanc thir skills in rspctiv tchnology ara. Whil vry ffort has bn mad to nsur that all matrial is as complt and accurat

More information

To Do. Mesh Data Structures. Mesh Data Structures. Motivation. Outline. Advanced Computer Graphics (Fall 2010) Desirable Characteristics 1

To Do. Mesh Data Structures. Mesh Data Structures. Motivation. Outline. Advanced Computer Graphics (Fall 2010) Desirable Characteristics 1 Advancd Computr Graphics (Fall 200) CS 283, Lctur 5: Msh Data Structurs Ravi Ramamoorthi http://inst.cs.brkly.du/~cs283/fa0 To Do Assignmnt, Du Oct 7. Start rading and working on it now. Som parts you

More information

Summary: Semantic Analysis

Summary: Semantic Analysis Summary: Smantic Analysis Chck rrors not dtctd by lxical or syntax analysis Intrmdiat Cod Scop rrors: Variabls not dfind Multipl dclarations Typ rrors: Assignmnt of valus of diffrnt typs Invocation of

More information

TCP Congestion Control. Congestion Avoidance

TCP Congestion Control. Congestion Avoidance TCP Congstion Control TCP sourcs chang th snding rat by modifying th window siz: Window = min {Advrtisd window, Congstion Window} Rcivr Transmittr ( cwnd ) In othr words, snd at th rat of th slowst componnt:

More information

USER MANUAL ACCESS CONTROLLER smartlock

USER MANUAL ACCESS CONTROLLER smartlock and lif gts bttr! USER MANUAL ACCESS CONTROLLER smartlock scurity www.smartlock.pl C spd Q, app managmnt rmot control ? smartlock and lif gts bttr! smartlock accss controllr is wathr-proof so it can b

More information

Type & Media Page 1. January 2014 Libby Clarke

Type & Media Page 1. January 2014 Libby Clarke Nam: 1 In ordr to hlp you s your progrss at th nd of this ntir xrcis, you nd to provid som vidnc of your starting point. To start, draw th a on th lft into th box to th right, dpicting th sam siz and placmnt.

More information

The semantic WEB Roles of XML & RDF

The semantic WEB Roles of XML & RDF Th smantic WEB Rols of XML & RDF STEFAN DECKER AND SERGEY MELNIK FRANK VAN HARMELEN, DIETER FENSEL, AND MICHEL KLEIN JEEN BROEKSTRA MICHAEL ERDMANN IAN HORROCKS Prsntd by: Iniyai Thiruvalluvan CSCI586

More information

JetAdvantage App Handbook

JetAdvantage App Handbook JtAdvantag App Handbook March 2019 HP Inc. maks no warranty of any kind with rgard to this matrial, including, but not limitd to, th implid warrantis of mrchantability and fitnss for a particular purpos.

More information

Pulling the (DB2) Trigger A Solution Example Author: Tommy Atkins, TEMBO Technology Labs

Pulling the (DB2) Trigger A Solution Example Author: Tommy Atkins, TEMBO Technology Labs Pulling th (DB2) Triggr A Solution Exampl Author: Tommy Atkins, TEMBO Tchnology Las Astract This articl is th follow-up to th original articl on Pulling th Triggr. As omisd, this articl ovids a st of cod

More information

AV1640 ANAG VISION. 16x4 Character

AV1640 ANAG VISION. 16x4 Character AV1640 16x4 Character 5x7 dots with cursor 1/16 duty +5V single supply Controller built in (KS0066 or quivalent) B/L driven by pin1 and 2, 15 and 16 or A,K Pin Assignment No. Symbol Function 1 Vss Gnd,

More information

QUICK REFERENCE. Sutter Instrument Company Lambda Series. Configuration, Cabling, & Remote Control Quick Reference

QUICK REFERENCE. Sutter Instrument Company Lambda Series. Configuration, Cabling, & Remote Control Quick Reference QUICK REFERENCE Rv..4 (273) Suttr Instrumnt Company Lambda Sris Configuration, Cabling, & Rmot Control Quick Rfrnc Lambda Sris Configuration, Cabling, & Rmot Control Quick Rfrnc (Rv..4 (273)) Suttr Instrumnt

More information

SPECIFIC CRITERIA FOR THE GENERAL MOTORS GLOBAL TRADING PARTNER LABEL TEMPLATE:

SPECIFIC CRITERIA FOR THE GENERAL MOTORS GLOBAL TRADING PARTNER LABEL TEMPLATE: SPCIFIC CRITRIA FOR TH GNRAL MOTORS GLOBAL TRADING PARTNR LABL TMPLAT: TH TMPLAT IDNTIFIS HOW AND WHR DATA IS TO B PLACD ON TH LABL WHN IT IS RQUIRD AS PART OF A GM BUSINSS RQUIRMNT FONT SIZS AR SPCIFID

More information

IN the early seventies, the IEEE recommended a Common

IN the early seventies, the IEEE recommended a Common PAPER SUBMITTED TO 2009 IEEE PES GENERAL MEETING. 1 Opn Modl For Exchanging Powr Systm Data F. Milano, Mmbr, IEEE, M. Zhou, Mmbr, IEEE, and GuanJi Hou Abstract This papr prsnts an XML-basd opn data modl

More information

Acceleration of the Smith-Waterman Algorithm using Single and Multiple Graphics Processors

Acceleration of the Smith-Waterman Algorithm using Single and Multiple Graphics Processors Acclration of th Smith-Watrman Algorithm using Singl and Multipl Graphics Procssors Ali Khah-Sad, Stphn Pool and J. Blair Prot Abstract Finding rgions of similarity btwn two vry long data strams is a computationally

More information

Voltage Detector, High-Precision. Features. Name RESET

Voltage Detector, High-Precision. Features. Name RESET M MICROCTRONIC-MARIN SA oltag tctor, High-Prcision scription Th is an ultra-low currnt voltag dtctor availabl in a larg varity of configurations and vry small packags for maximum flxibility in all nd-applications

More information

AN EVALUATION MODEL FOR THE CHAINS OF DISTRIBUTED MULTIMEDIA INDEXING TOOLS RESPECTING USER PREFERENCES

AN EVALUATION MODEL FOR THE CHAINS OF DISTRIBUTED MULTIMEDIA INDEXING TOOLS RESPECTING USER PREFERENCES AN EVALUATION MODEL FOR THE CHAINS OF DISTRIBUTED MULTIMEDIA INDEXING TOOLS RESPECTING USER PREFERENCES 1 Bassm HAIDAR, 2 Bilal CHEBARO, 3 Hassan WEHBI 1 Asstt Prof., Dpartmnt of Computr Scincs, Faculty

More information

Voltage Detector, High-Precision. Features. ! 3 reset output options:

Voltage Detector, High-Precision. Features. ! 3 reset output options: M MICROCTRONIC-MARIN SA Voltag tctor, High-Prcision scription Th is an ultra-low currnt voltag dtctor availabl in a larg varity of configurations and vry small packags for maximum flxibility in all nd-applications

More information

To Do. Advanced Computer Graphics. Motivation. Mesh Data Structures. Outline. Mesh Data Structures. Desirable Characteristics 1

To Do. Advanced Computer Graphics. Motivation. Mesh Data Structures. Outline. Mesh Data Structures. Desirable Characteristics 1 Advancd Computr Graphics CSE 63 [Spring 208], Lctur 7 Ravi Ramamoorthi http://www.cs.ucsd.du/~ravir To Do Assignmnt, Du Apr 27 Any last minut issus or difficultis? Starting Gomtry Procssing Assignmnt 2

More information

Managing Trust Relationships in Peer 2 Peer Systems

Managing Trust Relationships in Peer 2 Peer Systems Managing Trust Rlationships in Pr 2 Pr Systms R.S.SINJU PG STUDENT, DEPARTMENT OF COMPUTER SCIENCE, PONJESLY COLLEGE OF ENGINEERING NAGERCOIL, TAMILNADU, INDIA C.FELSY ASST.PROF, DEPARTMENT OF COMPUTER

More information

Introduction to Data Mining

Introduction to Data Mining Introduction to Data Mining Lctur #15: Clustring-2 Soul National Univrsity 1 In Tis Lctur Larn t motivation and advantag of BFR, an xtnsion of K-mans to vry larg data Larn t motivation and advantag of

More information

Clustering Algorithms

Clustering Algorithms Clustring Algoritms Hirarcical Clustring k -Mans Algoritms CURE Algoritm 1 Mtods of Clustring Hirarcical (Agglomrativ): Initially, ac point in clustr by itslf. Rpatdly combin t two narst clustrs into on.

More information

Blue-Bot. Marketing Guide BLUETOOTH FLOOR ROBOT. Computing and ICT

Blue-Bot. Marketing Guide BLUETOOTH FLOOR ROBOT. Computing and ICT Blu-Bot BLUETOOTH FLOOR ROBOT Computing and ICT Markting Guid Blu-Bot_Usr Guid.indd 1 About this guid Introduction This markting guid has bn cratd to nsur that you ar informd of all of th ky faturs and

More information

JMFMoD: A New System for Media on Demand Presentations on Education

JMFMoD: A New System for Media on Demand Presentations on Education JMFMoD: A Nw Systm for Mdia on Dmand Prsntations on Education Authors: Ángla Blda, Univrsidad Politécnica d Valncia, Camino d Vra s/n, Valncia, Spain, anblor@doctor.upv.s Juan José Crmño, Univrsidad Politécnica

More information

Proceedings of the 5 th Annual Linux Showcase & Conference

Proceedings of the 5 th Annual Linux Showcase & Conference USENIX Association Procdings of th 5 th Annual Linux Showcas & Confrnc Oakland, California, USA Novmbr 5 10, 2001 THE ADVANCED COMPUTING SYSTEMS ASSOCIATION 2001 by Th USENIX Association All Rights Rsrvd

More information

Formal Foundation, Approach, and Smart Tool for Software Models Comparison

Formal Foundation, Approach, and Smart Tool for Software Models Comparison Formal Foundation, Approach, and Smart Tool for Softwar Modls Comparison Olna V. Chbanyuk, Abdl-Badh M. Salm Softwar Enginring Dpartmnt, National Aviation Univrsity, Kyiv, Ukrain Computr Scinc, Faculty

More information

To Do. Advanced Computer Graphics. Motivation. Mesh Data Structures. Outline. Mesh Data Structures. Desirable Characteristics 1

To Do. Advanced Computer Graphics. Motivation. Mesh Data Structures. Outline. Mesh Data Structures. Desirable Characteristics 1 Advancd Computr Graphics CSE 63 [Spring 207], Lctur 7 Ravi Ramamoorthi http://www.cs.ucsd.du/~ravir To Do Assignmnt, Du Apr 28 Any last minut issus or difficultis? Starting Gomtry Procssing Assignmnt 2

More information

Revit Architecture ctu

Revit Architecture ctu h pt r2: Chaptr 2 Rvit Architctur ctu BasicsChaptr2: Bfor you bgin to us Rvit Architctur, you nd to bcom rc familiar with th intrfac, th typs of objcts you will b using to crat your dsigns, P sa and basic

More information

A Loadable Task Execution Recorder for Hierarchical Scheduling in Linux

A Loadable Task Execution Recorder for Hierarchical Scheduling in Linux A Loadabl Task Excution Rcordr for Hirarchical Schduling in Linux Mikal Åsbrg and Thomas Nolt MRTC/Mälardaln Univrsity PO Box 883, SE-721 23, Västrås, Swdn {mikalasbrg,thomasnolt@mdhs Shinpi Kato Carngi

More information

Maxwell s unification: From Last Time. Energy of light. Modern Physics. Unusual experimental results. The photoelectric effect

Maxwell s unification: From Last Time. Energy of light. Modern Physics. Unusual experimental results. The photoelectric effect From Last Tim Enrgy and powr in an EM wav Maxwll s unification: 1873 Intimat connction btwn lctricity and magntism Exprimntally vrifid by Hlmholtz and othrs, 1888 Polarization of an EM wav: oscillation

More information

LAB 3: DMVPN EIGRP. EIGRP over DMVPN. Disclaimer. Pag e

LAB 3: DMVPN EIGRP. EIGRP over DMVPN. Disclaimer. Pag e LAB 3: DMVPN EIGRP Disclaimr This Configuration Guid is dsignd to assist mmbrs to nhanc thir skills in rspctiv tchnology ara. Whil vry ffort has bn mad to nsur that all matrial is as complt and accurat

More information

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Directed Graphs BOS SFO

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Directed Graphs BOS SFO Prsntation for us with th txtbook, Algorithm Dsign and Applications, by M. T. Goodrich and R. Tamassia, Wily, 2015 Dirctd Graphs BOS ORD JFK SFO LAX DFW MIA 2015 Goodrich and Tamassia Dirctd Graphs 1 Digraphs

More information

Ontology and Context. Isabel Cafezeiro Departamento de Ciência da Computação Universidade Federal Fluminense Niterói - RJ, Brazil

Ontology and Context. Isabel Cafezeiro Departamento de Ciência da Computação Universidade Federal Fluminense Niterói - RJ, Brazil Ontology and Contxt Isabl Cafziro Dpartamnto d Ciência da Computação Univrsidad Fdral Fluminns Nitrói - RJ, Brazil isabl@dcc.ic.uff.br dward Hrmann Hauslr, Alxandr Radmakr Dpartamnto d Informática Pontifícia

More information

Interface Description for SRC65 BACnet MS/TP RS485

Interface Description for SRC65 BACnet MS/TP RS485 Intrfac Dscription for SRC65 BACnt MS/TP RS485 Vrsion 1.0, 09.09.2009 Thrmokon Snsortchnik GmbH www.thrmokon.d mail@thrmokon.d 1 Amndmt Indx Vrsion Dat Dscription 1.0 09.09.2009 1. Rlas Thrmokon Snsortchnik

More information

XML security in certificate management

XML security in certificate management XML scurity in crtificat managmnt Joan Lu, Nathan Cripps and Chn Hua* School of Computing and Enginring, Univrsity of Huddrsfild, UK J.lu@hud.ac.uk *Institut of Tchnology, Xi'an, Shaanxi, P. R. China Abstract

More information

Transaction-level Modeling of MPEG-2 Video Decode Application in SystemC 2.0.1

Transaction-level Modeling of MPEG-2 Video Decode Application in SystemC 2.0.1 Transaction-lvl Modling of MPEG-2 Vido Dcod Application in SystmC 2.0.1 Samvit Kaul, Srkanth M, Junhyung Um, Eui-young Chung, Kyu-Myung Choi, Jong-Tak Kong, Soo-Kwan Eo CAE Cntr, Systm LSI Dvision, Dvic

More information

GSM on the Net. Background. System concept. Olle Granberg

GSM on the Net. Background. System concept. Olle Granberg GSM on th Nt Oll Granbrg GSM on th Nt introducs an ntirly nw concpt for businss communications, offring voic, data and multimdia srvics ovr corporat intrants. Th voic srvic can b ithr fixd or mobil (in

More information

MOBY. Interface Module ASM 472 A B. Table of Contents. Short Description of ASM Configuration, Mounting and Commissioning

MOBY. Interface Module ASM 472 A B. Table of Contents. Short Description of ASM Configuration, Mounting and Commissioning Tabl of Contnts Short Dscription of 1 Configuration, Mounting and Commissioning 2 MOBY Intrfac Modul Tchnical Dscription and Programmr s Guid Programming th 3 Sampl Applications 4 Prsnc Chck 5 Troubl-Shooting

More information

What is state? Unit 5. State Machine Block Diagram. State Diagrams. State Machines. S0 Out=False. S2 out=true. S1 Out=False

What is state? Unit 5. State Machine Block Diagram. State Diagrams. State Machines. S0 Out=False. S2 out=true. S1 Out=False 5.1 What i tat? 5.2 Unit 5 Stat Machin You a DPS officr approaching you. Ar you happy? It' lat at night and. It' lat at night and you'v bn. Your intrprtation i bad on mor than jut what your n ar tlling

More information

Section II. PCB Layout Guidelines

Section II. PCB Layout Guidelines Sction II. PCB Layout Guidlins This sction provids information for board layout dsignrs to succssfully layout thir boards for MAX II dvics. It contains th rquird printd circuit board (PCB) layout guidlins,

More information

Fuzzy Intersection and Difference Model for Topological Relations

Fuzzy Intersection and Difference Model for Topological Relations IFS-EUSFLT 009 Fuzzy Intrsction and Diffrnc Modl for Topological Rlations hd LOODY Flornc SEDES Jordi INGLD 3 Univrsité Paul Sabatir (UPS) Toulous, 8 Rout d Narbonn, F-306-CEDEX 9, Franc Institut d Rchrchn

More information

Announcements. q This week s schedule. q Next week. q Grading. n Wednesday holiday. n Thursday class from am

Announcements. q This week s schedule. q Next week. q Grading. n Wednesday holiday. n Thursday class from am Announcmnts This wk s schdul n Wdnsday holiday n Thursday class from 9.00-0.30am Nxt wk n Monday and Tusday rgular class n Wdnsday Last uiz for th cours Grading n Quiz 5, 6 and Lab 6 ar du. Applications

More information

Modelling CoCoME with DisCComp

Modelling CoCoME with DisCComp Modlling CoCoME with DiCComp Dagtuhl Workhop, Sbatian Hrold Clauthal Univrity of Tchnology Dpartmnt of Informatic Softwar Sytm Enginring Chair of Prof. Dr. Andra Rauch Ovrviw Introduction Introduction

More information

ID: Sample Name: 65youtuber.com Cookbook: default.jbs Time: 17:33:33 Date: 14/10/2017 Version:

ID: Sample Name: 65youtuber.com Cookbook: default.jbs Time: 17:33:33 Date: 14/10/2017 Version: ID: 34232 Sampl Nam: 65youtubr.com Cookbook: dfault.jbs Tim: 17:33:33 Dat: 14/10/2017 Vrsion: 20.0.0 Tabl of Contnts Analysis Rport Ovrviw Gnral Information Dtction Confidnc Classification Analysis Advic

More information

Group 2 Mega Crystals Usability Test Report

Group 2 Mega Crystals Usability Test Report Group 2 Mga Crystals Usability Tst Rport Rport Writtn By Katrina Ellis Tam Mmbrs Usr Exprinc Consultants Katrina Ellis Zhitao Qiu HU4628 Julia Wiss Sarah Ingold Jams Staplton CS4760 Kris Gauthir (Android)

More information

: Mesh Processing. Chapter 6

: Mesh Processing. Chapter 6 600.657: Msh Procssing Chaptr 6 Quad-Dominant Rmshing Goal: Gnrat a rmshing of th surfac that consists mostly of quads whos dgs align with th principal curvatur dirctions. [Marinov t al. 04] [Alliz t al.

More information

Overview of the Gifted Services Portfolio Process

Overview of the Gifted Services Portfolio Process Saint Paul Public Schools Ovrviw of th Giftd Srvics Portfolio Procss Talnt Dvlopmnt and Acclration Srvics What is th Portfolio Rviw? Th portfolio rviw offrs all studnts th opportunity to b assssd for giftd

More information

PW 6101 PW 6131 PW 6161 PW Programming instructions Profitronic M. To avoid the risk of accidents or damage to the machine it is

PW 6101 PW 6131 PW 6161 PW Programming instructions Profitronic M. To avoid the risk of accidents or damage to the machine it is Programming instructions Profitronic M PW 6101 PW 6131 PW 6161 PW 6201 To avoid th risk of accidnts or damag to th machin it is G ssntial to rad ths instructions bfor installing, commissioning and using

More information

TRIANGULATION OF NURBS SURFACES. Jamshid Samareh-Abolhassani. 1 Abstract

TRIANGULATION OF NURBS SURFACES. Jamshid Samareh-Abolhassani. 1 Abstract TRIANGULATION OF NURBS SURFACES Jamshid Samarh-Abolhassani 1 Abstract A tchniqu is prsntd for triangulation of NURBS surfacs. This tchniqu is built upon an advancing front tchniqu combind with grid point

More information

This module calculates the motor speed based on a rotor position measurement when the direction information is available.

This module calculates the motor speed based on a rotor position measurement when the direction information is available. SPEED_FRQ Spd Calulator Basd on Rotor Angl With Dirtion Information Dsription This modul alulats th motor spd basd on a rotor position masurmnt whn th dirtion information is availabl. thta_l dir_qep SPEED_FRQ

More information

Analysis of Influence AS Path Prepending to the Instability of BGP Routing Protocol.

Analysis of Influence AS Path Prepending to the Instability of BGP Routing Protocol. ISSN : 2355-9365 -Procding of Enginring : Vol.5, No.1 Mart 2018 Pag 1112 Analysis of Influnc AS Path Prpnding to th Instability of BGP Routing Protocol. Hirwandi Agusnam 1, Rndy Munadi 2, Istikmal 3 1,2,3,

More information

Building a Scanner, Part I

Building a Scanner, Part I COMP 506 Ric Univrsity Spring 2018 Building a Scannr, Part I sourc cod IR Front End Optimizr Back End IR targt cod Copyright 2018, Kith D. Coopr & Linda Torczon, all rights rsrvd. Studnts nrolld in Comp

More information

Multihop MIMO Relay Networks with ARQ

Multihop MIMO Relay Networks with ARQ Multihop MIMO Rlay Ntworks with ARQ Yao Xi Dniz Gündüz Andra Goldsmith Dpartmnt of Elctrical Enginring Stanford Univrsity Stanford CA Dpartmnt of Elctrical Enginring Princton Univrsity Princton NJ Email:

More information

NASPI Work Group meeting April 24-26, 2018 Albuquerque, NM

NASPI Work Group meeting April 24-26, 2018 Albuquerque, NM NASPI Work Group mting April 24-26, 2018 Albuqurqu, NM Pavl Kovalnko Viktor Litvinov from Data to Action Prmium Information Srvics from Data to Action Dsign, Dvlop and Dploy - digital transformation solutions

More information

EXTENSION OF RCC TOPOLOGICAL RELATIONS FOR 3D COMPLEX OBJECTS COMPONENTS EXTRACTED FROM 3D LIDAR POINT CLOUDS

EXTENSION OF RCC TOPOLOGICAL RELATIONS FOR 3D COMPLEX OBJECTS COMPONENTS EXTRACTED FROM 3D LIDAR POINT CLOUDS Th Intrnational rchivs of th Photogrammtry, mot Snsing and Spatial Information Scincs, Volum XLI-, 016 XXIII ISPS Congrss, 1 19 July 016, Pragu, Czch public EXTENSION OF CC TOPOLOGICL ELTIONS FO D COMPLEX

More information