Home

FactoryLink ECS Core Tasks Configuration Guide

image

Contents

1. E SS E printf inside the for loop n E 2g E 00000000 BADTOK 00000000 LE NFELNEWNUSERNCML 3 Description of thefiles generated by parsecml The following test cis generated by parsecml V3 NUSER C PA Bees Soe Sets Lee bee eo eee pies uri include include include include include include include include void long char short double lt s lt s Kf lt m lt s lt lt t ji tdio h gt tdlib h gt ib h gt ath h gt tring h gt cml h gt vars h est h gt test void llocvar trlocvarLMAXMSG slocvar n flocvar 262 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables memset amp llocvar 0 sizeof llocvar memset strlocvar 0 sizeof strlocvar memset amp slocvar 0 sizeof slocvar memset amp flocvar 0 sizeof flocvar Procname test printf nCML Entering procedure test n cirstack PRINT INSIDE THE WHILE LOOP N cirstack pushstr INSIDE THE WHILE LOOP N doprint pop locvar llocvar 1 puchlong llocvar pushint 1 doadd llocvar poplong WEND printf FactoryLink is the best n for i INITVAL i lt UPBOUND i INCREMENT I INITVAL UPBOUND INCREMENT are defined and declared in test h er o 5 2 r O 2 Factory
2. Errors that read IML PROC namenot found are probably caused by a typing error or failureto list a PRG file in the Triggers table Procedure names are case sensitive while procedure fil enames are always lower case if applicable to the operating system PROC Definitions A PRG file groups several procedure definitions Procedure definitions contain a minimum of three statements PROC name BE GIN and END Procedure definitions are case sensitive so the following defines two procedures proc Dave begin print Dave end proc dave begin print Little Dave end 134 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Configuration Tables Comments The pound sign indicates the IML parser ignores a comment that is all text after the The exception to this is if the is inside the string or escape using the backslash character Well commented code is integral to maintain a user developer friendly code Math and Logic Variables Table The Math and Logic Variables table lets you define the database elements Math and Logic reads or writes An element must be defined beforeit can beused in a procedure or else the task will not validate the procedure the element will be considered an undefined variable Define each element referenced by the procedures in a program file by entering its tag name in this table The Math and Logic Variables table should contain ever
3. 42 FactoryLink ECS Core Tasks Configuration Guide EVENT AND INTERVAL TIMER Configuring the Event and Interval Timer Task When all information has been specified the dialog resembles the sample dialog below tua Event Timer Information olx Edit View Utilities Exit Help B Tag Name Year Mon Day DOW Hours Mins startday 8 0 endday 17 0 newyear JAN 1 lastday 12 31 fribpm FRI 17 0 E Cancel Enter Exit ajm uy In this example the startday element has a value of 0 between midnight and 8 00 amand 1 between 8 00 am and 11 59 pm and 59 seconds 23 59 59 each day of the year Similarly the endday element has a value of 0 between midnight and 5 00 pm and 1 between 5 00 pm and 11 59 pm and 59 seconds The newyear element s value has a value of 1 on J anuary 1 of each year and 0 on all other days Similarly thelastday element s value has a value of 1 on December 31 of each year and 0 on all other days m lt D gt o Q 3 D lt D The fri5pm element has a value of 1 each Friday between 5 00 pm and midnight Click Enter to savethe information and return to the Main Menu when you finish setting the event timers Interval Timer Information Dialog Use Interval Timer to define events that occur at least once every 24 hours at regular intervals of the system clock such as every second or every two hours F or example useinterval ti mers as triggers in Polled Re
4. Local variables are declared one data typeto aline and normally only one data item per linein statements similar to the ones shown below DECLARE short itotal N DECLARE float ftotal Initialized Value E ach timea procedureis called in the interpreted mode a new instance of each local variable is created and the value of each variableis initialized to 0 Each time the executableis run in the compiled mode the value of each local variable is initialized to 0 which redefines the variable When a procedure is completed variables defined inside the procedure are destroyed When large numbers of local variables are dedared in a program file and are meant to be accessible to all the procedures in that file performance can be improved by pladngthedeclarations at the top of the filein which the procedures are stored before the start of the first procedure This makes the dedarations global to the program file 190 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure A local procedure variable may be declared as a scalar local variable or as a local array Scalar Local Variable f declared as a scalar local variable the dedaration has thefollowing form DECLARE type name where type is oneof the following SHORT signed short integer LONG signed longinteger FLOAT double precision floating point number STRING ASCI character string of up to 79 characters and name contains only alphabeti
5. Table PRINT Designates the name of a PRINT operati on Name Command printtrig Name of the digital element that triggers the Trigger print operation You can also configure other tasks to writeto this element to trigger a print operati on Command PRINT Designates a PRINT operation Source 96s Thename of the fileto be printed In this File Spec example the file name is a variable specifier At run time File Manager replaces this variable with the value of the message element printpath specified in the Source Variable 1 field Source printpath At run time the File Manager replaces the Variable 1 variable s in the Source File Spec field with the value of this message element In this example this valueis a file name Destination 1 1 designates the pri nt spool device that prints File Spec the filespecified by printpath This example assumes you have already defined print spool device 1 in thePrint Spooler task At run time when the operator or a task triggers the digital element printtrig File Manager prints the file to Print Spooler device number one FactoryLink ECS Core Tasks Configuration Guide 79 a o o gt o Q D FILE MANAGER Sample File Manager Operations Example 3 REN Rename Example 3 demonstrates how to configure a REN rename operation using Windows file syntax To configure a REN operation fill out the Control panel as shown below Table 4 4 Sample File
6. Usethe Persistence task to save the values of an active actoryL ink appli cation at predetermined ti mes so if F actoryL ink is shut down unexpectedly useful data is not lost Then when you restart FactoryLink with the warm start command line option the Run Time Manager restores the last save of thereal time database from the persistence savefile 9U SISl d PERSISTENCE OVERVIEW The memory based real time database represents the current state values of elements The real time database is a collection of domain instances Elements in the database may have default values which are placed into the domain instance when itis initialized The values of the elements in a domain instanceare lost when the domain instance is closed When the domain instance is opened again its elements are initialized totheir default values This can be a problem if FactoryLink unexpectedly shuts down because of an event such as a power loss or a faulty process Useful information can belost because of the initialization of the real time database to its default values when thesystemis restarted Since most of the information in F actoryLink applications is the accumulation of data over time you cannot recover this data unless it is saved Persistence provides a way of saving the state of an active FactoryL ink application Persistenceis the ability of an element to maintain its value over an indefinite period of time Non persistent elements losetheir
7. Core Tasks Configuration Guide 227 MATH AND LOGIC SYNTAX Structure Directives 228 FactoryLink ECS Core Tasks Configuration Guide Directives are symbols used in statements and determine thetype of statement performed Directives must not beused in expressions Math and Logic recognizes the foll owing directives Table 8 21 Directive Usage x expr x expr Meaning Assign expr to x via database write or locally Assign expr to x via a forced database write if if expr Test portion of if statement then else endif while wend begin or then block else block endif while expr wend begin required If test is TRUE begin then block optional If test is not TRUE begin else block End of if then or if then else block While expr is TRUE do while block End of while block Begin program end or end End program call proc system dedare print lock call proc01 proc block x system dedare short x print starting lock Execute a procedure and return optional keywd Definea procedure Execute a system call and return Define a variable or declare a procedure Print a line of text Lock the database MATH AND LOGIC SYNTAX Structure Table 8 24 Continued Directive Usage Meaning Terms used in this table are defined as follows x is a variable capable of being assigned a value It may bea database
8. FILE MANAGER Using Variable Specifiers in File Specifications The chart bel ow contains examples of variable specifiers using generic syntax Table 4 9 Variable Specifier Examples Variable Description Sample Results Directory subdirectory or filename 968s FLINK Numeric file extensi on 9ed 1 2 3 etc 03d 001 002 003 etc Filenameand extension 8s 03d file 001 8S 3S fil e exe 86 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Using Wildcard Characters in File Specifications UsiNG WILDCARD CHARACTERS IN FiLE SPECIFICATIONS TheFileManager task accepts the following wildcard character specifiersin the source and destination path names asterisk for string replacement 7 question for singlecharacter replacement EX mark D Format path names as follows z e Table 4 10 D source DEVICE NAME DIR NAME SUB DIR NAME WILDC ARD FILESPEC destination DEVICE NAME DIR NAME SUB DIR NAME Do not specify a filenamefor the destination path with COPY asFile Manager does it for you Path names with wildcard characters in the file specifications might resemble the foll owing examples Table 4 11 source DEVICE FLINK SAMPLE SAMPLE destination DEVICE FLINK E XE The following example is of a File Manager operation using wildcard characters using Windows fil e syntax Table 4 12 Sample File Manager Contro
9. 3s subdirectory and file extension Standard node2 cV history exe node2 is the name of a path for a sample exe remote station network station FactoryLink ECS Core Tasks Configuration Guide 97 a o o gt o Q D FILE MANAGER Operating System Notes For Unix Users Configuring File Manager Source File Spec 5 5 and Destination File Spec 5 7 Table 4 21 directory subdi rectory For log history history arc filename extension stand alone systems station directory For nodel flink pic subdirectory networked screen1 pic filename extension Systems Using Variable Specifiers in File Specifications 5 16 The following chart contains UNI X spedific examples of variable specifiers used to desi gnate paths Thelast example shows the path name of a station on a network Table 4 22 Samples of Variable Specifiers in Path Names a NEN NEN NN Standard fflink exe sample exe Base example path 1variable s exe sampl e exe Variable for directory 2 variables s 8s sample exe Variables for directory and subdi rectory 3 variables Pes s sample s Variables for directory subdirectory and file extension 98 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Operating System Notes Table 4 22 Continued Samples of Variable Specifiers in Path Names n Standard node2 flink exe node2 is t
10. 4 y 5 g x y 2 The program evaluates the expression as if it contained thefollowing parentheses f 2 x 3 4 y 5 g x y 2 Statements A statement is an instruction that describes mathematical and or logical operations to be performed in a specified order A diagrammed statement with each of its components labeled is illustrated bel ow Statements can be one of three types e Assignment Statements e Control statements e Procedure alls 220 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Assignment Statements Assignment statements assign values to Math and Logic procedure variables or database elements and can have either of thefollowing forms X expr Only writes if value of x is to be changed valid for procedure variables and database elements or X expr Forced write regardless of variable s present value Turns on change status flags Valid only for database elements where and are the assignment operators Refer to Operators on page 208 for more information Theassignment statement is written whether in a formula or within a procedure with the variable to be changed on the left hand side of the assignment operator and the term or expression whose value should be taken leaving it unchanged on theright hand side Math and Logic computes the expression expr and assigns the result tothe procedure vari able or element 5 x Refer to E xpre
11. F or example IF status 1THEN MSG whatever ENDIF 72 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER File Manager Control Panel This element can haveany of the following status values Table 4 1 n Operation completed Can t open file EX successfully path filename 1 Current operation in 13 Error occurred while gt progress readinga file e D 2 Specified file s not found 14 File could not be created m 3 Requested a line beyond end 15 Error occurred while of file writing to a file 5 Remote system could not 16 Illegal spool device was perform requested acti on specified 6 Attempt tolog ontoa remote 17 Not enough memory to station failed perform operation 8 Network transmission error 97 Illegal filename was occurred specified fthe TYPE DIR position trigger offset values are increased beyond the end of the file the File Manager will read in as many lines as possible set the completion trigger and set the completion status to 3 Refer to Sample File Manager Operations on page 76 for examples of File Manager operations Valid Entry standard element tag name Valid Data Type analog FactoryLink ECS Core Tasks Configuration Guide 73 FILE MANAGER File Manager Information Panel FILE MANAGER INFORMATION PANEL Click Enter to save the information after completing the File Manager Control panel Then click Next to display the File Manager In
12. L after the number to indicatelong analog representation as shown below Notation Long AnalogRepresentation Decimal _upperlim 123456L Hexadecimal _maxvalue OxFFFFFFFFL Minimum and maximum long analog values can range between 2 147 483 647 and 2 147 483 647 Floating point constants To represent floating point constants use standard floating point notation or exponential notation Floating point constants are strings of any digits O through 9 that either contain or end in a dedmal point Exponential constants E xponential constants are strings of any digits O through 9 with an E E e or e preceding the exponential portion of the value The following tabl e shows numerals represented by numeric constants in the various notations just described Ob101 Ob001 Oblll 0123 033 05670222L Hexadecimal Ox45AB OxOaOd OX7CEFOAF 4L Floating Point 465 95 00 24567 90667 Exponential 9780e12 332e 4 54221E234 String Constants A stringis a sequence of ASCII characters enclosed in double quotation marks String constants can be from 0 to 79 characters and the ending character must always bethefinal character in thestring For example thestring ABC is made up of the characters A B C in that order A string with no characters is an empty string and is a valid string An empty stringis a space endosed in double quotation marks If an operator enters more than 79 characters as the value of a message the task truncate
13. OFF counting does not ocaur au o e o2 co o 4 gt FactoryLink ECS Core Tasks Configuration Guide 55 PROGRAMMABLE COUNTERS Programmable Counters Information Panel If the tag specified in this field is not already defined a Tag Definition panel is displayed when you dick on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type digital UpClock Name of an element that causes the value of the Current Value element present count to move toward the Terminal Value count limit When a 1 ON is written to the Up Clock element the valuein the Current Value element is increased by the amount specified by thelncrement Value element described below If the Preset Value starting count is less than the Terminal Value the Increment Valueis added to the Current Value If the Preset Valueis greater than theTerminal Value the Increment Value is subtracted from the Current Value If the tag specified in this field is not already defined a Tag Definition dialogis displayed when you dick on Enter with a tag type of digital in the Type field Accept this default At least onetype of clock must be defined that is an entry is required in either the Up Clock or Down Clock fiel d Valid Entry standard element tag name Valid Data Type digital Down Clock Name of an element that causes the value of the Current Value element present v
14. Procedure Variable Types MAILBOX N A Floating point data items conform to ANSI double precision standards The FactoryL ink data type MAIL BOX has nocounterpart in Math and Logic MAILBOX data types cannot be defined as local procedure variables Usethefollowing guidelines to choose which data type to usein a particular instance e Ifthe value will ever need to maintain a fractional portion to the right of the dedmal point define it as a FLOAT floating point 8 e Ifitisa flag or an ON OFF typeof decision point dedareit as a DIGITAL this is analogous to the boolean or logical data types in other programming languages e If itis an integer within the defined range of the machine declare it as either an ANALOG if it fits in the short range or a LON GANA long analog if it will not fit in the short range but is still expected to be within the stated allowable range for integers Integers are numbers without a fractional portion Declaretext variables to be written to the screen or to a fileas MESSAGE D pus 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 199 MATH AND LOGIC SYNTAX Structure For Windows NT and Windows 95 The 64K barrier under segmented architectures such as Microsoft Windows NT and Windows 95 presents a limitation on the sizeof some variable data in Math and Logic N either global nor local variablearrays or data items such as string arrays or message buff
15. a o o gt o Q D FILE MANAGER File Manager Control Panel If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type digital Completion Status Name of an element set by the File Manager task to indicate the status of an operation The Completion Status element can be referenced by any FactoryLink task ind uding the F ile Manager to handle file error situations or trigger the next File Manager table tostart an operation If the tag specified in this field is not already defined a Tag Definition dialogis displayed when you dick on Enter with a tag type of analog in the Type field Accept this default The File Manager writes an analog value to the Completion Status element toindicate the status of a file management operation Use the task s TASKMESSAGE_U 6 tag toreport messages on the application screen in addition tothe Completion Status tag For example if you get a status 12 in the Completion Status tag you also see the message Can t open file path filename in the tag TASKMESSAGE U 6 If you want to use IML for this function set up a math procedure triggered by the status tag itself In the procedure assign the appropriate ASCI I string for each possible status code toa message tag in a series of IF THEN statements
16. e FactoryLink ECS Core Tasks Configuration Guide 151 CONFIGURING MATH AND LOGIC Entering CML Into the System Configuration Table ENTERING CML INTO THE SYSTEM CONFIGURATION TABLE Beforestarting CML for the first time you must enter the name of its executable fileintothe FactoryLink system configuration For each domain in which you are configuring CML you must enter the name of the applicable executable in the System Configuration Information panel Compl ete the foll owing steps to enter the CML filename If you configured CML to run in both domains you must perform this proceduretwice once for each domain 1 Open the System Configuration Information panel from the Configuration Manager Main Menu for the domain s in which you configured CML Enter R inthe Flags field to start CML at run time Enter CML in the Task Name field Enter Compiled Math and Logic in theDescription field a A O N Enter the executable name in the Executable File field for the domain in which you opened the System Configuration Information panel either e FLAPP USER BIN CML CUSER EXE for the user domain e FLAPP SHARED BIN CML CSHARED EXE for the shared domain where FLAPP is the environment variable set tothe path of the application files For example C PROCESS USER BIN CML CUSER EXE or C PROCESS SHARED BIN CML CSHARED EXE J Use the appropriate syntax for your operating system 6 Click Enter to save the i
17. if current drive successfully set to drive a 242 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes For OS 2 Table 9 5 Directory Path Control Functions getdir string getdir dri ve Returns the current path of specified drive drive 20 current drive drive 1 a drive 22 b and so on Example string getdir 1 Therefore string aA getdri ve drive getdrive Returns current disk number drive 1 a drive 22 b and so on Example drive getdrive Therefore drive 2 if current driveis drive b setdir status Returns zero for success Sets new setdir drive path current dri ve di rectory drive 20 current drive drive 21 a drive 22 b and so on Example status setdir 1 aA test Therefore status 0 if current drive directory successfully set to a test FactoryLink ECS Core Tasks Configuration Guide 243 D 5 D 5 2 m fo 2 7 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 5 Directory Path Control Functions Continued setdrive stat setdrive drive Returns zero for success Sets new current drive drive 1 a drive 2 b and soon Example stat setdrive 1 Therefore stat 0 if current drive successfully set to drive a For UNIX Table 9 6 Function Sample Format Description setdir status setdir path Returns zer
18. is runningin the CML mode it converts the programs into C source code Other such keywords may exist Refer tothe user manual supplied with the particular C compiler in use The keyword begin is interchangeable with the opening brace and the keyword end is interchangeable with the closing brace You can use either the keyword or the brace anywhere inside Math and Logic programs Do not write procedures that use forms of these keywords as names because they may not be upward compatible with later releases of Math and Logicand may cause unpredictable system behavior during executi on 178 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Comments COMMENTS Comments are text used to annotate a program Comments are not executable code and are ignored during execution Effective commenting should besimilar to effective naming It should be dear and concise Three areas to consider are e Usage When defini nga function explain its purpose what the argument types and uses are and external side effects or does it alter global variables or tags and why e Scope When defining variables explain the scope and what procedures write tothem and usetheir values e Reference When you reference a function especially if itisin a different file note the file it is defined in and what it does to local variables Comments begin with the pound sign and end with the end of line character 1 They can be
19. read on the Celsius scale Because the temperature will never drop bel ow freezing this means a minimum raw value of 0 degrees on the Celsius scale The highest value for raw data Either a constant value or a tag can be specified in this field For this example raw data is being read on the Celsius scale The temperature will never rise above boiling or a maximum raw value of 100 degrees on the Celsius scale 276 FactoryLink ECS Core Tasks Configuration Guide SCALING amp DEADBANDING Defining Scaling and Deadbanding Operations Minimum Eng Unit The lowest value for scaled data Either a constant value or a tag can be specified in this field For this example scaled data is being converted toa Fahrenheit scale Thetemperature will never drop below freezing or a minimum engineering unit value of 32 degrees on the Fahrenheit scale Maximum Eng Thehighest valuefor scaled data Either a constant value or a tag Unit can be specified in this field For this example raw data is being read on the Fahrenheit scale Thetemperature will never rise above boiling or a maxi mum engineeri ng unit value of 212 degrees on the Celsius scale g 9 fb E 2 fb 5 E e Si Scaling and Deadbanding Information EMT E Edit View Utilities Exit Help Bl xDeadband Deadband Scaling Value Abs Pct Lock Tag 2 PCT disabl temp Cancel Enter Exit KU i Z Deadband Value The amount in either absolute value
20. the analog variable but it is not automatically converted to floating point If you anticipate working with large values such as this or detect their presence during the execution of a program it would be wiseto provide for the conversi on of the value Force this conversion by creating a floating point variable fptemp and setting fptemp 2 0Xtemp D pus 2 5 2 r e c O FactoryLink ECS Core Tasks Configuration Guide 203 MATH AND LOGIC SYNTAX Structure Floating point value overflow correction Although it is rare overflow conditions can also occur in operations on floating point data types The result of an overflow is unpredictable and usually fatal therefore set up the programs to detect and avaid overflow conditions F or example division by zeroal ways results in overflow If this happens modify the programs invol ved so any variable about to be used as a divisor is tested for zero and provide for a method to skip the operation or to write an alert message whenever these conditions arise If overflow occurs check stri ng concatenation joining operations to determineif they are resulting in the assignment of inappropriate strings to floating point values This is discussed in String conversion bel ow and in Example 4 on page 206 String conversion A string type can be used in an arithmetic or logical operation if and only if the string is a sequence of digits indudingthenatural logarithm constant
21. 2 5 2 r e O RE 2 FactoryLink ECS Core Tasks Configuration Guide 197 MATH AND LOGIC SYNTAX Structure You can also call a procedure or function defined in another program file If no triggered procedures exist in the referenced program file then the Math and Logic Triggers table must contain an entry for that file n the example below F uncl is called in PROC1 PRG but it is defined in PROC2 PRG Therefore PROC2 requires an entry in the Math and Logic Triggers Table PROCI PRG PROC2 PRG DECLARE PROC funcl PROC PROC PROC PROC2 BEGIN BEGIN CALL funcl Funciis called in END PROC1 PRG but it is defined in PROC2 PRG Therefore PROC2 PROC funcl requires an entry in BEGIN the Math and Logic Triggers Table END END w Math and Logic Triggers Information 5 d Edit View Utilities Exit Help Trigger Tag Procedure Mode Description 3l secl PROCI COMPILED Procedure for calling func PROC2 COMPILED Procedure for containing func1 NENNEN E Cancel Enter Exit KT tj 2 198 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Data Types and Variable Types Because Math and Logic supports both elements and procedure vari ables procedure variables can be defined as any of the FactoryL ink data types The table below shows the F actoryLink data types and their corresponding vari able types Table 8 3 FactoryLink Data Types
22. 2 r e FactoryLink ECS Core Tasks Configuration Guide 127 MATH AND LOGIC OVERVIEW Triggering Calling TRIGGERING CALLING Triggering Developing Triggering Schemes Multiple procedures are executed using thetriggeri ng method of this system To develop the most effi cient triggering scheme consider the following e What intervals or circumstances trigger individual procedures at a reasonable rate for this data e Trytouse conditional event triggering based on changing data so procedures run when data is change state driven or tri gger driven Single threaded Task This task is single threaded This means triggered procedures are ued and executed in the order in which they aretriggered A procedure that does not complete because of an infinite loop for example will stop the rest of the procedures from executing When running one procedure set a trigger for the next Calling You can both trigger and call procedures Trigger Procedure f you want to wait until one procedure has completed before executi ng another or if your procedurehas to execute when an event occurs trigger a new procedure Calling Procedure f you want a procedure to occur immediately you must call the procedure This system uses a complex cueing process that necessitates using calling procedures if you want them to occur in a distinct order 128 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC OVERVIEW Triggering
23. 3 Enter FLRUN tobegin the compile process during which CML creates the executables 4 f you recompiled on a system other than the run time system copy the CML executables from FLAPP USER CML and or FLAPP SHARED CML tothe same path on the run time system CML does not recompile every time you enter FLRUN Once CML has compiled the program files into executable files it recompiles only if you change a program file 154 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC How CML Operates How CML OPERATES CML indudes three utilities that create the executables CML uses at run time e MKCML e PARSECML e CCCML Each utility performs a specific role in the compile process The compile process occurs in the following calling sequence of the CML utilities beginning at run time when you enter the FLRUN command 1 FLRUN calls the MKCML utility 2 MKCML calls CTGEN which ensures theMath and Logic CT fileis up to date 3 MKCML calls PARSECML to produce C files C code from the program fil es 4 MKCML then calls CCCML tocompilethe C files into object files using an external compiler and tolink the object files with library files into binary executables usi ng an object linker The following diagram illustrates the calling hierarchy of the CML utilities CML Utilities Call Hierarchy D er 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 155 CONFIGUR
24. COPY PRINT REN and DEL operations Name of an element whose valuetells theFile Manager wherein a directory to start listing files or wherein a fileto start typing TheFileManager starts reading after the line number specified by the value of the Position Trigger element For example if the value of the Position Trigger element is 6 the File Manager begins reading the file at lineseven The number of lines displayed or the number of fil es listed depends on the number of TagName elements defined in theFile Manager Information panel descri bed below Y ou can configure the system so at run time you or any FactoryL ink task can changethe value of this element sothe File Manager starts at a different point in a directory or fil e and shows a different subset of information Do not specify the same el ement name for DIR and TYPE operations If the tag specified in this field is not already defined a Tag Definition dialogis displayed when you click on Enter Accept this default Valid Entry standard element tag name Valid Data Type analog Command File operation to be performed This can be one of the following COPY Copies the sourcefile to the desti nation file Spedfy both the source and destination paths This operation does not require that you complete a File Manager I nformation panel a o o gt o Q D REN Renames thesourcefile tothe destination file Sped fy both the source and destination paths Both the
25. Calling Completing the Calling Sequence e Enter FLRUN command FLRUN callstheMKCML utility e MKCML calls PARSECML to produce C files C code from the program files e MKCML then calls CCCML tocompile the C files into object files using an external compiler and tolink the object files into binary executables using an object linker D er 2 5 2 m fo ol FactoryLink ECS Core Tasks Configuration Guide 129 MATH AND LOGIC OVERVIEW Triggering Calling 130 FactoryLink ECS Core Tasks Configuration Guide Chapter7 Configuring Math and Logic Touse Math and Logic you must first create a Math and Logic program using the three Math and Logic configuration tables e Math and Logic Variables table e Math and Logic Triggers table e Math and Logic Proceduretable This chapter describes how to configure the M ath and Logic tables The number of elements triggers and programs you can define is limited only by the amount of available memory the operating system and or the compiler CML only Refer to the documentation supplied with the compiler for detail s on compiler limitations D er 2 2 2 r e 2l FactoryLink ECS Core Tasks Configuration Guide 131 CONFIGURING MATH AND LOGIC Text Editor TExT EDITOR When working in Compiled Math and Logic you use a text editor to select and edit information and to enter a new name Y ou may also choose to create your own proce
26. Configuring the Math and Logic Tables CONFIGURING THE MATH AND Locic TABLES Complete the configuration tables in the following order e Math and Logic Variables table e Math and Logic Triggers table e Math and Logic Procedure table Choosing a Domain Math and Logic can operate in either the SHARE D or the USER domain Except in cases where all tasks must sharethe same Math and Logic data we recommend using the USER domain for Math and Logicin order to prevent unforeseen interference between tasks Before opening the M ath and L ogictables ensure the current domain selected is USER in the Configuration Manager Domain Selection box Choosing a different domain for a task after it has been configured without making supporting changes in theapplication can result in unpredictable system behavior D er 2 5 2 r e 2l FactoryLink ECS Core Tasks Configuration Guide 137 CONFIGURING MATH AND LOGIC Math and Logic Variables Table MATH AND LOGIC VARIABLES TABLE To configure the Math and Logic Variables table 1 Choose Math and L ogic Variables from the Configuration Manager Main Menu to display the Math and Logic Variables Information panel 4 Math and Logic Variables Information olx Edit View Utilities Exit Help a Tag Name Tag Type Tag Description a Cancel Enter Exit 4 zl 2 Specify the foll owing information Tag Name Enter the name of an element or tag to b
27. DOT llocvar 0 318 T_PRINT 00000000 293 T_STRING You have entered the body of PROC test prg n 311 T DOT PRINT You have entered the body of PROC 260 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables test prg n 276 T_WHILE 00000000 320 T_LVAR LLOCVAR 290 T_INT 00000003 259 T LE 00000000 277 T BEGIN 00000000 311 T DOT WHILE llocvar lt 3 318 T PRINT 00000000 293 T STRING INSIDE THE WHILE LOOP n 311 T DOT PRINT INSIDE THE WHILE LOOP n 260 T EQ llocvar 320 T_LVAR llocvar 290 T_INT 00000001 269 T ADD 00000000 311 T DOT llocvar llocvar 1 278 T END 00000000 311 T DOT WEND 365 T CCODE printf FactoryLink is the Best in 365 T CCODE for i INITVAL I lt UPBOUND i INCREMENT 365 T_CCODE 7 INITVAL UPBOUND INCREMENT are defined and declared in test h 365 T_CCODE Body of for loop must be careful of referencing m 365 T CCODE factorylink tags in CBEGIN CEND block S must assign the tag to a local 2 365 T_CCODE outside of block and then process the local r and then assign value back e 365 T CCODE to tag outside of the CBEGIN CEND bloc zi FactoryLink ECS Core Tasks Configuration Guide 261 COMPILED MATH AND LOGIC Generation of CML Executables 365 T CC 365 T CC 365 T CC 365 T CC 2 8 T EN O T 311 T DOT OD OD OD OD D
28. ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Makefiles Math and Logic Domain Makefile The first time you choose Math and Logic Domain Makefile from the Main Menu an empty text editor is displayed because a domain specific makefile does not exist You can create one using the master makefile CML MAK inthe FLINK CML directory as a model To create a domain specific makefile Copy CML MAK fromthe FLINK CML directory to either e FLAPP USER CML directory for the user domain e FLAPP SHARED CML directory for the shared domain Open the Main Menu and ensurethe current domain selected in the Configuration Manager Sel ection box matches the domain of the makefile you are creating Choose Math and Logic Domain Makefile from the Main Menu to display a text editor contai ning the domain spedfic makefile CM L MAK copied in Step 1 Edit the fileas required Any definitions in the domain specific makefile in the application directory override the definitions in the master makefilein FLINK CML directory Save and exit the file D er 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 255 COMPILED MATH AND LOGIC The CML Process THE CML PROCESS When you have completed configuring the three tables Variables Table Triggers Table and Procedures Table you have created the processing procedures for running programs in CML The following discusses the process involved in producing
29. Math and Logic was configured to access the analog elements lastcar and tempset and thelong anal og element temp for values to use in its calculations The tag types and tag descriptions are displayed in the panel when you click Enter After all visible fields are complete click on Enter to save the information and return tothe Main Menu N 91607 pue yen FactoryLink ECS Core Tasks Configuration Guide 139 CONFIGURING MATH AND LOGIC Math and Logic Triggers Table MATH AND LOGIC TRIGGERS TABLE To configure the Math and Logic Triggers table 1 Choose Math and Logic Triggers from the Main Menu todisplay the Math and Logic Triggers Information panel u Math and Logic Triggers Information of x Edit View Utilities Exit Help E Trigger Tag Procedure Mode Description mi Cancel Enter Exit 2 Specify the foll owing information Trigger Tag Procedure Enter the name of an element whose value can trigger a Math and Logic procedure The associated procedure is executed either when this element s val ue changes to 1 if the element is digital or whenever the element s value changes for all other data types Ifthereis a procedure or program file that should be loaded but does not have an associated trigger element that is it is invoked directly from other programs you have defined and loaded specify the name of that file s main procedure on a separate line and leave the Trigger Tag fiel
30. OnTime C Set Change Status ON r On Exception Set Change Status OFF Cancel Edit Help 2 Choose the required options from the Persistence section of the Tag Definition dial og Use Domain Saves the valueof the persistent element according to the options Settings chosen for the domain s persistence The Saving and Restoring options are disabled when this option is chosen Deselect Use Domain Settings to enablethe Saving and Restoring options for this element specifically FactoryLink ECS Core Tasks Configuration Guide 19 PERSISTENCE Configuring Persistence for Individual Elements Saving Indicates when the value of the persistent element is saved This can beone of the following On Time Saves the val ue of the persistent element on a timed trigger On Exception Saves the value of the persistent element whenever its value changes On Time and On Exception Saves the value of the persistent element on a timed trigger and when its value changes Restoring Indicates how torestore the persistent element This can be one of the following Set Change Status ON Restores the persistent el ement with its change status bits set to 1 ON after a warm start Set Change Status OF F Restoresthe persi stent el ement with its change status bits set to 0 OFF after a warm start Thisisthe default No Options Selected The element is not marked as persistent 20 FactoryLink ECS Core Tasks Configurat
31. Table 5 1 zs SES E HUS rcr Path and File Name Format System Specifications e Windows pt1l DRIVE DIRECTORY z NT COM1 SUBDIRECTORY FILE EXT Windows lpt2 95 and COM2 OS 2 pt3 Note n OS 2 these values must be entered inlower case UNIX devttyn or d DIRECTORY SUBDIRE CTORY ev lpn FILE EXT wheren is the unit number FactoryLink ECS Core Tasks Configuration Guide 107 PRINT SPOOLER Configuring the Print Spooler Initialization Sequence File Separator Sequence Thelnitialization Sequenceis defined by enteringthe action you want it to perform in the Initialization Sequence column of the Print Spooler Information panel The Initialization Sequence performs the action s you define once at the beginning of a Spooler session TheFileSeparator Sequence is defi ned by entering the action you want it to perform in the File Separator Sequence column of the Print Spooler Information panel The File Separator Sequence performs the action s you define at the end of each file of a Spooler session Enter an alphanumeric string of between 1to 16 characters for use only with the Report Generator and File Manager not for use with the Alarm Supervisor command sequences that automatically send characters tothe printers to separate the output of different files These command sequences can consist of two types of characters Display characters P rintable ASCII characters such as A that ca
32. about an operation e Parentheses U se these to group sub expressi ons Their main purposeis to override the precedence of operations by forcing the evaluation of other operations first Also use parentheses to enclose arguments being passed toa function or procedure e Brackets Usethese to enclose array indices For double or tri ple indexed arrays use multiple pairs of brackets 214 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Commas Usetheseto separate the arguments if more than one being passed to a function Also use commas between types in procedure declarations and between type argument name pairs in procedure defi nition header Statements proc statements Refer to the following chart for additional information Thefollowing chart illustrates special grouping operators Table 8 13 Operator Type Usage Operands Operation Name N A A N A any type left open bracket N A N any type right dose bracket N A N A any type comma between arguments Change status Operators The dhangestatus operator checks whether the value of a element has changed since Math and Logic s last read operation returning TRUE if the element s changestatus bit has been set for any reason including a forced write operation Use of the change status operator itself resets the element s change status bit with respect to Math and Logic The chart below shows the c
33. altered it is out of the domain of USDATA technical support TARGET LAPP FLDOMAIN cm cf LDOMAIN exe This is the desti nation executable D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 163 CONFIGURING MATH AND LOGIC Calling C Code CALLING C CODE To call C code in a Math and Logic program use the CM L spedfi c keywords e cfunc Cbegin e cend Using cfunc Use the keyword cfunc to ded are standard C functions and user defined C functions as callablein line functions within a CML program In line C functions allow a CML program to call a C function directly without opening a C code block Thefunction must be ded ared before it is called The C code generated by CML provides prototypes for standard library functions however it does not indude prototypes for user defined C functions Y ou must provide function prototypes for all user defined functions nduding a function without a prototype may result in compiler warnings regarding the missing functions Use only C functions that use the Math and Logic data types of SHORT LONG FLOAT and STRING with cfunc Although a C function may use any data type internally its interface to Math and Logic must use only these types Inthefollowing example testfuncis declared to usefour arguments whose values are SHORT LONG FLOAT and STRING data types and toreturn a value with a SHORT data type DECLARE cfunc SHORT testfun
34. an executable file for the given domain from the PRG files CML is made up of several F L utilities along with a third party ANSI C language compiler working together at run time to generate ANSI C code from the prg files you created This C codeisthen compiled and linked to produce an executable for each domain configured torun in CML This process begins when you createthe prg files in configuration manager with the procedure editor At run timeor from running FL utilities the prgfiles are parsed parseaml N user V2 CJ which produces C code from the procedure files The compiler is then called to produce the associ ated object files This is followed by the linker called to link the objects together to generatethe executable for the gi ven domain This occurs in both the SHARE D and the USER domains The associated executables are F LAPP YUSER CML CUSER E XE for theU SER domain F LAPP YSHARE D CML CSHARE D E XE for the SHARED domain 256 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables GENERATION OF CML EXECUTABLES The executables generated are FLAPPYSHARE D CML CSHARED EXE FLAPPYUSER CML CISER EXE 1 Validation Thefirst step in the process is saving the procedure with the F actoryL ink procedure editor When you save the grammar syntax of the procedureis checked by the math validation utility Always make sure all procedures validate and all lines areless than
35. command file syntax is the same for all operating systems Table 4 6 Sample File Manager Control Panel Per Table DIR Designates the name of a DIR operation Name Command dirtrig Name of the digital element used to trigger the dir Trigger operati on Position dirscroll Name of the analog element that controls the output of Trigger the DIR command Command DIR Designates a DIR operation Source 96s This field contains a variablespecifier which theFile FileSpec Manager replaces at run time with the value of the message element dirpath desi gnated in the Source Variable 1 field Source dirpath Atrun time when the value of the digital element Variable 1 dirtrigis forced to 1 ON File Manager displays the directory specified by dirpath Because DIR operations do not need a destination the Destination Variable fields are blank 82 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Sample File Manager Operations Table 4 6 Continued Sample File Manager Control Panel Sample LE Entry Explanation At run time when the value of the digital element dirtrigis forced to 1 ON File Manager reads the directory sped fied in the Source Tag 1 element dirpath File Manager starts reading after the line number specified by the Scroll element dirscroll In this example eight lines of text from the specified file are read into message elements dirlin1 dirlin2 dir
36. digital elements in the FactoryLink real time database The Event and Interval Timer task uses the SHARE D domain Before opening and configuring the E vent and Interval Timer task ensure the current domain selected is SHARED in the Configuration Manager Domain Selection box Event Timer Information Dialog Use Event Timer to define events that only occur not more than once every 24 hours For example use event ti mers to start or stop reports and as triggers to read and writerecipefiles Choose E vent Ti mer to display the Event Timer Information dialog u Event Timer Information mf x Edit View Utilities Exit Help Tag Name Year Mon Day DOW Hours Mins Cancel Enter Exit al mi oy 40 FactoryLink ECS Core Tasks Configuration Guide EVENT AND INTERVAL TIMER Configuring the Event and Interval Timer Task Following arefield descriptions for this dialog TagName Element name for example time8am to be assi gned to the event When the event occurs the element is forced to 1 so its change status bit is set to 1 The Timer task resets all event timers back tozero at midni ght Y ou can assign more than one element to the same event If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter with atag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type di
37. e FactoryLink ECS Core Tasks Configuration Guide 181 MATH AND LOGIC SYNTAX Constants For example to define a symbolic constant PI torepresent the value 3 14159 use either CONST PI 3 14159 UN or CONST PI 3 14159 Then you can usethe constant PI wherever needed in place of the value 3 14159 Numeric Constants Numeric constants can be assigned to digital analog long analog or floating point elements as well as to numericlocal variables Constants can be used in expressions wherever a numeric operand argument is valid provided they are not the objects of an assignment operator The object of an assignment is the argument on the left hand side of an assi gnment operator that is the argument assigned a new value Because constants cannot take on new values they must never be placed on the left hand side of an assignment operator M ath and Logicuses threetypes of numeric constants Integer e Floating point e Exponential Integer constants Y ou can assign integer whole number constants to elements and local variables depending on their data types and the operati on For an element its data type must be one of the F actoryL ink data types digital analog or long analog and its value must be an integer For alocal variable its data type must be one of thelocal variabletypes short or long and its value must be an integer 182 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGI
38. fiers H owever if the same files are to be used for all operations do not use variable specifiers Use the Source and Destination Variable fields to designate variables to replace the variable specifiers You can indude up to four variable specifiers each one designated by a leading percent sign in the path or file name These variable spedfiers indicate a portion of the path or filename that is variable replaced with data from elements when the file operation is performed The variables can be digital analog long analog floating point or message elements Multiple variables can be used together as in a filename and extension for example 8s 3s a o o gt 5 Q D If you want to vary the actual path files used in either the source or destinati on paths use one or more of the four variables and xx type specifiers to dynamically build these at run time from tags Otherwise simply hardcode the exact path file names desired and leavethe four tag variablefields blank The data type of the element must match the variable specifier type Variable specifiers and their data types arelisted bel ow Table 4 8 Variable iE TELE FactoryLink Specifier Specifier Type Data Type d Deci mal Digital Analog Long Analog Floating point 95 String Message Refer to F actoryLink Fundamentals for more information about variable specifiers FactoryLink ECS Core Tasks Configuration Guide 85
39. mit for the number of bottles per case is 20 The Increment Value of 1 represents one bottle When counting is triggered each bottle counted increases the current count of bottles starting with 0 in the case by 1 until the case contains 20 bottles until the Current Value reaches the Terminal Value of 20 When the case contains 20 bottles when the Current Value reaches the Terminal Value the Counter task indicates the case is full by force writing a 1 ON tothe Positive Output el ement and force writing a 0 OFF tothe Negative Output element At this point if AutoClear Y ES the Current Valueelementis reset to 0 the P reset Value and the count can begin again If AutoClear NO the current Value element remains at 20 the Terminal Value until another task writes a 1 ON to the dear element indicating the count can begin again The count does not continue past 20 the Terminal Value Each timethe bottle count reaches 20 the Terminal Value the Counter task again force writes a 1 ON anda 0 OFF to the Positive and Negative Output elements When AutoClear YES or when the Clear element is triggered the bottle count is reset to 0 the Preset Value ready for a repeat of the counting process Example Two You can set up another task such as EDI or Math and Logic to react to a deviation such as a defective bottle during the count by adjusting the count To adjust the count that task writes a 1 ON tothe Down Clock element
40. name is not used on stand alone systems flags arethe optional flags This can beone of the following NONE Thisisthe default B Binary file S Suppress Beginning and End of File Used to concatenate fi les spool device is the optional spool device defaults to 1 legal devices are 1 through 5 Names of elements whose val ues replace the variable spedfiersin the destination path name These fields work in conjunction with the Destination Format field to form the path of the fil eto which the File Manager performs operations The value of the element in the Destination Variable 1 field replaces the first variable specifier the value of the element in the Destination Variable 2 field replaces the second variable specifier and so on If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter f you use vari able specifiers make the data type match the variable spedfier type Refer to FactoryLink Fundamentals for informati on Valid Entry standard element tag name Valid Data Type digital analog longana float message Name of an element used to indicate that a file management operation is compl ete not necessarily successful This element if entered is set by File Manager and can bereferenced by any FactoryLink task including File Manager to monitor file management operations or trigger an event FactoryLink ECS Core Tasks Configuration Guide 71
41. nested or written on lines by themselves If the line of code to be annotated is short they can be written on the same line as the code Always indude comments in procedures for later reference They provide programmers with information about the intended function of the procedure Comments are also useful on variable dedaration lines to explain how the variable is to be used and its value limits Standard coding practice calls for one comment for approxi mately every five lines as well as at the top of any loop and before a function call D pus 2 5 2 m fo m FactoryLink ECS Core Tasks Configuration Guide 179 MATH AND LOGIC SYNTAX Comments The fdlowing example illustrates the use of comments declare global variables DECLARE SHORT init_flag PROC EXAMPLE BEGIN DECLARE SHORT _n DECLARE SHORT tub array 100 init flag 0 IF NOT init flag THEN pressure 10 tubs 20 tempset 71 Set tub arrayL n n n0 WHILE n lt tubs tub array n n n n l WEND init flag 1 ENDIF 1 Continue here with main secti END 1 Do initialization procedure bu decision flag 1 declare local variables t only once initially init flag 0 J Initialize database variables force write pressure in product tubs J number of tubs to fill if degrees Celsius warm for n 0 1 tubs 1 start loop index at 0 s dt done so set init flag ON on of
42. not limited to their appearance in Math and Logic code but is also limited to what the name becomes in the generated C code For example special characters become by the parsing routing Therefore declarations like declare short lu 1lu declare short lu lu declare short lu lu all become declare shortlu lu with potentially confusing results such as duplicate definition errors or changes in one variableare reflected in another 174 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Procedure Tokens Tag Naming Conventions These conventions are a combination of the standards used in programmi ng and standards borrowed from existing F actoryLink applications These conventions are necessary when using the F LDEM O application In a genuine FactoryL ink application that could have 10 000 or more different tag names several developers and takea year or two to complete they are necessary An informative tag name should contain the foll owing e Application meaning e FactoryLink module e Type function e Domain The application meaning should be clear and concise to meet the typing requirement The module and type portion should have standard abbreviations The application meaning should be less than eight characters to meet the configuration environment li mits Three major constraints exist for naming tags e The need for information e Theneed to minimize typing e The need for limited column widt
43. once on the Warm Start icon to seled it 4 Click Settings In Optional Parameters type w 5 Close window Edit the command line as flrun w d nshared lt ret gt or add the w tothe script file using above syntax Beforestarting the Run Time Manager the FLRUN command executes the RE SOLVE program to check the persistence save file for any configuration changes you made The need to check for configuration changes is discussed in Resolving Configuration Changes on page 17 16 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Resolving Configuration Changes RESOLVING CONFIGURATION CHANGES After you shut down a FactoryLink application you might reconfigure part of the application usingthe Main Menu or the Application Editor This means the elements and their values stored in the persistence savefile either may not exist or might not havethe same data type when you restart the application Before each F actoryLink session is restarted the element names stored in the persistence save file must be checked for changes against the OBJ E CT CT andthe DOMAIN CT files This resolving of configuration changes is done by the RE SOLV E EXE resolve on UNIX systems program The FL RUN command automatically executes this program before it starts the Run Time Manager for a particular FactoryLink sessi on 9U SISl d The RESOLVE program serves three purposes Creates the blank persistence save file thefirst
44. or percent of total value that when applied creates a rangeon either side of the valuein which the recalculated value does not have to be written tothe database For this example temperature changes of less than 296 in ashort period of time are not of concern for this process This would be reflected in a deadband value of 2 with PCT chosen for the Deadband Abs Pct field If a tag name is specified for the deadband value rather than an integer no deadbandi ng occurs until a value is written tothe specified tag from the database FactoryLink ECS Core Tasks Configuration Guide 277 SCALING amp DEADBANDING Defining Scaling and Deadbanding Operations Deadband Enter Absolute or Percentageto indicateif the deadband value Abs Pct specified is an absol ute number of engineering units EUs or a percentage of the scaled value range For this example a deadband value of 2 percent PCT has been selected Equivalently since 296 of 18096 F ahrenhat is 3 6 degrees you could specify an absolute ABS deadband of 3 6 Scaling Lock Tag Usethis field to temporarily disable the scaling feature for the scaled tag When the Scaling Lock Tag has a non zero value changes made to the tag are not propagated to their rel ated members After the changes to that function have been made and thefundion has been re enabled the current raw valueis scaled and written to the scaled valuetag n this example if the incoming tank temp data needed to be di
45. procedure df PROC EXAMPLE 180 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Constants CONSTANTS A constant is a numeric or character valuethat remains unchanged during the execution of a program Constants can be used anywhere in a calculation a numeral can be used and arefaster to use in calculations than variables Constants are especially useful in applications in whi ch the boundary value of a loop or array must be modified When the constant is modified its value can be changed in only one place within the application instead of in many different places For example a factory upgrades from three drying beds to five and the constant BED MAX is used as e A loop index to index through the operations on the groups of beds e An array index for the array containing informati on on each bed e Asa limiting factor on the number of beds polled The valueof BED MAX can be modified from 3 to 5 thus preventing the need for massive search and repl ace operations on hard coded values Threetypes of constants are discussed here e Symbolic e Numeric String Symbolic Constants A symbolic constant is a name you defineto represent a single known numeric value You can define a symbolic constant using either of two formats CONST name value Ne or CONST name value Fi S E You can use either an equal sign or a space to separate the name and value D pus D 5 2 r
46. real time database from the persistence save file It restores the values of the persistent elements tothe last values saved by Persistence To perform a warm start of FactoryLink usethe warm start argument w In Windows and OS 2 add the w to the command line for the icon used to start FactoryL ink in UNIX either pass the w tothe F LRU N command or add it tothe linein thescript fileused tostart FactoryL ink See the table below for details FactoryLink ECS Core Tasks Configuration Guide 15 PERSISTENCE Principles of Operation Table 1 1 Starting FactoryLink using the w warm start Windows Create a new Start F actoryLink icon following the steps below 1 Click onceon the Start FactoryLink icon to select it 2 Click Edit Copy 3 Click Edit gt Paste A copy of the Start F actoryLi nk icon is pasted into theF actoryLink Program Group Itislabelled Copy of Start FactoryLink 4 Changeits properties by a clicking File Properties b dicking in the command line C pressi ng the End key to get to the end of the command line d adding w to the end of the command line preceded by a space 5 Click File gt Rename and change the icon s label to Warm Start FactoryLink Press the Enter key Create a new Run Ti me Manager icon following the steps below 1 Right dick once on the Run Time Manager icon to select it 2 Click Copy a Enter Warm Start for the icon s new name b Click Copy 3 Right dick
47. source and destination paths must be the same that is they must point tothe same directory This operation does not require you complete a File Manager Information panel FactoryLink ECS Core Tasks Configuration Guide 67 FILE MANAGER File Manager Control Panel DEL Deletes the source file The DEL command requires onl y the source path the destination path is ignored This operation does not require you complete a File Manager I nformation panel PRINT Causes thefile specified by the source path to be printed on the device specified by the destination path The destination path must contain the name of a device known tothe Print Spooler task This operation works only with the Print Spooler and does not requirethat you complete a File Manager Information panel DIR Displays a list of all files in thedirectory specifi ed by the source path which can include wildcard characters The desti nation path is ignored This operation requires you complete a File Manager Information panel and you define output text objects in Graphics to display lines from the file TYPE Displaysthe contents of thesourcefile The desti nation path is ignored This operation requires that you complete a File Manager Information panel and that you define output text objects in Graphics to display li nes from the file Note that File Manager reads in only 80 characters at atime and puts the rest of the line if more than 80 characters into the next mess
48. syntax errors Choose Validate from the File menu If there are no errors the system reports nothing If there areerrors the following message is displayed ra g Canceled CN Validation error N ES 5 Choose Save from the File menu to save the procedure 6 Choose Exit to exit the Math and Logic Procedure panel and return to the Main Menu If you try to exit a procedure containing validation errors the following messageis displayed A Warning N Validation error Select OK to continue de E This warning reminds you errors exist so you do not run the application until the errors are corrected A procedure that fails validation is not loaded at run time and can cause Math and Logicto fail Exiting an empty procedure results in a validation error however the existence of an empty procedure will not affect the task during run time Correcting Validation Errors 1 Click OK from the Validation error message box Thelines of the procedure that the system could not vali date turn red and the cursor moves tothe first non validated line 2 Todisplay error help for a non validated line mark the line marked as non validated red and placethe cursor on the line 3 Choose Error Help from the Help menu The system displays the cause of the error for that line 4 Choose Validate again after you have corrected an error The system clears the red lines for that error and moves the cursor to the next non validated li
49. system restarts task A because the value of the digital start trigger is restored to 1 e Task A is not running when the system is shut down then the value of the task s digital start trigger is 0 When a warm start is performed the system stil restarts task A because even though the value of the digital start trigger is restored to 0 thetask s Run flag is set and the Run flag supersedes the restored value of the digital start trigger 28 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Persistence Save File Name PERSISTENCE SAVE FILE NAME The persistent data is saved in a unique persistence save file for each domain instance The persistence save files have the extension PRS and are located in the FLAPP FLNAME FLDOMAIN directory where FLAPP isthetranslated application environment variable FLNAME isthetranslated application environment variable FLDOMAIN isthetranslated domain environment variable The name of each persistence savefileis FLUSERXPRS where FLUSER is the translated environment variable for the domain user name The persistence save file contains the saved values for that domain user 9U SISl d For example in Windows where the FL RUN BAT file sets the Shared FLUSER environment variableto SHAR EU SR but the User domain FLU SER environment variable remains at the default setup in the AUTOE XEC BAT file the Shared persist fileis named SHAREUSR PRS and the User persist file is named F
50. the accuracy of the most precise data type involved or when incompatible operations are taking place between digital and analog val ues Data type conversion can ensure the accuracy of the results of certain calculations with a few exceptions The following guidelines indicate when and why data types should be converted D pus 2 5 2 r e c O FactoryLink ECS Core Tasks Configuration Guide 201 MATH AND LOGIC SYNTAX Structure Guidelines for Converting Data T ypes Floating point If a floating point valueis assigned toa digital analog or long truncation analog variable Math and Logictruncates the fractional part of the floating point val ue instead of rounding it up or down before assigning the value tothe variable This results in a loss of accuracy This may be acceptable when the fractional values are not significant in the result of the calculation Non zero Assigningan analog long analog or floating point valuetoa conversion digital variable converts any non zero value to 1 and returns O if the valueis 0 This can be useful when all one needs to know is whether a particular variable s contents are non zero for useasa trigger element perhaps but it can result in a loss of precision in other situations Because a digital data type holds only a single bit of data the operation has only two possible results if the assigned value is 0 after any fractional part is truncated the digital variable takes on a
51. the original local variable SH ORT LONG FLOAT STRING The number of arguments in the declaration the order in which the arguments are entered and their data type must match the procedure definition Refer to Procedures on page 232 in Chapter 9 Math and Logic Procedures and Fundions for more informati on about arguments Remember procedure declarations are convenient when a custom written procedure must refer to another custom written procedure not yet been encountered because it is contained within another program file or occurs later in the same program fil e When the procedure bei ng called is displayed in the same file but beforethe current procedure procedure declarations are not required 196 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Thefollowing example shows how procedure declarations affect procedure calls PROC A N BEGIN CALL B Because Procedure B has not been declared and does not appear before Procedure A this call is not allowed Procedure B must be declared END PROC B BEGIN CALL A Because Procedure A is displayed before Procedure B this call is allowed M A Using the same example by declaring PROC B abovethe definition of PROC A then PROC B can be called DECLARE PROC B Declare PROC B 3 PROC A BEGIN CALL B PROC B can be called here because it was declared previously END PROC B BEGIN CALL A D pus
52. to causethe valueof the Current Value element to move toward the Preset Value by the ncrement Value For example during counting if a defective bottl eis counted but not packed in the case the EDI or Math and L ogictask subtracts that bottle from the total count by 3 writing a 1 ON tothe Down Clock element to cause the Current Value to move toward the Preset Value 0 in this example by the Increment Value 1 in this example Six bottl es havebeen counted and packed in thecase The Counter task counts the seventh bottle But the seventh bottle is defective so it is not packed in the case Therefore the EDI or Math and Logic task subtracts that bottle from the total count by writing a 1 ON tothe Down Clock element This causes the Current Valueto move from 7 down to 6 s1ajunoy U 9 Ko o 3 3 o e D FactoryLink ECS Core Tasks Configuration Guide 53 PROGRAMMABLE COUNTERS Principles of Operation If all counted bottles are defective and thus are not packed the EDI or Math and Logic task subtracts them from the total count by causing the Current Valueto count down until it matches the Preset Value 0 Although the bottle count is now 0 the Output elements have not been affected and the current counti ng operation continues until the case contains 20 bottles 54 FactoryLink ECS Core Tasks Configuration Guide PROGRAMMABLE COUNTERS Programmable Counters Information Panel PROGRAMMABLE COUNTERS IN
53. use a verbose level parameter the utility displays messages about its progress as it performs its part of the compile process This serves as a debugging aid The following chart shows the messages produced by each utility at the verbose level indicated Table 7 3 Verbose Level Utility Result Displayed 1 or higher MKCML Application name and domains as they are processed 1 or higherr CCCML Message Not authorized to run Math and Logic if the system cannot find the run time bit Current application and domain being processed Message No PRG files are configured as COMPILED Message echoing the command line that calls the compiler or linker before making the call Names of each file as it is compiled Message indicating all files are up to date PARSECML Name of each C file name as itis produced 2 PARSECML Verbose level 1 message plus The comments containing the original source lines of the Math and Logic program placed by the utility at the start of the generated C code All programs as they are parsed 3 or higher PARSECML Verbose level 1 and 2 messages plus Lexical tokens from each programs as it is parsed 158 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC How CML Operates Makefiles A makefileis a file containing all the informati on needed by the CCCML utility to compilethe C files produced by PARSECML and create an executable for the aurr
54. value when the Run Time Manager exits and shuts down the real time database H owever the values of persi stent elements are written to disk so they arenot affected when the real time database shuts down The job of the Persistence task therefore is to save persistent data The task offers thefoll owing features e Runs on all FactoryLink platforms e Lets you configure on a per tag basis or on entire domains which elements are persistent and when their values are saved to disk FactoryLink ECS Core Tasks Configuration Guide 13 PERSISTENCE Persistence Overview e Saves oneor all domain instances to disk while a F actoryLink application is running e Allows you to specify either a warm or cold start when initializing a domain instance Cold start initializes all elements totheir default values as configured in the Configuration Manager Main Menu Persistent elements are not restored to their previous values but are initialized totheir default values Warm start initializes all non persistent el ements to their default values just likea cold start and restores all persistent el ements in the domain instanceto their previously saved values e Uses its own internal disk cache to increase speed and reduce disk I O overhead e Resolves configuration changes to the application e Allows you to specify a trigger element that triggers the Persistence task to copy the current save fileto a backup file 14 FactoryLink ECS Cor
55. 00000 e eee eee eee eee 161 Calling C Code edo Gane eg es twee eee tere et pate EY 164 8 Mathand Logic Syntax oieri n iasa C erro 439 ProcedureTokens ssssslssseeseseeee nn 174 Naming Procedures iene eas Mine meena eae Marte ae LTA Math and Logic Reserved Keywords TEMP 176 Comments 52e see ee Put tubus edt itk ai fe dead end je Phan od nha die dee 179 Constarits i Li eme eX HEEL bee E RIF ORPEXGOR p ET ue 181 Symbolic Constants lllssllsee eese esses sss 181 NumericConstants issesssess esee sees sss 182 String Constants llle lees eese ess s 184 Struc E a dn ade E ato EROR o Pob Red dnd Rob b Pe ACE EO a RE a 187 Declarations 2 0 0 ee eee ee ss 187 EXP SSON S ues ex ees hn on E X S we Eod eo ee bee ea ad Ee ee 207 Statements s ii aii aiiai aa a aoa RR eee es 220 DI FeCtIVG5 ose om d eter t ede dike e E E d ai ina ed teed 228 9 Math and LogicProcedures and Functions 221 Progam Files 2secsolerweveree4e ee Ree ee ER eee ee eee ERR 231 Procedures 232 Arguments AG dhs tate tede tete fett send Soci eS Running Programs as Interpreted Programs TTUIETITTT 235 Technical Notes 0 0 cee lens 236 ee ee Local Procedures 236 Library Functions DITE Calling Functions that Operateon Tag IDs CML Only Deren 248 116 FactoryLink ECS Core Tasks Configuration Guide 10 Complex Math and Logic sisi ids D xxx RC APER ER ELEME System Configuration Pa
56. 012345678901234567890 cend END N m ee f e er D 3 o3 r fe e FactoryLink ECS Core Tasks Configuration Guide 171 CONFIGURING MATH AND LOGIC Calling C Code 172 FactoryLink ECS Core Tasks Configuration Guide Chapter8 Math and Logic Syntax Math and Logic Syntax is the language of Math and Logic This chapter discusses e Procedure Tokens e Reserved Keywords e Comments e Constants e Structure 9 qu F 93 r fe e oO FactoryLink ECS Core Tasks Configuration Guide 173 MATH AND LOGIC SYNTAX Procedure Tokens PROCEDURE TOKENS Procedure tokens are word like units recognized by the M ath and Logic language This section describes proceduretokens used in a Math and Logic program Naming Procedures Local Variable Naming declare short x declare short counter For reasons of clarity definitions line x should be avoided The variable name should indicateits function within the scope of the procedure Also to differentiate local variables from tog variables local variable names should start with Referencing thetype in thename of the variable is less important with local variables becausethe definition is near at hand Local variable names translate directly into the C code If you name any local variable the same as a variable or function in another moduleor library you will have conflicts at compile time The unique naming is
57. 80 characters in length Otherwise your results will be unpredictable a The validation routine either accepts the sourceas it has been input or it highlights it in red You must correct all grammar syntax before proceeding with the devel oping of the process of generating C code 2 Generation of C code ThePARSECML utility used to generate C code is fparsecml NDOMAIN V 0 5 C discussion to follow The procedure is then parsed and the IML code is read and converted into ANSI C code The utility that parse s theiml grammar and produces ANSI C code is PARSECML exe This may receive several different arguments di scussed later when called a Thel ML grammar syntax that you have entered and the editor has validated is now processed by the parser b CML generates one or more files that list the triggered procedures These files are named cmlproc c where is an integer 0 through 9 The files each contain 512 declarations of triggered procedures If the size of the application warrants then you may have several files of the format cml procO c cmlprocl c and so forth c All the global data declared in the procedure is processed and put in the file glvars c and glvars h These two files are created by the CML task Thefile glvars h also holds function prototypes for user defined functions or procedures The file glvars c also contains a function definition long fl ftol double This function is required in conversions of float
58. C SYNTAX Constants Integer constants can be represented in binary decimal octal or hexadecimal notation Binary Strings of Os and 1s in which the first two characters are either Ob or OB toindicate base two representation Decimal Strings of any digits 0 through 9 with the first digit either non zero Od or OD to indicate base ten representation Octal Strings of any digits O through 7 with the first digit a O Hexadecimal Strings containing any combinations of the digits 0 through 9 and or the characters A through For a through f in which the first characters are Ox or OX to indicate base sixteen representation For example to definethe local variable length as 28 use any of the following definitions Notation Definition Binary length 0b11100 Decimal length 28 Octal length 034 Hexadeci mal length 0x1C Furthermore some values are too large to be represented as short ANALOG values and must be represented as LONGANA values Any integer constant to be represented as a LON GANA long integer FactoryL ink data type must be following by a trailing L The following value ranges must be represented as LON GANA values Notation Value Range Decimal x lt 65 536 and a x gt 65 535 E joe Octal x gt 177777 Hexadeci mal x gt 0xFFFF E FactoryLink ECS Core Tasks Configuration Guide 183 MATH AND LOGIC SYNTAX Constants For example if a constant is to be larger than 65 535 placea trailing
59. E Using theCOPY Command with a N etwork without FL LAN s 92 Technical Notes aasaran naana ee hh 93 Operating System Notes en 94 For Windows NT and Windows 95 Users seen Eor OS 2 USES idus cg wn wees we wend ots xA RE awe RE EX a ee ForUnixUsers ouaszwswxereeUlenilbGSeszcexvaexsaxea sux Rd PartV Print Spooler 5 FEES spiseil Configuring the Print Spooler 0 0 00 cece eee 4 FactoryLink ECS Core Tasks Configuration Guide 94 96 98 G Core Tasks Configuration Guide Part VI Math and Logic 6 Math and Logic Overview 0 0 00 ce cece eee ee ee ees 119 WSS rai LTD 120 ProcdU res iiu lack cede cen AG RS Eee RG ee bi ee ee ee ee 121 Creating Programs ei viseieee eee hee ee pee ete eda DEN eee eee de 122 Configuration Tables 2 0 0 aaa ee eee ees 122 MOU CSS CR 124 Interpreted Mode m vix dere depu queas cue dered 24 Switching fromIML toCML T Orr us Compiled Mode VN PME CML Operation 0 ccc cccccccceccccccccccecceeeeecesess 126 TriggeringCalling 0 ccc ee tees 128 TRI QQGRING EM P EEEEPPERE CAMINO IIT Pp 7 Configuring Math and LOO 1i sd a cb kddek ed ep od a cea Rd LexbE ditor 2a esca ha pEdon Roc piE ana Rie d pae do RR Dg iC 132 Math and e an Sie eh pe I PIC ELEME 133 PRGFiles pdesis aida da RCRACRACRAL SACR dU aiti gus imd Ro Soa ds oa LOO Comments cris Math and Logic Variables Table EELSE en EEE EE E T dan 1235 M
60. F temp lt tempset THEN increase temperature temp temp ELSE IF temp gt tempset THEN decrease temperature ENDIF ENDIF The program file SETTEMP contains a procedure named SETTEMP The elements temps and temp were defined in the sample Math and Logic Variables Information panel SETTEMP is executed when the value of the trigger element SE C1 becomes 1 ON If the value entered for tempset is greater than the current temperature temp then temp is increased by 1 If the value entered for tempset is less than the current temperature then temp is decreased by 1 Coding Guidelines Consider the following guidelines when coding a procedure e Start the procedure with a BEGIN statement and conclude it with an END statement e Themaximum line length is 80 characters Running a procedure with lines longer than 80 characters can cause unpredi cable vali dation results the procedure may validate even though there areerrors Math and Logic will not function properly while running such a procedure e For each IF statement enter a matching ENDIF properly nested e Show all keywords such as IF THEN ELSE and ENDIF in uppercase characters to distinguish them from element names Keywords are not case sensitive but element names are 144 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Procedures Table 4 After you have entered the procedure you must validate it to check for
61. FORMATION PANEL The Programmabl e Counters task establishes parameters for the initiation performance and conclusion of counting activity TheProgrammable Counters task uses either the SHARED or the USER domain We recommend the SHARED domain unless counters should be unique to ead User for the purposes of the application Before opening and configuring the Programmable Counters task ensure the current domain selected is SHARED in the Configuration Manager Domain Selection box With the t program argument in the System Configuration in effect for the counter task negative output positive output and current value are initialized Positive output is set to 0 Negative output is set to 1 With no program argument those tags remain at their default persi stent values Choose Programmable Counters to display the Programmable Counters Information panel This panel contains eleven fields Press Tab to display other fields i Programmable Counters Information olx Edit View Utilities Exit Help Enable UP Clock DOWN Clock Clear Positive E Output Cancel Enter Exit E E Following arefield descriptions for this panel Enable Name ofan element that enables or tri ggers counting If this field is left blank counting is always enabled because the tri gger becomes either the UP CLOCK or the DOWN CLOCK When the value of Enableis set to 1 ON counting occurs If the value of Enableis set to 0
62. FactoryL ink tasks To send files to one of these devices F actoryLink tasks reference the correspondi ng devi ce number in a configuration table 4ajOOdS Julid o FactoryLink ECS Core Tasks Configuration Guide 105 PRINT SPOOLER Configuring the Print Spooler CONFIGURING THE PRINT SPOOLER Use the Print Spooler Tableto specify the devices to which the Print Spooler task di rects data The Print Spooler Table consists of one panel Print Spooler Information Print Spooler is normally configured in the SHARE D domain Before opening and configuring Print Spooler ensure the current domain selected is SHARED in the Configuration Manager Domain Selection box Choose Print Spooler to display the Print Spooler Information panel ul Print Spooler Information o Edit View Utilities Exit Help Device Initialization File Separator Binary On Binary Off a Sequence Sequence Cancel Enter Exit eimi Followingare field descriptions for this panel Device Name of the output device Each line corresponds to a specific device number F or example linel device 1 and line 52device 5 With Print Spooler you can define up to five devices lines to receive output from other F actoryL ink tasks Y ou can assign two or more device numbers to the same physical device For example if onl y one printer is installed and itis attached to parallel port 1 you can enter the same device name
63. FactoryLink ECS CoreTasks Configuration Guide Persistence Timer Counter File Manager Print Spooler Math and Logic Scaling and Deadbanding FactoryLink ECS 6 0 March 1996 Copyright 1984 1996 United States Data Corporation All rights reserved NOTICE The information contained herein is confidential information of United States Data Corporation a Delaware corporation and is protected by United States copyright and trade secret law and international treaties This document may refer to United States Data Corporation as USDATA Information in this document is subject to change without notice and does not represent a commitment on the part of United States Data Corporation USDATA Although the software programs described in this document the Software Programs are intended to operate substantially in accordance with the descriptions herein USDATA does not represent or warrant that a the Software Programs will operate in any way other than in accordance with the most current operating instructions available from USDATA b the functions performed by the Software Programs will meet the user s requirements or will operate in the combinations that may be selected for use by the user or any third person c the operation of the Software Programs will be error free in all circumstances d any defect in a Software Program that is not material with respect to the functionality thereof as set forth herein will be cor
64. IML Space unimportant While this is invalid because _unimportant has not been 188 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure defined in proc do less end Math and Logic uses two categories of scope block or local and file or global e Block scope Starts at the dedaration point and ends at the end of the block containing the declaration File scope Starts at the declaration point and ends at the end of the source file Generally use a variable constant or procedure after its declaration point in a program Therefore where variables constants and procedures are declared in a Math and Logic program depend on their intended scope Variable Declarations Variables can be declared in a Math and Logic program as procedure vari ables or as elements Variables declared as procedure variables are used to store values used only by Math and Logic to perform operations These values cannot be used by other FactoryLink tasks because they are not stored in the real time database Therefore procedure variables are not database elements Procedure variables dedared inside a particular procedure within a file are accessible only by that procedure and are called local procedure variables Procedure variables dedared outside of a procedure but within its program file are shared by all procedures in that file and are called global procedure variabl es Notethat procedure variab
65. ING MATH AND LOGIC How CML Operates MKCML The MKCML utility is a shell that calls the PARSECML and CCCML utilities as needed for the current application F or each domain MKCML checks the dependencies between the configuration tables named IML CT for both IML and CML and the program files MKCML performs the following tasks e Calls CTGEN which compares IML CT against the database files upon which the IML CT fileis dependent If the databasefiles havea later time date stamp than IML CT CTGEN rebuilds IML CT tobringit up to date e Determines whether thetime date of IML CT has changed If so then MKCML reproduces and recompiles all of the C files by calling PARSECML and CCCML When you redirect the output of MKCML to a file the messages displayed in the dump seem to be out of order because of how the operating system buffers and outputs messages when redirecting output If you do not redirect the output of MKCML then MKCML reports the messages tothe standard output in the correct order PARSECML The PARSECML utility parses the application s program files and produces C files for a given domain It producesa C file for each programfile listed as compiled in the Math and Logic Triggers nformation panel has COMPILED as the Mode field entry This utility also checks the dependend es between the program files and the C files tosee if any procedures have been updated sincethe C files werelast produced CCCML The CCCML uti
66. LOGIC Compiled Math and Logic COMPILED MATH AND Locic Compiled M ath and Logic CML is a combination of utilities and libraries that at run ti me create bi nary executablefiles fromthe program files you spedfied torun in the compiled mode The compile process begins at run time when you enter the FLRUN command CML translates the program PRG files into C source code putsthe C codeinto files with an extension of C compilesthe C files to produce object OBJ files and then links the object files to the appropriate libraries to create binary executable EXE files Then as each program s assodated trigger is set CML runs its executable rather than interpreting and executing the program file Because FactoryL ink appli cations can be configured in two domains U SE R and SHARE D CML creates one executable file for each domain in which the PRG files are configured Thefile name of each executableis unique defined to be C followed by the domain name e FLAPP USER CML CUSER EXE for the user domain e FLAPP SHARED CML CSHARED EXE for the shared domain Executable files created in the UNIX operating system do not have an extension in their file names D er 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 149 CONFIGURING MATH AND LOGIC CML Requirements CML REQUIREMENTS CML requires the following software and hardware e FactoryLink version 4 1 3 or later e Option bits e Run t
67. LUSERIPRS The persistence backup files are in the same place and have the same name except they have the extensi on BAK bak in UNIX FactoryLink ECS Core Tasks Configuration Guide 29 PERSISTENCE Editing Tag Persistence Settings Using BH SQL Utility EDITING TAG PERSISTENCE SETTINGS USING BH SQL UTILITY It may be useful for users to be able to make mass edits to the current persistence settings for defined tags in the OBJ ECT configuration table such as changing the field entries for all tags that currently are blank to a sped fic setting such as NONE This can bedoneusing the BH_SQL utility provided with all FactoryLink systems This utility 1 Modifies the OBJ ECT CDB filein the FLAPP directory 2 Modifies the TAGPERWHEN field in that file TAGPERWHEN meaning Tag is saved when is the text equivalent of the radio buttons seen on the Tag Definition dialog when defining a tag or using CTRL T to view the tag definition The possible values are e NONE tagis not persistent left blank same as NONE DOMAIN save based on domain persistence definition as configured in the Domain configuration panel e TIMED save on ti med trigger e EXCEPT save on change The procedure updates the table changing all instances of a specific entry in the TAGPERWHEN field at one timeto a new value Prior to executingthe instructions below we recommend you make a backup of theapplication usingthe FLSAVE utility or some other
68. Link ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Ifthe plus operator is used in an expression with an operand of the string type the other operand in the expression will be automatically converted toa string if it is not already a string and the operator will concatenate the two strings This type of operation is considered to be a string operation not a logical or arithmetic operation See Example 3 on page 206 Array Conversion If converting a local variable declared as an array convert each array element separately f the conversi on computation is within aloop use one temporary variable of the new data type to represent the array index or a eate an array of the same size and of the new data type and load it with the converted values D pus D 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 205 MATH AND LOGIC SYNTAX Structure Examples of Data Type Conversion T he foll owing four examples illustrate data type conversi on Example 1 Converting analog values to digital Let switch be a digital element The statement switch 25 2 results in switch having a value of 1 ON because the assigned value after the fractional part is truncated is non zero Example 2 F loat truncation intointeger Let lastcar be an analog element 16 bit integer The statement lastcar 47 1 results in lastcar having the value 47 not 47 1 Sincelastcar i
69. Link ECS Core Tasks Configuration Guide 263 COMPILED MATH AND LOGIC Generation of CML Executables Body of for loop must be careful of referencing factorylink tags in CBEGIN CEND block must assign the tag to a local outside of block and then process the local and then assign value back to tag outside of the CBEGIN ECEND block xf printf Inside the for loop n printf CML Leaving procedure test n gt 4 Utility that links the associated object files to produce the executable Usage cccml NDOMAI N 5 The next process that happens tothe generated ANSI C codeis to be linked with the other files and necessary li braries to produce the domain executable file LAPP YSHARE D CML CSHARE D EXE or F LAP P JUSER CML CUSER EXE Thelinkingis done by a call tothe utility cccml exe This function is given alist of the object modules to be linked to produce the executable The list of objects is in the file cml Ink File cml Ink NOE ST 16384 SE 512test syscp cfunk cbwtags glvars CMLPROCO eA FLNEW user cml cuser exe cml map E FLOS2431 lib flib lib eX FLOS2431 lib aml lib 264 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables E FLOS2431 cml cml def This file aml Ink is the file passed tothe linker It tells the linker what files and libraries need to be linked together to produce the desi red executable cuser exe or c
70. Manager Control Panel Sample Entry Explanation TableName WINREN Designates the name of a REN operation Command rentrig Name of the digital element that triggers Trigger the rename operation Command REN Designates aREN operation Source c temp s log This field contains a variable specifier File Spec which F ile Manager replaces at run time with the value of the message element s file specified in the Source Variable 1 field Source s file At run time File Manager replaces the Variable 1 variable s in the Source File Spec field with the value of this analog el ement Destination s tmp s tmp contains a variable specifier FileSpec which File Manager replaces at run time with the value of the message el ement rento specified in the Destination Variable 1 field Destination rento When the value of the digital el ement Variable 1 rentrigis forced to 1 ON File Manager renames thefile specified in s file with the filename contai ned in rento 80 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Sample File Manager Operations Example 4 TYPE Example 4 demonstrates the TY PE command TYPE command filesyntax is the same for all operating systems Table 4 5 7 Sample File Manager Control Panel z D Sample TA 3 ee eem z L Table Name TYPE Designates the name of a TYPE operation Command typetrig Name of the digital e
71. Notethis limitation when planning application data design for such applications Contact Customer Support for suggestions on workarounds such as dedaring several linked data items if large buffers are needed in an application to be ported Data Type Conversion Createa new variable of a particular data type for accuracy in computation such as floating point and initializethe new item to the current value of another variable of a different data type such as a long analog This conversion prevents a possi ble loss of accuracy in upcoming calculations as explained bel ow Usethe new variable to do operations with other variables of the sametype as the new variable Automatic conversi on of any numeric data type digital analog long analog or floating point takes pl ace when a variable of onetype is assigned the value of another variable of a different data type Use the simplest type of assignment statement necessary for the conversion to obtain the most efficient performance Refer to Statements on page 220 for information about assi gnment statements Include the new variablein a configuration table or in a program file depending on whether the original variableis a element or is local to program operations This will greatly simplify the debugging process should a problem occur during startup Data type conversions are not often needed but they can beuseful in particular situations Convert variables whenever the result requires
72. OC N BEGIN DECLARE FLOAT f DECLARE LONG k z DECLARE STRING buff E a buff strcmp f k r END J amp b pd 9 FactoryLink ECS Core Tasks Configuration Guide 165 CONFIGURING MATH AND LOGIC Calling C Code In this program stramp converts the FLOAT value f and the LONG value k to strings compares thetwo strings and then returns a number buff that indicates whether the comparison was less than greater than or equal to zero This comparison is shown below If f lt k then buff is a number less than O If f k then buff is equal to O If f gt k then buff is a number greater than 0 Example 2 uses cfuncto declare the function testfunc which has a return data type of VOID DECLARE cfunc VOID testfunc FLOAT PROC MYPROC BEGIN DECLARE FLOAT flp f1p 100 0 testfunc flp a J In this program the declared floating point variable 1p is set to 100 0 and this value is passed to the function testfunc Note that VOID is entered in place of the data type for the function s return value This is because the program is simply passing a value to testfunc and the function is not required to return a value Using cbegin and cend You can use the keywords cbegin and cend to embed C code directly into a CML procedure Between these keywords you can call external library functions and manipulate structures and pointers Math and Logic does not support However you cannot dedareC variables insi
73. ONE Use thefollowing command if you havea large number of tags configured to be saved as defined for the domain configurati on and you want to change the setting for all of these tags to be saved individually when they change value or on excepti on SQL gt update object set tagperwhen DOMAIN where tagperwhen EXCEPT lt ret gt Type QUIT at the BH_SQL prompt once all desired changes have been made FactoryLink ECS Core Tasks Configuration Guide 31 PERSISTENCE Editing Tag Persistence Settings Using BH SQL Utility 32 FactoryLink ECS Core Tasks Configuration Guide Part Il Event and Interval Timer Table of Contents Event and Interval Timer 2 Event and Interval TIME aoa ded Do ec CR anaran ST Principles of Operation 0 cc ee eee 38 Changing the Operating System Dateand Time 0 e eee 40 Configuring the E vent and Interval Timer Task 0 000000 40 Event Timer Information Dialog llle elei e eee ee eee 40 Interval Timer Information Dialog 00000002 ee 43 FactoryLink ECS Core Tasks Configuration Guide 35 Event and Interval Timer 36 FactoryLink ECS Core Tasks Configuration Guide Chapter2 E vent and Interval Timer Use theE vent and Interval Ti mer task to define timed events and timeintervals that initiate and control any system function in run time mode e Timed events occur at a spedfic time not more than once every 24 hour
74. ORY FILE EXT stand alone HISTORY ARC systems STATION DRIVE A For NODE 1 CA FLINK PI CV DIR SUBDIR networked SCREEN1 PIC FILE EXT systems Using Wildcard Characters in File Specifications 5 17 Format path names as follows Table 4 18 source DRIVE DIRECTORY SUBDIRECTORY WILDCARD FILESPEC destination DRIVE DIRECTORY SUBDIRECTORY it for you Do not specify a filename for the destination path as File Manager will do Path names with wildcard characters in the file specifications might resemble the fol lowing examples Table 4 19 source C FLINK SAMPLE SAMPLE destination C FLINK EXE 96 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Operating System Notes Using Variable Specifiers in File Specifications 5 16 The following chart contains OS 2 specific examples of variable specifiers used to desi gnate paths Thelast example shows the path name of a station on a network Table 4 20 Samples of Variable Specifiers in Path Names LINT RN RNC NN Standard CA history exei sample exe Base example path 1 variable C 8s exe sampl e exe Variable for directory 2variables c 8s 8s sampleexe Variables for directory and subdirectory 3variables c 8s 8s sample 3s Variables for directory subdirectory and 3 character file extension 4variables 1s 8s 8s sample Variables for drive directory
75. U UD P qd a Poe ute iy eee Sl lA 22 wo Vang Programmable Counters Table of Contents Programmable Counters 50 FactoryLink ECS Core Tasks Configuration Guide Chapter3 Programmable Counters Use the Programmable Counters task to provide count per unit of ti me measurements and to provide event delays such as defining a trigger to unlock a door and then specifying a delay before the door locks again A programmable counter is a group of el ements with values that work together to perform a count Outputs from programmable counters can be used to provide input to Math and Logic programs or other FactoryL ink tasks or totrigger Math and Logic programs Thereis no limit except the amount of memory to the number of programmable counters that can be defi ned The Programmable Counters task uses either the SHARED or USER domain The use of programmable counters requires an understanding of change status flags Refer to FactoryL ink Fundamentals for this discussion au o e o2 c o EE 4 gt FactoryLink ECS Core Tasks Configuration Guide 51 PROGRAMMABLE COUNTERS Principles of Operation PRINCIPLES OF OPERATION A programmable counter is a group of elements with components that work together to perform a count E ach programmable counter is made up of some or all of thefollowing elements and analog and digital values Elements e Enable triggers counting activity Up Clock i
76. a file on a remote station The format for a remote file path is as foll ows station path where station is the nameof the remote station path is the full path nameof the file on the remote station 88 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Using the File Manager with Networks The source and desti nation are interchangeable as long as one of them is the local FactoryL ink station The only difference between local file operations and remote file operations is remote file names must include the disk drive specification if required by the operating system and must conform tothe filename syntax for the remote computer s operating system In a copy operation only onefile can be remote In a rename operation both fil es must be on the same station For example to copy a filefroma local FactoryLink station to a remote FactoryL ink station use the following format for the remote path name NAASTATION NAMENDEVICE NAME DIR NAME FILE NAME a o o gt o Q D Other fil e management operations can be performed with File Manager using the same format Do not use the remote filename STATI ON when performing File Manager operations on networks unless you installed FLLAN on the local and remote computers U singtheF LLAN FactoryLink station name instructs FLLAN rather than the network to perform the operation At run time beforeinvoking file management operati ons between local
77. ad or Write PLC tables and in Send or Receive tables for FL LAN Network configurations FactoryLink ECS Core Tasks Configuration Guide 43 EVENT AND INTERVAL TIMER Configuring the Event and Interval Timer Task Choose Interval Timer to display the Interval Timer Information dialog 14 Interval Timer Information of x Edit View Utilities Exit Help Tag Name Hours Mins Secs 10ths E E Cancel Enter Exit m Following are field descriptions for this dialog Tag Name Hours Mins Secs 10ths Name of the el ement for example sec5 to be assi gned to the interval You can assign the same interval to more than one element If the tag specified in this field is not already defined a Tag Definition dialogis displayed when you dick on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type digital default digital Hours Mins minutes Secs seconds and 10ths tenths of a second fields define the interval at which an eventis to occur If these fields are left blank theinterval timer assumes a default value of 0 At least one of these fields must be filled in with a valid entry not zero as itis not considered a valid entry or else the system does not allow the I Ti mer to start but instead displays the error message Bad data in ITimer record recordz file itimer exe Depending on th
78. age tag For example if the messagein the lineis 140 characters long it puts the first 80 into the first message tag and the next 60 into the second message tag 68 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER File Manager Control Panel Source File Spec Full path name of the source file The source file spec can use the filename syntax for the operating system on which either the remote or the local station resides If you areusing FLLAN the source can reference a remote station f you specify a remote station for the destination and a remote station for the source the two remote stations must be the same If the destination is local there is no restriction on the source station Similarly if the sourceis local there is no restriction on thedestination Refer to UsingtheFileManager with Networks on page 88 for information about referenci ng remote stations Type wildcard characters in the path nameto show a root directory s contents usingthe DIR command For example in this field type CINEI Only one file in a copy operation can be remote Both files in a rename operati on must be on the same station ay o o gt o Q D For stand alone systems DEVICE NAME DIR NAME SUB DIR NAME FILE NAME For networked systems STATION_NAME DEV ICE_NAME DIR_NAME SUB_DIR_NAME FILE _NAME In the case of the COPY DEL and DIR commands the source file specification may contain variable sp
79. alue to move away from the Terminal Value toward the Preset Value When a 1 ON is written tothe Down Clock element the valuein the Current Value element is decreased by the amount specified by the Increment Value element f the Preset Valueisless than the Terminal Value the Increment Value is subtracted from the Current Value If the Preset Valueis greater than the Terminal Value the Increment is added tothe Current Value The Current Value does not move past the Preset Value and the Positi ve N egative Outputs are not triggered when thePreset Valueis reached The data typefor this tagis digital At least onetype of clock must be defined that is an entry is required in either the Up Clock or Down Clock fiel d Valid Entry standard element tag name Valid Data Type digital 56 FactoryLink ECS Core Tasks Configuration Guide PROGRAMMABLE COUNTERS Programmable Counters Information Panel Clear Nameof an element that causes the Current Value to be reset to the Preset Value each time a 1 ON is written toit the Clear element Each timea 1 ON is force written to the Clear element a 0 OF F is force written to the Positive Output element and a 1 ON is written tothe Negative Output element If the tag specified in this field is not already defined a Tag Definition dialog is displ ayed when you click on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid D
80. an ELSE dause exists the ELSE block is executed The ELSE block is optional ThelF THEN block is not optional and the THEN verb must immediately foll ow the test expressi on on the samelineas IF Each IF statement must be ended with an ENDIF statement on a line by itself D pus 2 5 2 m fo 2 O FactoryLink ECS Core Tasks Configuration Guide 223 MATH AND LOGIC SYNTAX Structure The fdlowing examples illustrate the use of IF I ENDIF control statements Example 1 F x 1 THEN a atl b 20 LSE a a 1 b 0 DIF dg Example 2 I E E N NC F NOT initflag THEN IF alrm gt 6 THEN initflag 1 alrm alrm 1 CALL initproc ENDIF LSE b 20 tag a 1 procadd NDIF call another proc call another proc 224 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure G Example 3 N df take determinant of 2x2 array det a 0 0 a 1 1 t ta 0 1 a 1 0 if nonzero then invert 2x2 array a 1 place resulting array in 2x2 array b IF det 0 THE b 01 0 a 1 1 det b 01 1 a 0 1 det b 11 0 a 11 0 det b 1 1 a 01 01 det ELSE PRINT Cannot invert this matrix n ENDIF V E WHILE WEND A WHILE WEND statement specifies a block of code is to be executed repeatedly until thetest expressi on becomes false Syntax The WHILE WEND control stat
81. and remote nodes ensuretheFLFM SERVER task is runningin the SHARED domain on the remote node Using the COPY Command with FLLAN COPY operations the most common File Manager operations performed on a networked system have the fd lowing uses e Copy local files to a remote station e Copy remote files to a local station e Copy local files to the local station FactoryLink ECS Core Tasks Configuration Guide 89 FILE MANAGER Using the File Manager with Networks The fdlowing exampleis of a copy operati on on a networked system The source and destination paths are in Windows file syntax Table 4 13 Sample File Manager Control Panel PAPE TableName WINXFER Designates a fil e transfer operation on a network using FLLAN Command COPY Designates a COPY operation Trigger filexfertrig Name of the digital element used to trigger the copy operati on Source c arq Source path where s is the variable Format 945 1 og specifier The string specified by the value of the message d ement s filereplaces the 965 in the source specification Source Tag 1 s file At run time File Manager replaces the variable s in the Source F ormat field with the value of this analog element Destination nod2 s File Manager computes the destinati on Format path in the same way as the source path Destination s path If the message elements path contains the Tag1 following message C NFLINKNRECIPE the com
82. and Logic Triggers Information panel is forced to 1 ON at midnight of each day The element array cars consists of elements whose values indicate the colors cars are painted Valid paint colors hereare 1 through 5 The values of the elements in element array errors also defined in the Math and Logic Variables I nformati on panel indicate whether a problem occurred with the car s paint job a value of 0 OFF indicates noerrors and a value of 1 ON indicates a problem occurred If a problem occurs the element array cars will not contain a valid paint color valuein that array location D er 2 5 2 r e FactoryLink ECS Core Tasks Configuration Guide 147 CONFIGURING MATH AND LOGIC Math and Logic Procedures Table Whenever the digital element midnight is forced to 1 ON thePRINTRED procedure triggers Math and Logic to read the values of the real time database message el ements in the element array cars Whenever the value of one of these message el ements is 3 the valuefor red paint the PRINTRED proceduretells the FactoryLink Print Spooler task to print the index intothe element array cars for that car If thecar is not marked as red the procedure tests the value of the element array error and reports an error if the value is 1 ON In this way the operator receives printed information about all cars in a factory painted red each day 148 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND
83. and Logic copies the values used as arguments so the procedure modifies the copies not the original values of the variables or elements F or example if the tag name of a database element is used as an argument the task copies the value of that element and sends it to the procedure as the argument The original value of the database element is not affected Values modified as arguments cannot be passed back to the calling procedure An array cannot be used as an argument toa procedure but an array element can PROC pgml short non tagnm but CALL pgmi tagl In this example the val ue of the digital element tag is copied intothe procedure variable non tagnm and converted toa short data type Inside the procedure operations on non tagnm do not affect the value of tag1 However because FactoryL ink real time elements are global at the end of the procedure tagl can be assigned the value of non tagnm The dedaration section of a procedure definition is optional Any of the declarations can be made in this section Remember the two previously stated rules e Any variables declared within the procedure are by definition local variables and cannot be referenced outside of the procedure e Dedarations must come before any statements D er 5 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 233 MATH AND LOGIC PROCEDURES AND FUNCTIONS Program Files Calling Sequence F or Math and Logicto invoke a pr
84. aracter in a sequence enter a backslash followed by the two character hexadecimal value of the control character For example the two digit hex value for the ASCII ESCAPE character is 1B If on a particular printer an ESCAPE character followed by G turns graphics mode ON and ESCAPE followed by gturns it OFF fill in the command sequences as follows Binary On 1BG Binary Off 1Bg This sequence puts the printer in graphics mode before it begins the print job and takes the printer out of graphics mode upon completion of the print job Valid Entry alphanumeric string of between 1to 16 characters C1 4a OOdS ulld Status Tag Nameof an element that contains one of three analog values representing the status of the printing device O Fileprint is complete 1 Device adive 2 Error operating devi ce f you specify more than one device be sureto distinguish between devices when assi gni ng element names If the tag specified in this field is not already defined a Tag Definition dialog is displ ayed when you click on Enter with a tag type of analogin the Type field Accept this default Valid Entry standard element tag name FactoryLink ECS Core Tasks Configuration Guide 109 PRINT SPOOLER Configuring the Print Spooler Message Tag Name of an element that contains a message describi ng the status of the printing device This element is useful if you want to display the status of a printing device on a gra
85. array is dynamic and a value of zero marks thelast element STRING local variables and message tag variables arefunctionally the same This is the sameas a C type CHAR on most platforms If you want toreference worthless in another PRG in this domain you must put a dedareshort worthless in the header of that file The dedaration tells the procedure A variableor a constant is to be created or a variable or a procedureis to be referenced e The scope of the created variable or constant or the referenced variable or procedure z D pus D 5 2 r e c O FactoryLink ECS Core Tasks Configuration Guide 187 MATH AND LOGIC SYNTAX Structure Scope Scopeis that part of a program in which a variable constant or procedure can be used The scope of a local variable and its C code variable definition is the section of codes where this variable can be referenced This varies according to where the dedarations take place For example FILENAME DO NOT PRG declare short worthless if worthless can be used anywhere in this domain of IML proc do not short nocount begin declare short unimportant 13b nocount and _unimportant can only be used inside proc do not worthless nocount unimportant This is valid code call do less end proc do less begin declare short wasted declare short space wasted worthless This is valid code because wasted is local to proc do less if and worthless is global to this domain of
86. ary minus Bitwise s complement Logical negation Binary Bitwise AND Bitwise OR Bitwise XOR 91607 pue yN FactoryLink ECS Core Tasks Configuration Guide 217 MATH AND LOGIC SYNTAX Structure Table 8 17 Continued Precedence 1 is highest Category Operator Description Multiplicative E xponenti ation Multiplication Division Modulus remainder Additive Binary plus addition Binary minus Subtraction Relational Less than or equal to Greater than Greater than or equal to Equality Equal to Not equal to Logical AND Logical OR Assignment Variable or database element assignment Forced write database element only 218 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Thefollowing examples illustrate operator precedence Table 8 18 Example Statement Explanation of Operator Precedence x 5 y 10 AND NOT zflag According to precedence rules the order of evaluation is NOT then then 4 then lt then AN D The program evaluates the expression as if it contained the following parentheses x lt 5 y 10 AN D NOT zflag To perform the addition beforethe multi pli cati on add parentheses to alter precedence as follows x lt 5 Y 10 AND NOT zflag Because and havethe same precedence and they associ ate left to right the program performs before The program evaluates the expression as if it contained the following paren
87. as concatenation operator in regard to string operands which yields 1e3081e 308 The system stops converting at the second occurrence of e discarding the 308 portion and attempts to placeintothe vari able float1 the out of range value 10 raised to the power of 3081 which is too largeto fit into the floating point constant and which is not the desired value Convert each of these values before adding them to prevent this type of error and avoi d unpredictable system behavior Create two conversi on variables float1 and float2 and replace the statement above with the following statements floatl messagel get first user input float message 4 get second input floatl floatl float2 sum the inputs P The computations can then be carried on using only float1 Expressions An expression is a set of arguments operands that resolveto exactl y one value An expression consists of some combi nation of the following elements Operators symbols or keywords that specify the operation to be performed e Variables database element tag names and procedure variables e Constants symbolic numeric and string constants e Functions D pus 2 5 2 r e FactoryLink ECS Core Tasks Configuration Guide 207 MATH AND LOGIC SYNTAX Structure In an expression parentheses and brackets are balanced and all operators have the correct number and types of operands The following examples illustrate we
88. ata Type digital Positive Output Nameof an element to which a 1 ON is written each time the Current Value reaches the Terminal Value The value of the Positive Output element remains 1 ON until a 1 ON is written to the Clear element If the tag specified in this field is not already defined a Tag Definition dialog is displ ayed when you click on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type digital Negative Output Nameof an element to which a 0 OFF is written each time the Current Valuereaches the Terminal Value The value of the Negative Output element remains 0 OF F until a 1 ON is written tothe Clear element This tagis set to 1 at task startup If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you dick on Enter with a tag type of digital in the Type field Accept this default Valid Entry standard element tag name Valid Data Type digital Current Value Nameof an element to specify the name of an element that contains the current value of the counter This valueis always between the Preset Value and the Terminal Value The default is O If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you dick on Enter with a tag type of analogin the Type field Accept this default Valid Entry standard element tag name Valid Data Type analog longa
89. ath and LogicTriggersTable sseee esee esses 136 Math and LogicProcedureTable 0 00 e cece eee ee ee 136 Configuring the Math and Logic Tables llle nee 137 Choosing a Domain OP METER Math and Logic Variables Table Leda bas pk Dk Ea DE ae EEEE 138 Math and LogicTriggers Table 0 0 0 0 ccc eee eese 140 Math and Logic Procedures Table 0 cc eee cece esee 143 Correcting Validation Errors een eee n n nnns 145 Configuration Examples Using Element Arrays oie ha ie tre eons 2 LAD Compiled Math and Logic s n saasaa 149 CML RequirementsS 0 000 ce aaa 150 Entering CML Intothe System Configuration Table 152 RUMANO CML wi ae weed nde eR ti TENERE Gia the dees E EE 153 Running CML on a Devdopment System 2 2 2 153 FactoryLink ECS Core Tasks Configuration Guide 5 Core Tasks Configuration Guide Running CML on a Run TimeOnly Systen 153 How CML Operates 0 0 cece e nnn 155 Makefile Poe eis enn ie eee E neat wee LOS Editing CML MAK NUTS Advanced Concepts for CML Pda d id dese wr dd wal Ado dior e Sake eek 161 Utilities and Commands 0 00000 e eee eee ee ee eee 161 Calling C Code ii hens nates bead eroded eee ber Ee pex ee Fs 164 8 Math andLodgiC 5 VIV cversez dades Sees qo dme PPP S ProecdureTokens ananunua cece eee hrs 174 Naming Procedures T aes Deere de ede LIF Math a
90. backup utility At least make a backup copy of theOBJ ECT CDB and OBJ ECT MDX files soif anything goes wrong during the procedure the backup can be restored with no damage done tothe application The general syntax can be modified to update the persistence setting for any group of tags from the current settings to any valid new setting as a group by varyingthe literal values in the first and second instance of tagperwhen Follow the steps below tousethe BH SQL utility 1 Run BH SQL by typing the program name at a prompt for all systems except MS Windows F or MS Windows run the program from the Program M anager File gt Run menu selection 30 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Editing Tag Persistence Settings Using BH SQL Utility 2 TypeattheBH SQL prompt SQL gt connect flapp lt ret gt whereflapp is the actual path tothe flapp directory as defined in the F LAPP environment variable 3 TypeattheBH_SQL prompt quote marks are all single quotes not double quotes SQL gt update object set tagperwhen NONE where tagperwhen lt ret gt U D E e o D 3 Qo D where thefirst instance of tagperwhen N ONE is the desired new value for the field and the second instanceis the current value of the field in this case a blank entry This command finds all records in the OBJ ECT table for which the current tag persistence setting is blank and changes all the settings to N
91. ble Consider thefoll owing examples ra DECLARE SHORT itotal total number of vats heated DECLARE FLOAT ftempm J mean temperature held in vats SN E Local Array A local variable can also be dedared as a local array A local array represents a set of values of the same type An array is declared by specifying the size dimension of the array after thearray type An array can have a maximum of 16 dimensions An array with morethan one di mension may bethought of as an array whose elements are also arrays rather than scalar variables each additional dimension gains the array another set of row and column indices E ach of the dimensions which must be constant are enclosed in brackets Use one of the following forms to declare a local variableas a local array DECLARE SHORT week 7 il days of the week Y or DECLARE SHORT ca1 12 31 10 ten year calendar array The second form defines a three di mensional array The total number of elements in array cal is the product of the size of each dimension Local variable arrays function like scalar local variables in many ways except neither an array nor an array element can be passed as an argument to a procedure 192 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Global Procedure Vari ables Y ou must declare global variables outside of any procedure that references them How you declare them depends on whethe
92. both shown in brackets are optional When additional arguments exist the items shown in braces are present 226 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Math and Logic copies the values used as arguments so the procedure modifies the copies not the original values of the variables or database elements Refer to Arguments on page 233 in Chapter 9 Math and Logic Procedures and Functions for more information Block Nestability Blocks delimited with control statements can be nested provided each IF or WHILE statement contains an appropriate matching ENDIF or WEND statement Blocks cannot overlap and must be matched pairs entirely within any other blocks to which they are internal mproperly nested logic causes unpredictable results The following example illustrates proper procedure nesting IF x y THEN N n 0 WHILE n lt 1 a n 0 n n 1 WEND ELSE IF x gt y THEN a x y 1 ELSE aLly x 1 IF alert THEN PRINT FOUND IT n ENDIF ENDIF ENDIF Excessive nesting of blocks or procedure calls can cause the operating system to halt the procedure and return a Stack overflow error If this error occurs either restructure the procedures to reduce the number of nesting levels or increase the stack size for Math and Logic Contact Customer Support for information about increasing thestack size 0 D pus 2 5 2 r e FactoryLink ECS
93. c SHORT LONG FLOAT STRING Y ou may declare C functions to return the following data types Function Value returned SHORT Short integer LONG Long integer FLOAT Floating point STRING String VOID None The VOID data typeis unique toCML Use VOID when declaring a function not required toreturn a value 164 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Calling C Code Do not use VOID in programs designed torun in interpreted mode cfunc Examples The following two examples show how to use cfunc Example 1 uses cfuncto ded arethe standard C function strcmp for usewithin a CML program DECLARE cfunc SHORT strcmp STRING STRING B PROC TEST STRING s1 BEGIN IF stremp sl QUIT 0 THEN PRINT QUITTING n ENDIF END N P S E The function strcmp compares two strings and returns a value that indicates their relationship In this program strcmp compares the input string si tothe string QUIT and is dedared to have a return value of the data type SHORT e Ifthe return valueequals 0 then si isidentical to QUIT and the program prints the message QUITTING e fthereturn valueis less than or greater than 0 the program prints nothing C functions dedared using dunc havefull data conversion wrapped around them meaning any data type can be passed to and returned from them Given the sample code above the following program is legal within CML 7 PROC MYPR
94. c characters A Z a z digits 0 9 periods dollar signs at signs and underscores has a maximum length of 30 characters does not have a period as its first or last character does not havea digit as its first character in a name In the compiled mode the periods dollar signs and at signs are all converted to underscores in theresulting C sourcefile For example the variable names temp temp temp all equal temp when they are translated into C source code Therefore avoid variable names with periods dollar signs and at signs The period can beused in element tag names in this release however if it is used incorrectly future software updates may produce undesirable results n future releases of F actoryLink the period will be used to represent an object that has its own members Therefore we recommend you not usethe period in tag names Contact Customer Support for additional information D pus 2 2 2 e O FactoryLink ECS Core Tasks Configuration Guide 191 MATH AND LOGIC SYNTAX Structure Separatethe names with commas as shown in thefoll owing example to declare more than one variable of the sametype on the same line N DECLARE SHORT s1 s2 s3 4k loop amp array indices 3D array A However we recommend variables be decl ared oneto a linewith comments on the same line after each declaration briefly describing the use of the varia
95. can reference a remote station f you spedfy a remote station for the destination and a remcte station for the source thetwo remote stations must be the same If the destination is local there is no restriction on the source station Similarly if the source is local there is no restriction on the destination Refer to UsingtheFile Manager with N etworks on page 88 for information about referencing remote stations For stand alone systems DEVICE NAME DIR NAME SUB DIR NAME FILE NAME For networked systems STATION_NAME DEVICE_NAME DIR_NAME SUB_DIR_NAME FILE _NAME Unless you use wildcard characters in the source file spec specify the full path name of the destination If you use wildcard characters do not specify the full path specify only the directory Refer to FactoryLink Fundamentals for information about wildcard characters In thecase of the COPY DEL and DIR commands the destination file specification can contain variable specifiers or wildcard characters Refer toF actoryLink Fundamentals for information about variable specifiers 70 FactoryLink ECS Core Tasks Configuration Guide Destination Variables 1 4 Completion Trigger FILE MANAGER File Manager Control Panel If using the PRINT command use the following destination file spec format station_name flags spool device where station name is the optional FactoryL ink station name defaults to LOCAL TheF actoryLink stati on
96. cess ce RR e eee enna 256 Generation of CML Executables llle nh 257 Scaling amp Deadbanding Scaling s D dbanding s iupaecsi Ok Oca ro ote PRO HS Principles of Operation 0 0 0 0 cette 274 Defining Scaling and Deadbanding Operations lusus 276 FactoryLink ECS Core Tasks Configuration Guide 7 Core Tasks Configuration Guide 8 FactoryLink ECS Core Tasks Configuration Guide Persistence Y Table of Contents Persistence 1 uo co eee eer eee eee aT ears ee ee ee ee ee ey reer eee re S Persistence OvervieW 0 060 rn 13 Principles of Operation 0 cc tt eee 15 Resolving Configuration Changes 0 0 cece ee eee 17 Configuring Persistence for Existing Applications 18 Configuring Persistence for New Applications 0 00 18 Configuring Persistence for Individual Elements 0 000000 19 Configuring Persistence for All Elementsin a Domain 21 Configuring the Persistence Task 0 ccc cece eens 23 Persistence Task Start Order 0 00 nauan na tt eee 26 Persistence and Digital Elements 000 e eee eee 27 Persistence SaveFileName isses 29 Editing Tag Persistence Settings UsingBH SQL Utility 30 FactoryLink ECS Core Tasks Configuration Guide 11 Persistence 12 FactoryLink ECS Core Tasks Configuration Guide Chapter 1 Persistence
97. command in double quotes To obtain directory listings of files in the current active drive path use SYSTEM dir OS 2 returns a status code with 1 indicating success and any non zero value indi cating failure Virtually any system command valid from the normal OS 2 prompt is valid when sent through the SYSTEM function Usingthis feature makes procedures non portable without manual conversion of the system calls tothose appropriate in the target system For UNIX The SYSTEM function sends the specified operating system command tothe operating system and spawns a subprocess that passes the request to a DCL Command Line Interpreter CLI The Run Time Manager screen for the particular domain in which Math and Logicis running displays the output the D er 5 2 5 2 e c FactoryLink ECS Core Tasks Configuration Guide 247 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes CLI produces while processing the request E nclose the desired system command in double quotes To obtain directory listings of files in the current active drive path use SYSTEM 1s UNIX returns a status code with 1 indicating status and any non zero value indicating failure Virtually any system command valid from the normal UNIX prompt is valid when sent through the SYSTEM function Note that using this feature makes procedures non portable without manual conversion of the system calls to those appropriatein t
98. configured to be saved on a ti med basis and writes their values todisk the persi stence save file Leavethis field blank if no timed saves are required for the application A Tag Definition dialog is displayed when you dick on Enter if the tag spedfied in this field is not already defined Valid Entry standard element tag name Valid Data Type digital analog longana float message FactoryLink ECS Core Tasks Configuration Guide 23 PERSISTENCE Configuring the Persistence Task Cache Buffers Number between 0 and 32766 indicating the number of buffers to be set aside for the Persistence task s internal disk cache The default is 16 The greater the number of buffers the less the task writes to the disk which improves performance Usethefollowing guidelines to aid in determining the number of buffers How often the data is changing How much of the data is changing Thesize of the data that is changing While there is no definitive way to determinethe ideal number of buffers you can usethe total number of tags of each data type that arepersistent in the application to calculate an estimation of the maxi mum buffer size The formula is given as follows max buffer size of analog digital 2 of longana 4 of float 8 of msg len wherelen is the message length from the P ersistence panel Then select a combination of number of buffers multiplied by buffer size that equals this value See Buffer Size b
99. cribes some possible effects of warm restarts on the application dependi ng on when Persistence starts and what has happened to the other tasks during the startup process This discussion ONLY applies if the TASKSTART tags from the System Configurati on Table are made persi stent Example 1 Persistence starts last and shuts down first After the application starts the values ofthe TASKSTART tags are 1 so Persistence saves a 1 as their last known value At shutdown because Persistence stops first Persi stence does not see the change in value ofthe TASKSTART tags from 1 to 0 zero so the saved values remain as 1 On a warm start of the application theTASKSTART tags for all tasks that were running at shutdown will be restored to 1 and therefore their tasks will start It is important to note that these same tasks will be started regardless of their R flagsettings in the SYS CT file This assumes no manual starts terminati ons Example 2 Persistence starts first and shuts down last Because Persistence starts first it sees the application starting and therefore sees the values of the TASKSTART tags at 0 If there is a termination during thestartup process then because Persistence stops last it saves a 0 as the last known valueof the TASKSTART tags On a warmstart of the application none of the tasks will be started becauseall of thetasks TASKSTART tags had a last known value of 0 The shutdown order is moresignif
100. culations in your application that divide very small numbers by very large numbers thosethat divide very large numbers by very small numbers or thosethat di vi de a number by zero We recommend you test for integer overflow analog values conditions and for floating poi nt overfl ow float values conditions It is important before performing computati ons ensurethe results will be within the stated maxi mum and minimum ranges of the system itself H owever if you need to use larger analog values than the system can handle use floating points as a workaround situations requiring numbers larger than the float representations possible on most systems will almost never arise Shorttolong Short analog values aresimpleto convert to long analog values analog conversion The first example bel ow shows how overflow conditions on long analog values can be corrected by converti ng the values to floating point prior toattempting the computation in which errors are likely to occur The second example shows a workaround for floati ng point overflow conditions Long analog value overflow correction If temp is a 16 bit analog variablethat currentl y has the value 30 000 then because of the limitations inherent in representing numbers in the computer the erroneous result of the computation 2Xtemp will be 5 536 instead of the expected val ue of 60 000 I n other words theresult of this computation does not fit into the integer field allocated to
101. cutables for domains ready for running cuser exe and cshared exe then FactoryL ink application starts Procedures Operating at Run Time FactoryLink tasks are running Triggers are turning on and off Procedure logic is running in either IML or CML or Both Orderly FactoryLink Shutdown 252 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC System Configuration Panel Setup Under IML CML SYSTEM CONFIGURATION PANEL SETUP UNDER IML CML When you uselML or CML you must always determine the correct task settingin the System Configuration Panel The default setting for the Math and Logictask is to run in IML mode Torun Math and Logic in Compiled mode the task name must be changed to CML and the executable file field must beset to bin aml Y ou may choose to run both ML and CML tasks in the same domain If this is the case you must add the second task The best way to dothis is to copy the last line in the system configuration panel and pasteit in below the line just copied Y ou can then change the flags task name description and increment the index of all array elements start trigger through the display description Make sure you change the executable fileto bin iml or bin aml whichever is applicable D er 2 5 2 r e 7 FactoryLink ECS Core Tasks Configuration Guide 253 COMPILED MATH AND LOGIC Makefiles MAKEFILES A makefile is a file containing all the informati
102. d blank Valid Entry standard element tag name Valid Data Type digital analog longana message Enter an alphanumeric string of between 1to 8 characters that specifies the unique name of the Math and Logic procedure exactly as entered in the PROC statement to betriggered by the element defined in the Trigger Tag field Consider the following guidelines when defining this entry Procedure names are case sensitive but the file names of the program files containing the procedures are not 140 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Triggers Table Do not give a procedure a tag name or usethe same name for two procedures even if the procedures are in different domains If either of thesetwo errors exist Math and Logic cannot initiate the procedure Although the name of a triggered procedure cannot belonger than 8 characters you may uselonger names for procedures that are called not triggered Every procedure file must contain a procedure with the same name as the file name The procedure name must be alphanumeric and must begin with an alphabetic characer Valid Entry alphanumeric string Valid Data Type for Windows NT Windows 95 and OS 2 alphanumeric string of between 1 and 8 characters for UNI X alphanumeric string of between 1 and 16 characters all lower case Mode Enter the mode in which Math and Logic will operate Either Interpreted Math and Logicload
103. d value tag the function should be disabled using the Scaling Lock Tag When the Scaling Lock Tag has a non zero value changes made to the tag are not propagated to their related members After the changes to that function have been made and the function has been re enabled the current raw valueis scaled and written to the scaled value tag Any changes to the ranges are applied to the scaled value as well Deadbanding which applies to raw to scaled conversion but not to scaled to raw conversion may be specified in one of two ways as an absolute ABS number of Engineering U nits EUs or as a percentage PCT of the scaled range During raw to scaled conversion a newly calculated scaled val ue that does not exceed the deadband will not be written to the database f deadbanding is being appliedtoa tag associated with scaling rather than a specific alpha numeric range then deadbanding should be specified by a percentage of a rangerather than as an absol ute value If the deadband variance for a scaled tag is specified as an absol ute value then no deadbanding is applied to the associated raw tag 274 FactoryLink ECS Core Tasks Configuration Guide SCALING amp DEADBANDING Principles of Operation For this example assume the temperature of the liquid in a tank is being monitored Thetank temperature probe records raw incoming data on a Celsius scale The operators monitoring the temperature are more familiar with the Fahrenheit scal
104. de 59 PROGRAMMABLE COUNTERS Programmable Counters Information Panel In the second example second line on the panel the counter is used to createa one minute delay of an event such as bottle capping Since the Enable field is left blank counting is always enabled When the value of secl becomes 1 ON the Counter task increases the Current Value min delay by 1 Thetask continues to increase this value once each second until the Current Value matches the Terminal Valueof 60 At this time counting stops and the Counter task writes a 1 ON to the Positive Output element min end indicating the end of the one mi nute delay Other FactoryLink tasks can monitor the min end element to trigger another operation and then write a 1 ON tothe Clear element min start to reset the count 60 FactoryLink ECS Core Tasks Configuration Guide Part IV File Manager Table of Contents File Manager 4 File Manada iia xd tct ene db E Ed ede R43 File Manager Control Panel lillisilsllesese eee File Manager Information Panel 02 20 00 eee eee esee Sample File Manager Operations 0000 e cee eee Example T1 COPY ican iudei routaa ER PRO RADE ADR Ade Lea BS Example2 PRINT 00 0 eee tee nh Example3 REN Rename 2 0 ee eee ees 65 66 74 76 76 79 80 Example4 TYPE i 81 Example5 DIR Directory 82 Example6 DEL Ddete sock ck deeded es duce B4 Using Variable S
105. de a cbegin cend block already within the scope of a procedure When you dedarea C variable the declaration block from doegin to cend must be displayed outside the procedure above the PROC statement Refer to the declaration of static FILE Fp stderr in Example 2 below The cbegin and cend statement must each be on a line by itself with no preceding tabs or spaces All lines between these two keywords the C code block are passed directly to the C file PARSECML produces for this program 166 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Calling C Code The following two examples show how to use the cbegin and cend keywords a 4 Example 1 UN PROC TEST STRING message BEGIN DECLARE STRING buff IF message QUIT THEN PRINT FINISHED n ENDIF cbegin sprintf buff The message was S n message fprintf stderr buff cend END j In this program the sprintf and fprintf functions called between cbegin and cend are passed directly tothe C file PARSECML generates for TEST Note that local variables are within the scope of the C code block and can be accessed during calls to external functions Any C code blocks outside the body of a CML program are collected and moved to thetop of the generated C file as shown in Example 2 er o 5 2 r O 2 O FactoryLink ECS Core Tasks Configuration Guide 167 CONFIGURING MATH AND LOGIC Calling C Cod
106. dures in any text editor system for more power for some tasks If you write your own procedures we recommend you validatethese with the FactoryLink editor Also the default font sizein Interpreted Math and Logic is 20 Courier It should be 10 12 pt Courier To change the default use FLFONT To change FLF ONT set FLFONT 212 If no Courier font exists then default to the system fixed font 132 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Configuration Tables MATH AND LoGiIc CONFIGURATION TABLES The confi guration of CML is completed usingthe same panels in the Configuration Manager used to configure IML A new field has been added to the Math and Logic Triggers panel called the Mode field This field controls whether the associated procedureistoberun usingI ML or CML The field uses the key file imlmode key to validate the field You may choose either Interpreted or Compiled to choose IML or CML We suggest all procedures in an application be configured as either Interpreted or Compiled Itis possible torun both IML and CML but the application designer must be sure that any procedures called from a Compiled procedure also be configured as Compil ed Running F LCONV properly converts existing IML tables to the new format Although the Mode field is blank when the application is initially converted the default value for the field is Interpreted so the application may be run imm
107. e fd Example 2 cbegin include mylib h cend PROC TEST STRING s1 BEGIN PRINT The message is sl END cbegin static FILE Fpestderr cend PROC SOMETHING FLOAT f1 BEGIN cbegin fprintf Fp 26 29gNn f1 cend END N VL In this program file the statement static FILE Fpestderr will be moved tothe top of the program file just after the line include mylib h 168 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Calling C Code The fol lowing example shows how to access real time database elements from within embedded C code blocks It increments the values of two analog elements Tagl and Tag2 5 by 10 Pu m cbegin N int fl tagname to id TAG int function prototype missing from CML H cend PROC example BEGIN Cbegin TAG tag 2 ANA value 2 fl tagname to id tag 2 TAG1 TAG2 5 fl read Task id tag 2 value value 0 10 value 1 10 fl write Task id tag 2 value cend END e er D m Q r fe e oO FactoryLink ECS Core Tasks Configuration Guide 169 CONFIGURING MATH AND LOGIC Calling C Code Thefollowing example shows how to manipulate messagetags within embedded C code cbegin cend code bl ocks This example reads from TAGI adds X tothe string then writes the result to TAG2 PROC ADD X E BEGIN cbegin itdefine MAX LEN 80 default maxi
108. e but any trigger type except mailbox can operate as triggers Digital tags only trigger a procedure when the valueis TRUE and the changestatus bit is high Other tag types trigger whenever their value changes This table has one panel Math and Logic Triggers I nformati on Math and Logic Procedure Table TheMath and LogicProceduretablelets you writethe M ath and Logic procedures required by the application E ach program file must be named exactly as it is named in the Math and Logic Triggers Information panel but with a PRG extension After you write a procedure and save it to a program fil e name you can edit it in this panel This tableis a text entry panel Math and Logic Procedure filenameprg Trigger Elements Elements used in Math and L ogic procedures must first be defined in the Math and Logic Variables table Because any Math and L ogic procedure can access them these el ements are global in scope N ote that global elements are not the same as global variables which are declared inside program files and are used only withi n procedures Refer to Structure on page 187 in Chapter 8 Math and Logic Syntax for further discussion of variables and scope If a Math and Logic procedureis triggered by an element the name of this trigger element must be entered in the Math and Logic Triggers table so the procedure will be loaded and run 136 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC
109. e as noted below The stringis converted toa number before the operation is performed conversion stops at the first non numeric character except e A string can be from 0 to 79 characters If an operator enters more than 79 characters as the value of a message the task truncates the string to include only thefirst 79 characters String to numeric conversion stops at the first non numeric character In general when alphabetic characters are used inside a stringthat contains onl y numeric data the task sometimes interprets the characters differently from the way you intended We recommend you set up some type of input checkingif strings areto be routinely accepted as operands for computations A special case is when the letter e is included inside the string During string conversion e is interpreted as exponential an indication the string of digits is to be considered written in scientific notation Refer to Numeric Constants on page 182 for information about numeric representation This allows the representation of larger numbers in a more compact format It can however cause problems if you have not planned for limits on thetype number and location of al phabetic characters inside these strings and if you do not invoke logic to test the contents of the string for appropriateness before calling the conversion routine For an example and a description of the resulting workaround see Example 4 on page 206 204 Factory
110. e Tasks Configuration Guide PERSISTENCE Principles of Operation PRINCIPLES OF OPERATION Persistence begins during application development Whether configuring a new application or reconfiguring an existing application you must first determine whi ch el ements are persistent when the values of the persistent elements are saved todisk and how these saved values are restored during a warm start Then specify this information on the Tag Definition dialog when defining a persistent element At run time the Persistence task saves the values of the persistent elements to its own internal disk cache and thetask writes the data to disk from there Saving the persistent val ues to memory first increases processi ng speed and ensures all val ues meant to be saved are saved within the allotted time 9U SISl d The Persistence task runs under each domain that requires persistent data to be saved The RESOLVE program executed by the FLRUN command creates a blank persistence save file for each domain thefirst time it is executed During its initialization the Persistencetask loads the persistence save file to determine whi ch el ements in the application are persistent and when the values of those elements are to be saved It alsoloads the PERSIST CT file to get specific information about the configurati on of the Persistence task itself When you perform a warm start the current domain s Run Time Manager restores the domain instance s
111. e and wish to havethe data displ ayed on that scale The temperature never falls below freezing or above the boiling point g 9 fb E 2 fb 5 E oe FactoryLink ECS Core Tasks Configuration Guide 275 SCALING amp DEADBANDING Defining Scaling and Deadbanding Operations DEFINING SCALING AND DEADBANDING OPERATIONS 1 To open Scaling amp Deadbandi ng open the Configuration Manager Main Menu and ensurethe current domain selected is SHARED in the Configuration Manager Domain Sel ection box 2 Double dick Scaling and Deadbanding from the Configuration Manager Main Menu to open the Scaling and Deadbanding table Scaling and Deadbanding Information fel E Edit View Utilities Exit Help H Scaled Tag Raw Tag xMinimum xMaximum Minimum xMaximum Raw Value Raw Value Eng Unit Eng Unit tank templ tank temp 0 100 32 212 m Cancel Enter Exit IE of 3 Enter the following information for each scaling or deadbanding operation Scaled Tag Raw Tag Minimum Raw Value Maximum Raw Value Enter the name of the tag to which scaled values will be written In this example the tag is named tank temp f for tank temperaturein F ahrenheit scale The tag for the field from which raw values are to be read n this example the tag is named tank_temp The lowest val ue for raw data Either a constant value or a tag can be specified in this field For this example raw data is being
112. e interval you specify thetimer starts at midnight or at system startup If the interval can be divided evenly into 24 hours 86 400 seconds or 1 440 minutes the ti mer runs as if it started at midnight If theinterval cannot be evenly di vided i nto 24 hours the timer starts at system startup Conventions for use Hours A number between 0 and 23that indicates the length in hours of theinterval Example E very 2 hours 2 every 3 hours 3 etc 44 FactoryLink ECS Core Tasks Configuration Guide EVENT AND INTERVAL TIMER Configuring the Event and Interval Timer Task Mins A number between 0 and 59 that indicates the length in minutes of theinterval Example E very 5 minutes 5 every 10 minutes 10 etc Secs A number between 0 and 59that indicates the length in seconds of theinterval Example Every second 1 every 7 seconds 7 etc 10ths A number between 0 and 9 that indicatesthe length in tenths of a second of the interval Example E very tenth of a second 1 every half second 5 etc When all information has been specified the Interval Timer Information dialog resembles the sample dialog below tut Interval Timer Information n x Edit View Utilities Exit Help Tag Name Hours Mins Secs 10ths E sec5 5 sec30 30 m min 7 lt min20 20 E reportl 1 17 hour8 8 aui mr 3 a Cancel Enter Exit m E WZ D lt gt In this example the sec5 el ement s c
113. e used in a Math and Logic procedure Donot use a Math and Logic reserved keyword as an element name If the element is to be an array specify O for each array di mension when entering its name here For example batch O 0 Then in the Dimension field of the Tag Definition dialog specify the number of elements for each array dimension Valid Entry standard element tag name Valid Data Type digital analog longana message Tag Type Enter the data type of the element identified in the Tag Name field Press ENTER for information from a predefined tag or to complete a tag Valid Entry data type Tag Description Enter a description of thetag identified in the Tag Name field Valid Entry standard element tag name 3 Ifa Tag Name field entry does not havea corresponding Tag Type field entry for tag types of digital analog longana or message a Tag Definition dialogis displayed Choose the appropriate data type 138 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Variables Table When you completethe configuration process the panel resembles the following example uwi Math and Logic Variables Information oy x Edit View Utilities Exit Help il Tag Name Tag Type Tag Description lastcar ANALOG Number of cars worked today tempset ANALOG operator input temperature mh ANALOG current temperature Cancel Enter Exit L1 Inthis example
114. each function to display each line as it executes Also prints out the received values of procedures to the display when they are called 5 Displays the lexemes of the functions as they are parsed NDOMAIN This argument specifies domain F actoryL ink utility Usage Nuser or N shared C This argument specifies that you want a dean rebuild of all the c files generated This is the D er 2 5 2 m fo m 7 same as deleting all thefilein the fF LAPP yuser cml or F LAPP yshared cml directories FactoryLink ECS Core Tasks Configuration Guide 259 COMPILED MATH AND LOGIC Generation of CML Executables The use of the verbose levels V3 and above can cause the linker error DGROUP Exceeds 64K This is because of the large number of strings inserted in the printf statements Pleaselimit the use of V3 and above to debug use only g The following is the output from the command line when running EN FLNEW USER CML parsecml V2 Nuser C creating tag definition file e F LNEWY user cml tagsO bin processing file e FLNE WY user cml test c procedure test E FLNEW USER CM The following is the output from parsecml V5 Nuser C LE NFLNEWNUSERNCML parsecml V5 Nuser C creating tag definition file e FLNEW user cml tags0 bin processing file e FLNEW user cml test c procedure test 2 9 T PROC test 277 T BEGIN 00000000 260 T EQ 1locvar 290 T INT 00000000 311 T
115. ed fiers or wildcard characters Refer to Using Variable Specifiers in F ile Specifications on page 85 and Using Wildcard Characters in File Specifications on page 87 for more information about variable specifiers and wildcard characters Valid Entry full path name FactoryLink ECS Core Tasks Configuration Guide 69 FILE MANAGER File Manager Control Panel Source Variables Names of elements whose values repl acethe variable specifiers in 1 4 thesource path name These fields work in conjunction with the Source File Spec field toform the path of thefileto which theFile Manager performs operations The value of the element in the Source Variable 1 fiel d replaces the first variable specifier the value of the element in the Source Variable 2 field replaces the second variablespecifier and so on If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter If using variable specifiers make the data type of the element match the variable spedfier type Refer to FactoryLink Fundamentals for information about variable specifiers Valid Entry standard element tag name Valid Data Type digital analog longana float message Destination File Full path name of the destination file The destination file spec Spec can use the filename syntax for the operating system on which either the remote or the local station resides f you are using FLLAN the destination
116. ediately after restoration To convert to CML enter Compiled into the Mode field of the desired procedures to Compil ed When you name any Math and Logic objects such as constants variables tags and procedures remember that IML and CML are very sensitive to case and special characters For CML the unique naming is not limited to appearancein Math and Logic code but is also limited to what the name becomes in the generated C code For example special characters become _ by the parsing routine Therefore the following declarations declare short lu lu declare short lu lu declare short lu_lu all become dedare short lu_lu with potentially confusing results such as duplicate definition errors or changes in one variable are reflected in another Remember when naming objects be sure all of these objects have uniquenames D er 2 5 2 e 7 FactoryLink ECS Core Tasks Configuration Guide 133 CONFIGURING MATH AND LOGIC Math and Logic Configuration Tables PRG Files The PRG files are the substance of M ath and Logic The PRG files contain all of the procedures listed in the Math and Logic Triggers table PRG Name vs Proc Name Every PRG file must contain one procedure defined with the same name as the eight character portion of thefilename That procedure must belisted in the Math and Logic Triggers table The IML task only knows which filenames to load by readi ngthe Triggers table
117. eger modulo or modulus Place spaces before and after the keyword MOD to avoid confusion with variable names when the program parses the formula All arithmetic operators except modulo operate on any type of numeric operands induding floating point M OD functions with only integers in the case of tag names this means any combi nation of analog or long analog data types Math and L ogic defines modulo as follows x MOD y This operation returns theremainder after dividing x by y D pus D 5 2 m fo uL FactoryLink ECS Core Tasks Configuration Guide 209 MATH AND LOGIC SYNTAX Structure Thefollowing examples illustrate arithmetic operations Table 8 6 a 17 5 3 Returns quotient of 3 remainder is lost 17 MOD 5 2 Returns remainder of 2 quotient is ignored 17 0 5 3 4 Result is converted to floating point returns quotient and remainder Relational Operators Relational or comparison operators compare one numeri c operand with another and generate a result that describes the outcome of the comparison Theresult of a given comparison is 1 TRUE or 0 FALSE Math and Logic resolves all operands to numeri c form The following chart illustrates rel ational operators used in comparisons Table 8 7 Keyword Type Usage Operation Name Operation Definition If x zy resultis 1 If x y result is O not equal to If x zy result is 0 If x y re
118. elements known as reserved elements each of which is one of the following data types analog long analog or message The following table lists reserved elements that are updated by the E vent and Interval Timer task WhiletheTimer task is running these reserved elements are constantly updated In order for the Timer task to run you must have entered an R flag for the Timer task in the System Configuration Tablein the Configuration Manager Main Menu Table 2 1 Reserved Element Data Type 38 FactoryLink ECS Core Tasks Configuration Guide EVENT AND INTERVAL TIMER Principles of Operation Table 2 1 Continued Reserved Element Data Type YYMMDD YY MM DD Message SECDAY Seconds since start of current day Long Analog SECYEAR Seconds since start of current year Long Analog SECTIME Seconds since anuary 1 1980 Long Analog m lt 5 42 3a o 35 D lt D FactoryLink ECS Core Tasks Configuration Guide 39 EVENT AND INTERVAL TIMER Changing the Operating System Date and Time CHANGING THE OPERATING SYSTEM DATE AND TIME To change the operati ng system date and time while F actoryLink is running shut down the Ti mer task change the date and ti me and restart the task Otherwise the Timer task tries to catch up by processing missed intervals CONFIGURING THE EVENT AND INTERVAL TIMER TASK Use this task to signal the occurrence of spedfied events or intervals by writing to
119. elow If you enter 0 nodisk caching is done This can be desirable if the operating system itself uses an efficient disk caching system such as UNIX Valid Entry numeric value of up to 32766 default 16 Buffer Size Number between 64 and 32766 indicating the size in bytes of each buffer in the cache The default is 512 Thelarger the buffer the less the task writes to the disk which improves performance Valid Entry numeric value of up to 32766 default 512 Message Copy Number between 80 and 32766 indicating the maximum length Size allowed for message elements during persistent saves FactoryLink uses the number entered here when it reads elements from the real time database and when restoring values during a warm start The default is 2048 Valid Entry numeric value of up to 32766 default 2048 24 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Configuring the Persistence Task Backup Trigger Name of an element used to trigger a backup of the current persistent save file A Tag Definition dialog is displayed when you click on Enter if the tag spedfied in this field is not already defined Atrun time when the application triggers the element defined here the Persistencetask copies the current persistence savefile to a backup file Valid Entry standard element tag name Valid Data Type digital analog longana float message The completed panel resembles the following sample ul Persiste
120. ement has the foll owing syntax WHILE test expr 1 Block to be executed while N test_expr remains true WEND J d If the expression test expr is initially false the block is never executed If the expression never becomes false the loop never terminates until the operator or another run time process forces the procedure to stop running Ensure the value of test expr can become false at some point in the loop s execution to prevent the program from hanging The keyword ENDWHILE can besubstituted for WEND D pus 2 5 2 m fo 2 O FactoryLink ECS Core Tasks Configuration Guide 225 MATH AND LOGIC SYNTAX Structure Thefalowing examples illustrate the use of WHILE WE ND control statements F Example 1 n 0 WHILE n lt 10 a n 1 n n 1 WEND tt Example 2 UN fib 0 x fib 1 y n2 WHILE n lt 100 AND fib n 1 lt 10000 fib n fib n 2 fib n 1 n n 1 WEND Indent conditionally executed blocks for readability This does not affect program execution Procedure Calls Procedure calls are statements that cause sped fi ed procedures to execute Procedure calls are used to reference custom written procedures or library fundions which are built intothe FactoryL ink system Syntax Procedure calls havethe following syntax ZT ALL proc_name B D or CALL proc_name argl arg2 arg3 0 The keyword CALL and the ending semicolon
121. ena te te eee ees 128 CALMING tee tne nt eh oh Pete Reh et oe a 2B 7 Configuring Math and LOGIC 0 cee eee ee ee ee 131 Bcc 132 Math and dun Tables RR xn 133 PRG Files DUTIES Comments ETTRTLDDEETTITELEERBESLD Math and Logic Variables Table E io Math and Logic Triggers Table i ae NR Ga MPa andis 30 Math and Logic ProcedureTable c0ccccceeeeeeee 136 Configuring the Math and Pd E OTET ETE ET 137 Choosing a Domain E E E ese T EEE ET Math and Logic Variables Table TDI 138 Math and Logic Triggers Table 0 0 0 cece eee eese 140 Math and Logic Procedures Table 0 2 0 0 cc eee eee eens 143 Correcting Validation Errors ja eere n n n n n n nns 145 Configuration E xamples Using Element Arrays vion dingai a sen LAG Compiled Math and Logic 2 2 0 0 cece eee 149 CML Requirements ein aa aa aha aea eee 150 FactoryLink ECS Core Tasks Configuration Guide 115 Math and Logic Entering CML Intothe System Configuration Table 152 Running CML 22525 eave eee eee be eyed kipin un E ER ee ete ek e DEG 153 Running CML on a Devdopment System 2 153 Running CML on a Run TimeOnly System 153 How CML Operates isi ioa sadia ida wa eee nen 155 Makefiles 159 Editing CML MAK vest unto dames eau eee T59 Advanced Concepts for CML APA aco E fia eae ae Re lead Bae Rate E 161 Utilities and Commands 0
122. ent domai n The name of the makefile used by CCCML is CML MAK andis uniquefor each operating system The CML MAK file located in the FLINK CML directory contains the following information to create the final executable file e Name of the C compiler to use for a given operating system e Command line switches to be used when compiling Name ofthe operating system s object linker e Linker command line switches e References tothe FactoryLink libraries to belinked e References to the developer supplied libraries to be linked Editing CML MAK As an aid for advanced users CML provides a method for editingthe CML MAK file You can changethe compiler and linker options specify command line switches and specify which object files and libraries tolink giving you the flexibility to create a makefile unique to an application for a given domain CML provides two options on the Main Menu for editing CML MAK Math and Logic System Makefile Math and Logic Domain Makefile Math and Logic System Makefile Any changes madeto this file are global they apply to all applications on the system Toedit CML MAK 1 ChooseMath and Logic System Makefile from the Main Menu to display a text editor containing the CM L MAK file from the FLINK CML directory 2 Editthefileasrequired 3 Saveand exit the file D er 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 159 CONFIGURING MATH AND LOGIC How CML Ope
123. entation for information about specific functions for a particular operating system Table 9 2 Mathematical Functions abs x abs y Returns absolute value Example x abs 5 Therefore x 5 cos x cos y Returns the cosine of y Specify y in Example x cos 4 radians Therefore x 0 921061 exp x exp y Returns ey Example x exp 4 Therefore X 54 59815 log x log y Returns the log base 10 of y Example x l09 100 Therefore x 2 FactoryLink ECS Core Tasks Configuration Guide 237 D pe 2 2 2 r e 2l MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 2 Mathematical Functions Continued loge x loge y Returns the natural log of y Example x loge 1 Therefore x 0 pow x y pow z Returns y tothe zth power Example 2 pow 3 Therefore x 8 rnd x rnd Returns a pseudo random positive integer Example x rnd within therange Oto 32767 One possible x 32750 result Note 32765 represents only oneof many possibleresults fromthis call madeto the pseudo randomizer This function cannot be seeded as can a more sophisticated randomizing function and therefore it tends to generate the same sequence of integers each time it is run Noroutine can choose trul y random numbers Probability functions area main component of these library routines which are heavily dependent on thehandling of the routine by the particular operating s
124. er compl eted File Manager forces the value of this element to 1 ON indicatingthat the operation is complete FactoryLink ECS Core Tasks Configuration Guide 77 FILE MANAGER Sample File Manager Operations Table 4 2 Continued Completion Status SSS feos 3 File Manager Control Panel Sample copystat When the COPY operation is complete File Manager indicates the status of the operation by writing an analog val ue to this element U se the task s TASKME SSAGE U 6 tag to report messages on the application screen in addition tothe Completion Status tag F or example if you get a status 12 in the Completion Status tag you also see the message Can t open file path filename If you want to use IML for this function set up a math procedure triggered by the status tag itself In the procedure assign the appropriate ASCII string for each possible status code to a messagetag in a series of IF THEN statements F or example IF status 1 THEN MSG whatever ENDIF 78 FactoryLink ECS Core Tasks Configuration Guide Example 2 PRINT FILE MANAGER Sample File Manager Operations Example 2 demonstrates how to configure a PRINT operation To configure a PRINT operation fill out the Control panel as shown bel ow PRINT command file syntax is the same for all operating systems Table 4 3 Sample File Manager Control Panel e
125. er data both of which tend to become large may exceed 64K Items dedared larger than 64K will nevertheless be allocated only 64K under Microsoft Windows no compile time or panel entry checking is planned to limit the size of declarations because of the multi platform nature of the current FactoryL ink software system Note also that theindex sizing valuefor a variable array is limited to 32K 32 767 array dimensions must be declared so as not to exceed this limit Notetheselimitations when planningapplication data design in other words any global or local variables which must be larger than 64K to serve the needs of the application designer should be partitioned logically during design so no data item as dedared exceeds 64K Contact Customer Support for suggestions on workarounds such as declaring several linked data items if large buffers are needed in an application For OS 2 The 64K barrier under segmented architectures such as OS 2 presents a limitation on the size of some variable data in Math and Logic Neither global nor local variable arrays or data items such as string arrays or message buffer data both of which tend to become large may exceed 64K Items declared larger than 64K will nevertheless allocated only 64K no compile ti me or panel entry checking is planned to limit the size of declarations because of the multi platform nature of the current FactoryLink software system Note also that the index sizing valuefo
126. ery line of the instructions and executes them for each triggered change IML is excellent for application prototyping and logic debugging Most applications written in the Interpreted M ode function with no or very few modifications under the Compiled Mode If an application runningin Interpreted Mode uses any reserved words as variables or procedure names these will need to be modified so the compiler will be ableto compile and link the procedures error free These words include any reserved by the C compiler for the platform you are runni ng on as well as those reserved by F actoryL ink Using IML When you use IML you create procedurefiles that arescripts and manipulate both real time database el ements and local variables Interpreted mode is most appropriate when e Only mathematical functions will be performed e A compiler is not available Running IML After starting the application Load the program into memory e Validatethe program Wait for changes tothe trigger el ements in the real time database associ ated with the procedures in the program e Execute the program associated with the trigger when thetrigger element is set to 1 ON 124 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC OVERVIEW Modes Executing IML When procedure changes are triggered in the real time database ML determines the proper procedure requested and then interprets and executes theinstructions in the procedure Eac
127. eting all the filein the F LAPP Yuser cml or f LAPP Yshared cml directories 266 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables The following is the output of running mkcml V 2 Nuser C creating tag definition file D CMLDOC ZIP FLAPP user cml tags0O bin processing file D CMLDOC ZIP FLAPP user cml test c procedure test processing file D CMLDOC ZIP FLAPP user cml syscp c procedure syscp processing file D CMLDOC ZIP FLAPP user cml cfunk c procedure cfunk processing file D CMLDOC ZIP FLAPP user cml cbwtags c procedure cbwtags Lest c SySCp C cfunk c cbwtags c glvars c Building Compiled Math and Logic task for application D CMLDOC ZIP FLAPP at domain user Compiling cl DOS2 Au Od Zp G2s nologo c ID FLOS2431 inc test c Compiling cl DOS2 Au 0d Zp G2s nologo c ID FLOS2431 inc SySCp c Compiling cl DOS2 Au 0d Zp G2s nologo c ID VFLOS2431Vinc cfunk c Compiling cl DOS2 Au Od Zp G2s nologo c ID VFLOS2431Vinc cbwtags c Compiling cl glvars DOS2 Au 0d Zp G2s nologo c ID FLOS2431 inc D er 2 5 2 r e O Compiling cl DOCCMLPROCO C FactoryLink ECS Core Tasks Configuration Guide 267 COMPILED MATH AND LOGIC Generation of CML Executables Microsoft R Segmented Executable Linker Ve
128. first Example x asc TEN character in string Therefore x 284 84 is the ASCII DEUM code for T chr string chr var Returns equivalent character of an Example msgvar chr 66 ASCII code Therefore msgvar B 66is the od ASCII code for B instr x instr str1 str2 Reurns the offset into str1 of the Example x instr ABCDE B occurrence of str2 Therefore x 2 len x len string Returns the length of string not Example x len MIAMI induding the terminator FLORIDA Therefore x 13 FactoryLink ECS Core Tasks Configuration Guide 239 D pun 5 2 5 2 e 2 7 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 3 String Manipulation Functions Continued lower Example Therefore string lower string msgvar lower NOT msgvar not Returns string converted tolower case Itrim Example Therefore string Itrim string msgvar Itrim SMITH msgvar SMITH Returns string with leading blanks trimmed substr Example Therefore string substr string offset len msgvar substr AB CDE 3 2 msgvar CD Returns a string of len length or less beginning with the offset character from the beginning of string The offset tothe first character in string is 1 trim Example Therefore string trim string msgvar trim SMITH msgvar SMITH Returns s
129. for both Device 1 line 1 and Device 2 line 2 Print Spooler then recognizes Devices 1 and 2 arethe same physical device and it acts accordingly FactoryLink tasks use the first entry in the Print Spooler Information panel as the default output device F or example when you request a print screen in Run Ti me Graphics the output goes to thefirst device defined the Print Spooler panel 106 FactoryLink ECS Core Tasks Configuration Guide PRINT SPOOLER Configuring the Print Spooler You can changethis default by moving the information for another defined device tothe panel s first line using the cut and paste features You can also direct output to a filerather than to a port by specifying a path and file name If Print Spooler writes to an existing file the new values text are appended tothat file in the speci fi ed format If output is redirected to a disk file as opposed to a true device the file opens in append mode before it receives output If the file does not exist when Print Spooler is first started itis created if any print jobs are directed to it The characters written to it are precisel y the same as if it were a true device indudingall device command sequences Y ou can use such file redirection to capture output for later examination and or printing at a time when FactoryL ink is shut down The Print Spooler task can send output to multiple devices at once Thefollowing example contains Valid entries z
130. for the elements either individually or for the entire domain These methods are explained in Configuring Persistence for New Applications on page 18 CoNFIGURING PERSISTENCE FOR NEW APPLICATIONS Tousethe warm start feature you must confi gure which el ements are persistent when their values will be saved and how to restore their changestatus bits during a warm start of F actoryLink You can configure persi stence in one of two ways e For individual elements Forall of the elements in a domain The fdlowing sections discuss how to confi gure persi stencefor both cases 18 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Configuring Persistence for Individual Elements CONFIGURING PERSISTENCE FOR INDIVIDUAL ELEMENTS Configure persistence for individual elements in the Tag Definition dialog The Tag Definition dialog is displayed when you Define a new element in either a configuration panel from the Main Menu or in an animation panel in the Application E ditor e PressCtrl T in a Tag field for a previously defined element Perform the following steps to configure persistencefor individual el ements U t e o t 3 Qo 1 1 Define anew element or press Cirl to display the Tag Definition dial og Tagname we Description TO Type Domain r Size Array ill Dimensions Longini Default Value Persistence r Use Domain Settings Saving Restoring r
131. formation panel u File Manager Information 8 Edit View Utilities Exit Help a Tag Name zl Table Name Cancel Enter Exit Next Prev af Following are field descriptions for this panel Tag Name Required only for DIR and TY PE operations not used with COPY PRINT REN and DEL operations Name of a message element that as a result of a DIR or TYPE command receives a message value to be displayed in a single line on a graphics screen The number of Tag Name fields defined in this panel determines the number of lines displayed as a result of a DIR or TYPE command at run time If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter with a tag type of messagein the Typefield Accept this default Values are written tothe el ements defined in the Tag Name field whenever a DIR or TYPE operation is triggered or whenever the operator changes the value of the Position Trigger element defined in the Control panel A different valuein the Position Trigger element means information from a different placein the directory or file is displayed Click Enter to save the information when theF ile Manager Information panel for thespecified command DIR or TYPE is complete Remember to configure one File Manager Information panel for each DIR or TYPE operation defined in the File Manager Control panel 74 FactoryLink ECS Core Tasks Configurat
132. gital default digital Year Mon Day Specify a period when an event is to occur Enter a Year Year DOW month Mon day Day and day of the week DOW or combi nation as explai ned below When using Day and Month the event occurs onl y on this datein the specified month in the specified year If you do not enter a month the event occurs on this date every month If you do not enter a month and year the event occurs on this date every month of every year When using DOW if you enter a month the event occurs on this day every week of that month only If you do not enter a month the event occurs on this day every week f you enter a month and year the event occurs on this day every week of the specified month during the specified year If you do not enter a month and year the event occurs on this day every week of every year Year 4 digit year such as 1994 Month 1 12 or MMM Example March is 3 or MAR for first three letters of the month s name m lt D gt o a 3 D lt D Day 1 31 indicating the day of the month the event is to occur If the event is to occur once every day leave this field blank DOW MON SUN First three letters of a weekday If the event is to occur once every day leavethe fi eld blank Hours Refer tothe following discussion of Hours Mins and Secs FactoryLink ECS Core Tasks Configuration Guide 41 EVENT AND INTERVAL TIMER Configuring the Event and Inte
133. h time an IML programis executed M ath and Logicfirst reads or interprets theinstructions within the program to determine the actions to perform Then it executes those acti ons Switching from IML to CML To make switching from IML to CML in large applications a one step process use the following procedure FromtheBH SQL prompt in the F LAPP directory of the application issue the following command e Tochange from IML to CML use the following command SQL gt update imltrig set mode 2 COMPILE D where mode is not null e Tochange from CML toIML use the following command SQL gt update imltrig set mode INTERPRETED where modeis not null Compiled Mode Compiled mode is a combination of several FactoryL ink utilities with a third party AN SI C language compiler worki ng together to generate ANSI C code from user created prg files In CML the procedure program fileistranslated into C source code to create a binary executabl efile for the platform on which the application is developed Because the application consists of both the SHARED and USER domains CML creates two executable files one for each domain These executables are unique and are named For SHARED domain fF LAP P YSHARE D CML CSHARED EXE For USER domain AF LAPP YUSER CML CUSER EXE These files perform the same actions described in the programfile when the associated trigger elements areset CML increases the speed and functionality of applicat
134. hange status flags are set to 1 every 5 seconds that is when the reserved analog element A SEC 0 5 10 15 55 This timer runs as if it started at midnight Therefore if system startup ti meis 9 39 18 the sec5 element s change status flags are first set 2 seconds later at 9 39 20 and every 5 seconds thereafter The sec30 element s change status flags are set to 1 every 30 seconds when A SEC Oand 30 This timer runs as if it started at midnight The min7 element s change status flags are set to 1 every 7 minutes after system startup because 1 440 is not evenly divisible by 7 The min20 element s change status flags are set to 1 every hour again at 20 minutes after the hour and again at 40 minutes after the hour FactoryLink ECS Core Tasks Configuration Guide 45 EVENT AND INTERVAL TIMER Configuring the Event and Interval Timer Task The report1 element s change status flags are set to 1 every hour and 17 minutes after system startup The hour8 element s cdhangesstatus flags are set to 1 threetimes a day at 8 00am 4 00 pm and midnight regardless of system startup ti me When interval timers are used as tri ggers for other tasks such as PLC read triggers or Report Generator triggers these tasks automatically use the change status flags associated with these ti mers 46 FactoryLink ECS Core Tasks Configuration Guide Part Ill Programmable Counters Naam m 10 LALA ANA N 10 10 TC oe ee wo oe we O
135. haracteristics of change status operators Table 8 14 Operator Type Usage Operands Operation Name unary x tag name change status changed changed x When checking change status do not enclose the database element name operand in parentheses The construct x is misinterpreted by Math and Logicin this context and will not produce the desired result Always use the construct x or changed x D pus 2 5 2 e O FactoryLink ECS Core Tasks Configuration Guide 215 MATH AND LOGIC SYNTAX Structure A change status operator is defined as follows Table 8 15 Operator Definition X Theoperation returns TRUE 1 ifthevalue changed x of x has changed since it was last read or change read by Math and Logic and FALSE O if it has not The fd lowing example illustrates two change status operations Table 8 16 Operation Results y y x Increments the value of y by 1 whenever the value of x changes If changed tag name then Initiates the procedure proc name call proc proc_ name whenever the value of the element Endif tag_name changes Do not perform change status operations on elements being used as procedure triggers trigger elements This may prevent the corresponding procedure s from being triggered at the proper time This is because checking the change status of theelement resets the change bit for that element Assignment Operators Assignment operat
136. he keywords AND NOT and OR to avoid confusi on with variable names when the program parses the formula The following examples ill ustrate logical operations Table 8 10 Operation Return Value NOT 3 NOT O NOT 1 OAND 1 OANDO 1AND 2 212 FactoryLink ECS Core Tasks Configuration Guide Table 8 10 Continued Operation MATH AND LOGIC SYNTAX Structure Return Value Bitwise Operators Bitwise operators compare and manipulate the individual bits of their operands Math and Logic resolves all operands to integers The fol lowing chart illustrates bitwise operators Table 8 11 Operator Type unary binary binary binary Usage Ix x amp y Operands Operation Name integer bitwise one s complement integer bitwise AND integer bitwise OR inclusive OR integer bitwise XOR exclusive OR FactoryLink ECS Core Tasks Configuration Guide 213 D pus D 5 2 r e O MATH AND LOGIC SYNTAX Structure Math and Logic defines bitwise operations as demonstrated in thefollowing examples Table 8 12 Operation Bit Value Return Value 9 1001 10 1010 1000 9 1001 10 1010 1011 9 1001 10 1010 0011 9 0000000000001001 10 1111111111110110 1111111111111111 9 0000000000001001 bitwise flip produces 11111111111110110 19 11111111111110110 Grouping operators The following operators provide grouping information
137. he name of a o path for a sample remote station network D stati on D Q 7 c Using Wildcard Characters in File Specifications 5 17 Format path names as follows Table 4 23 source directory subdirectory wildcard filespec destinati on directory subdirectory Do not specify a filename for the destination path as File Manager will do it for you Path names with wildcard characters in the file specifications might resemble the following examples Table 4 24 source flink sample sample destinati on flink exe FactoryLink ECS Core Tasks Configuration Guide 99 FILE MANAGER Operating System Notes 100 FactoryLink ECS Core Tasks Configuration Guide Print Spooler Print Spooler Table of Contents Print Spooler 104 FactoryLink ECS Core Tasks Configuration Guide Chapter5 Print Spooler TheFactoryLink Print Spooler task permits you to direct data to printers or other devices with parallel interfaces and also to disk files The Print Spooler task also provides other features e Filename spooling loads file when print deviceis available minimizing required memory e Management of printing and scheduling functions Print Spooler receives output from other F actoryL ink tasks such as Alarm Supervisor or File Manager and sends this output toa printer or disk file With Print Spooler you can define up to five devices to receive output from other
138. he target system Calling Functions that Operate on Tag IDs CML Only Math and Logic provides a function that looks up tag names and retrieves their tag I Ds so developers can call and use functions that operate on tag Ds and not tag names This function is int fl tagname to id TAG tp int num char tagname where TAG tp is a pointer toa developer supplied tag array to be filled in with taglDs int num is the number of tag names to look up char is one or more character pointers to valid tag names This function returns a code indicati ng either GOOD or ERROR It is designed for developers who integrate C source code intotheir Math and Logic programs and is availablethrough the CML run time library By usingfl tagname to id inside CML C code blocks developers can look up one or moretag names and fill in a developer supplied tag array with the tag I D for each tag name Developers can then use these Tag Ds with the FactoryLink PAK functions and any other function that operates on the tag D instead of the tag name just as the Math and Logic grammar does fl tagname to id is a variable argument function like print The developer can retrieve as many valid tag I Ds as tag array has room for 248 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes The fol lowing example shows how to usefl tagname to id cbegin void myfunc TAG list 2 fl_tagname_to_id
139. hs We recommend you create a standard column oriented naming for the tags with fixed length fields in the name This lets you browse a list of tags by attribute by lookingfor a particular column D pus 2 5 2 m fo 2 O FactoryLink ECS Core Tasks Configuration Guide 175 e MATH AND LOGIC SYNTAX Math and Logic Reserved Keywords MATH AND Locic REsERVED KEYWORDS A keyword is a word that has a spedal meaningin a particular programming language M ath and Logic reserves a set of keywords for usein Math and Logic programs B ecausethese keywords have predetermi ned meanings they cannot be used as procedure names local or global variable names constant names or database element names in Math and Logic Math and Logic keywords are not case sensitive so you cannot use themin either case Math and Logic reserves use of the keywords in the following list 176 FactoryLink ECS Core Tasks Configuration Guide abs add tag alltim ana and argent Argcount Argvect asc asm auto begin break call case cbegin cend cfunc changed char check_security chk_prot_bit chkz chr ckalloc clrstack cml force math cmlpp_listconst cmlpp_options continue connect cos ct_load debuge declare default dig div do doabs doadd MATH AND LOGIC SYNTAX Math and Logic Reserved Keywords MATH AND LOGIC RESERVED KEYWORDS doand doasc doband dobneg dobor dochr dodiv doeq dogetarg doge
140. icant than the startup order if the tags are saved on change I n general specify the Persistence task to shutdown first and therefore start last so that the saved values in the Persistence save file reflect thelast known running state of the application at shutdown Then the warm start will restoreit tothat state which is the purpose of the Persi stence task 26 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Persistence and Digital Elements PERSISTENCE AND DiGITAL ELEMENTS The way a digital element is used in an application affects how that element is configured for persistence Digital elements are often used to trigger some action in an application Examples include starting a Math and L ogic procedure or starting a FactoryLink task When a digital element is triggered its valueis changed from Oto 1 or force written to 1 FactoryLink starts the associated procedure or task When FactoryLink is warm started these elements are restored to their last saved value Configuring a digital element as persistent with its value to be restored with F orce Change Status ON can be used tostart any procedure or task associated with this element after the systemis initialized 9U SISl d However the di gital elements RTMCMD and RTMCMD U cannot be made persistent This is because when the value of these el ements is set to 1 the FactoryL ink system shuts down Therefore making these elements persi stent immediately shut
141. ime only systems CML run time option Development systems CML run time and devel opment options An ANSI compatible C language compiler for Development systems e Run time only systems that run on an operating system different from the development system The following table shows the supported C compilers for each operati ng system Table 7 1 Operating System Supported Compiler IBM AIX XL C Compiler 6000 HP UX HP UX C ANSI C MS Windows NT Compiler purchased with the Microsoft Visual C 32 bit E dition for Windows NT SCO Open Desktop SCO Open Desktop C Refer to the user manual for the particular compiler in use for information about compiler switches and setup options Option bits e Development systems the CML run time and development options e Run time only systems the CML run time option 150 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC CML Requirements For Windows NT and Windows 95 Compiled Math and Logicfor Windows NT and Windows 95 requires the environment variable F LCOMPILE to be set This environment variable points to thedirectory of the compiler you areusing Enter the followinglinein the AUTOEXEC BAT filefor Windows 95 and the Registry for Windows NT to set the FLCOMPILE environment vari able For Windows NT FLCOMPILE DRIVEACOMPILER DIRECTORY For Windows 95 set FLCOMPILE DRIVE COMPILER DIRECTORY Example set FLCOMPILE c BC4 D er 2 5 2 r
142. inal Value until Clear is triggered 58 FactoryLink ECS Core Tasks Configuration Guide PROGRAMMABLE COUNTERS Programmable Counters Information Panel When all information has been specified the panel should resemble the sample below us Programmable Counters Information of x Edit View Utilities Exit Help 5 Enable UP Clock DOWN Clock Clear Positive Negative B8 Output Output btl upclock btl clear btl done min start min end E Cancel Enter Exit aimi us Programmable Counters Information B x Edit View Utilities Exit Help Negative Current Preset Increment Terminal AutoClear B Output Value Value Value Value btl count 0 1 NO min delay 0 1 60 NO E Cancel Enter Exit 4 In the first example first line on the panel the counter along with a Math and Logic procedure that saves the count and resets the counter counts the number of bottles packed per minute Sincethe Enable field is left blank countingis always enabled Each time a bottle is packed a 1 ON is written tothe Up Clock element btl_upclock This triggers the Counter task to increase the Current Value btl count by 1 Each minute FactoryLink triggers a Math and Logic procedure to log the Current Value and trigger the Clear element bt clear to reset the count for the next minute o e o9 c o C o 4 gt FactoryLink ECS Core Tasks Configuration Gui
143. ing point values to along integer value When type casting a floating point to a long a call is FactoryLink ECS Core Tasks Configuration Guide 257 D er 2 5 2 r e O COMPILED MATH AND LOGIC Generation of CML Executables made to a compiler specific function to convert the compiler s internal storage format of floati ng point values to a long integer value This function is unique to each compiler manufacturer and they may namethe conversion function differently Insidethe CML library you need to perform floating point to long conversi ons To be able to support the MSC 6 0 and IBM C 2 compilers for FactoryL ink for OS 2 we havecreated thefunction longfl ftol double and placed it in thefile glvars c In the CML library we call this function only when casting floati ng points tolongs This results in compiler independence Remember global variables are user defined variables that are dedared outside the body of any procedure All global data is placed in glvars c d All the FactoryLink tags used in the proceduresthat arealso in the FactoryLink RTDB Real Time DataBase arelistedin thefile named tags bin and is created by the CML task These files are named in similar fashion as the emlproc c files Each file can contain 500 tags When the 500 tag li mit is reached dosethe current tags bin fileand start the next one i e tagsO bin tags1 bin and so forth These files are of binary format You can view the c
144. ion Guide FILE MANAGER File Manager Information Panel TheFileManager Control and File Manager I nformation panels should resemble theillustrations shown in Sample File Manager Operations on page 76 Valid Entry standard element tag name Valid Data Type message 1 J o gt o Q D FactoryLink ECS Core Tasks Configuration Guide 75 FILE MANAGER Sample File Manager Operations SAMPLE FiLE MANAGER OPERATIONS The examples below illustrate each type of fil e management operation n these examples entries for each type of file management operati on are displayed in separate sample Control panels in a real FactoryL ink application all file management operations are configured in one Control panel The first four examples do not requirethat you complete an associ ated F ile Manager nformation panel Thelast two examples do require that you complete a FileManager Information panel Example 1 COPY Exampl e 1 demonstrates how to configure a COPY operation using Windows file syntax Y ou can configurethe Math and Logic task or an analog counter in the Counters task to use this operation toincrement the alarm history file number This results in arolling count of the history file being transferred Hist 001 Hist 002 and so on To configure a COPY operation fill out the Control panel as shown below Table 4 2 Sample File Manager Control Panel ESI THIS 3 M TableName WINCOPY Because the COPY ope
145. ion Guide PERSISTENCE Configuring Persistence for All Elements in a Domain CONFIGURING PERSISTENCE FOR ALL ELEMENTS IN A DOMAIN Complete the following steps to configure persistence for all elements in a domain in the Domain Element List 1 Choose View gt Domain List to display the Domain Element List u4 Domain Element List lolx Edit View Utilities Exit Help U o e o t 3 Qo 1 Cancel Enter Exit K The list includes the domain name the parent domain the number of application instances available for the domain domain persistence and the setting for change bits Use the Persistence and Change Bits fields to configure persistence for an entire domain 2 Choose the Persistence field for the row containing the domain to be made persistent Enter the method you want to use to save the elements values This can be one of the foll owing None Theelements in the domain are not marked as persistent Timed Saves the values of the domain s elements on ati med trigger Except Savesthevalues of the domain s elements whenever their values change Both Saves the values of the domain s elements both on a ti med trigger and whenever their values change 3 ChoosetheChange Bits field for the same domain and enter how you want to restore the elements change status bits This can be one of the following ON Restores the domain s elements with their change status bits set to 1 ON after a warm s
146. ions e RunsCTGEN to create toIML CT Runs PARSECML in both domains to convert the PRG files to C files e Runs CCCML tocompileand link the CML domain executables PARSECML The PARSECML utility generates ANSI C code from each PRG file It have various levels of debugging via the VX parameter that can simpl e generate more detailed output or even add debugging statements to the C code CCCML The CCCML utility compiles and links the CML domain executables via the FLINK CML CML MAK file Its debugging levels only provide such information as the exact command line used to compile and link the code TheFLINK CML CML MAK is platform dependent and is the heart of the portability of FactoryLink Following is an example from OS 2 SRCSUFFIX c OBJ SUFF IX obj These variables darify the operating system C compiler naming convention for source and object filed cc ear F D m Q r fe e oO The CC variable designates the command li ne compiler FactoryLink ECS Core Tasks Configuration Guide 161 CONFIGURING MATH AND LOGIC Advanced Concepts for CML CCFL AGS doz2 AL Au Od Zp G2s nologo lt IF LINK inc CCFLAGS specifies all of the command line options for compiling the C files CMLOBJS glvars obj cmlprocs obj CMLOBJ S arethe stock CML files that arenot application dependent They are liableto changeas versions change USEROBJS Userobjs allows for the inclusion of user defined object modu
147. ions that use IML D er 2 5 2 m fo 2 O FactoryLink ECS Core Tasks Configuration Guide 125 MATH AND LOGIC OVERVIEW Modes Using CML When you use CML you makeimprovements on applications that use complex loops such as nested IF THEN ELSE dauses or WHILE loops Interpreted mode handles the execution of arithmetic operations fairly quickly but CML adds more functionality for you as an in line function to pass simple parameters and as an embedded C code block to pass complicated parameters Compiled mode is most appropriate when you want e Faster startup and execution for improved performance e Better handling of complex multiple conditional statements Ability to call C functions or toinsert C code into procedures Availability of extensive flow control for the application Running CML After starting the application Wait for changes tothe trigger el ements in the real time database associ ated with the procedures in the program e Exeautethe program associated with the trigger when thetrigger element is set to 1 ON Executing CML Each time a compil ed program is executed CML e Reads ar interprets the instructions within the program to determine the actions to perform e Exeautes these actions CML Operation CML uses three utilities for specific roles in creating the executables used at run time These utilities are e MKCML e PARSECML e CCCML 126 FactoryLink ECS Core Tasks Configura
148. ks Configuration Guide Chapter 11 Scaling amp Deadbanding The Scaling and Deadbanding task SCAL E EXE is used to convert or scale incoming raw data toa different value range and toindicate a dead or non recalculati ng band around a scaled value o O o o 5 2 The linear scaling feature of the task is used to convert or scale the incoming raw data to a different value range Many values read from a programmable logic controller PL C arein units other than thosethe user wishes to display manipulate and or archive Use of the scaling task eliminates the need to process data through an intermediate routing mechanism and the need to write codeto perform the scaling function when the scalingis linear The scalingtask if given ranges for the incoming and desired data values can derive the necessary conversion factor and or offset and perform the linear scaling calculations automatically using the formula g D 2 oy S 5 2 5 e mx b y where x is theraw value mis the multiplier b is a constant and y is the result The Deadbanding task is used toindicate a band or area around a value small enough to be considered insignificant In this case the new valueis stored and a new deadband recalculated but the new valueis not written to the program database Since F actoryLink tasks process values upon every change deadbanding provides a means of saving processing time and improving system efficiency N
149. l Panel Using Wildcard Characters ELM Sample Entry Explanation Command COPY Desi gnates a COPY operation Trigger copytrig Name of the digital element used to tri gger the copy operation FactoryLink ECS Core Tasks Configuration Guide 87 FILE MANAGER Using the File Manager with Networks Table 4 12 Continued Sample File Manager Control Panel Using Wildcard Characters Field Sample Entry Explanation Source cV hist report Designates the source path Format rpt Destination CA HIST At run time all files in the REPORT Format RECORDS subdirectory that begi n with RPT are copi ed to the RECORDS subdirectory UsiNG THE FiLE MANAGER WITH NETWORKS In addition to being fully compatible with F actoryL ink the FactoryLink File Manager is compatible with networks using the following protocol types e DECnet e NETBIOS TCP IP File management functi ons such as copying deleting printing and renaming files can be performed between the local F actoryL i nk system and any remote computer running File Manager as long as the FactoryLink system contains the FactoryLink Local Area Networking F LL AN option If using FLLAN createthe LOCAL file before filling in the configuration tables Define the local station namein the ASCII file LOCAL in theFLAPP NET directory Stand alone systems do not require the LOCAL file Either the sourceor destination path name can refer to
150. le at link time LINK TheLINK variable designates the command linelinker LKF LAGS NOE ST 16384 se 512 CMLLKOBJS USERLKOBJS These variables also allow for the indusion of object modules not usually part of CML CMLLIBS LINKALIBVFLIB LIBY FLINK LIB CML LIB USERLIBS These variables also allow for the indusion of libraries not usually part of CML User defined C languageindudes files that use quotes eg zind ude sample h should be placed in the F LAPP DOMAIN YCML directory Include files of the form nclude lt sample h gt should be placed in the path searched by the compiler You may want to place themin the FLINK INC directory and this is okay however the include files will not be saved with the application on an MPS The best place to put the include files is in the FL APP Y DOMAIN YCML and then they will be saved with the application when an MPS multi platform save is performed If you place the include files in the latter directory you should add the fol lowing to the cml mak file on the line CFLAGS 162 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Advanced Concepts for CML dos2 AL Au Od Zp G2s nologo c I FLINK inc I FLAPP LDOMAIN CML DEF FILE FLINKA CML CML DEF This specifies the link definition file Under some platforms it contains special information about window attributes and resources On others it contains compiled output options If this is
151. lement used totrigger thetype Trigger operati on Command TYPE Designates a TYPE operation Position typescroll Name of the analog element that controls the Trigger output of the TY PE command Source 96s This field contains a variable spedfier which the File Spec FileManager replaces at run time with the value of the message element typepath designated in the Source Variable 1 fiel d Source typepath At runtime when the val ue of the digital element Variable 1 typetrig is forced to 1 ON theFile Manager types the file specified by typepath Because TY PE operations do not need a destination the Destination Variable fields are left blank TagName typlinl At runtime when the value of the digital element typlin2 typetrig is forced to 1 ON the F ile Manager reads typlin3 the fil e specified in the Source Tag 1 element typlin4 typepath The File Manager starts reading after the typlin5 line number specified by the Scroll element typlin6 typescroll In this example eight lines of text from typlin7 the specified file are read into message elements typlin8 typlin1 typlin2 typlin8 These message elements may be referenced by other F actoryL ink tasks such as the Graphics task for display on a graphics or text screen FactoryLink ECS Core Tasks Configuration Guide 81 FILE MANAGER Sample File Manager Operations Example 5 DIR Directory Example 5 demonstrates the DIR Directory command DIR
152. les can be of one of thefollowing data types SHORT digital SHORT analog LONG long analog FLOAT STRING message D pus D 5 2 m fo uL 7 FactoryLink ECS Core Tasks Configuration Guide 189 MATH AND LOGIC SYNTAX Structure Although procedure variables arenot el ements in thereal time database they are still represented in system memory and can be saved and opened repeatedl y or printed during the running of those procedures that can open them Use the following guidelines to determine whether to dedare a variable as a procedure variable or as a element e If thevariableis opened from an external source declare it as a database el ement e If thevariableis a trigger for any procedure it must be declared as a database element defined as atrigger element with an assodated trigger tag name e f thevariableisused only by Math and Logic and must be accessible by all of the procedures within a program fil e declare the variable as a procedure variable with a global scope by declaring it outside thefirst procedure in the program file e If thevariableisused only by Math and Logic and is used only within a particular procedure dedare the variable as a procedure variable with a local scope by declaring it inside that procedure Local Procedure Variables Dedare local procedure variables immediately after the BEGIN statement A local variable dedaration must precede all other instructions in a procedure
153. les declared outside of a procedure The case of a variable nameis significant A variable name cannot begin with a digit 0 9 e Variables cannot be initialized at declaration Arrays cannot be passed as arguments toa procedure but individual array elements can Constant Declarations Constants are shared by all procedures and must be ded ared before any procedure in which they are used Therefore place constant declarations above the procedure statement of the first procedure within the program file in which the constant is referenced Only one constant can be declared on each li ne D pus 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 195 MATH AND LOGIC SYNTAX Structure Procedure Declarations A procedure dedaration identifies a procedure either defined later in the current program file or is referenced called by a procedurein the current program file It is comparable to a forward reference in the Pascal programming language used when a procedure calls another procedure not yet encountered but al ready exists Useone of the following forms to dedare a procedure depending on whether or not the procedure will accept arguments DECLARE PROC name or DECLARE PROC name typeL type If a procedureis to take arguments use the second form given above Only the data type of each argument is given in a procedure declaration The data type of each argument is the sameas
154. lin8 These message elements may be referenced by other FacoryLink tasks such as the Graphics task for display on a graphics or text screen ay o o gt o Q D FactoryLink ECS Core Tasks Configuration Guide 83 FILE MANAGER Sample File Manager Operations Example 6 DEL Delete Exampl e 6 demonstrates the DEL Delete command using Windows file syntax Table 4 7 Sample File Manager Control Panel ETE Sample Entry Explanation TableName WINDEL Designates the name of a DEL operation Command deltrig Name of the digital element used to Trigger trigger the delete operation Command DEL Designates a DEL operati on Source cA hist s tmp This field contains a variable specifier FileSpec which File Manager replaces at run time with the value of the message el ement delfile designated in the Source Variable 1 field Source delfile At runtime when the value of the digital Variable 1 element deltrig is forced to 1 ON File Manager deletes thefile specified by delfile Because DEL operations do not need a destination the Destination Variable fields are left blank 84 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Using Variable Specifiers in File Specifications USING VARIABLE SPECIFIERS IN FILE SPECIFICATIONS If the operator or the system is to enter all or part of the source or destination specification use variable sped
155. list 2 TIME DATE cend In this example the function retrieves the tag I Ds for the two real time database elements TIME and DATE and places their IDs into the tag array named list D er o 5 2 r O 2 O FactoryLink ECS Core Tasks Configuration Guide 249 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes 250 FactoryLink ECS Core Tasks Configuration Guide Chapter 10 Compiled Math and Logic The FactoryLink Math and Logictask executes user written procedures i e scripts that coordinate objecti ves and other F actoryLink tasks These procedures can be written so at run time they are triggered by responses to changes in the RT DB or they can be executed directly from within other Math and Logic procedures Math and Logicis atask that includes integrating several components These work in the following relationship D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 251 COMPILED MATH AND LOGIC Pre FactoryLink Run Mode Setup 1 System Configuration Panel Setup 2 Configuration of FactoryLink Table A Variables Table B Triggers Tab C Procedures user constructed logic IF in Interpreted Mode IF in Compiled Mode application is ready torun processing procedures for running and FactoryLink appli cati on programs must be created starts LPARSECML producing C code 2 CCCML compiling and linking generated code 3 Exe
156. lity compiles each C fileproduced by PARSECML into an object fileusing an external compiler It then links the object files with theF actoryLink and developer supplied libraries intoa binary executable To determine the name of the compiler to use for a specific operating system CCCML uses a special file called a makefile Running the Utilities from the Command Line TheFLRUN command sets the F actoryL ink path the application directory path theuser name and the domain nameto the environment variables and turns off the verbose level and dean build parameters 156 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC How CML Operates CML is designed so each of the CML utilities can bestarted from the command line if required This can beuseful if during application development you need to perform only a porti on of the compile process The command line parameters used by all CML utilities aredescribed in the following table Table 7 2 CML Command Line Parameters Parameter Description EE Sets the path to the F actoryLink program files Sets the path to the application directory Sets theuser name Sets the domain name Sets the verbose debug level to x aC Performs a dean build reproducing all files from scratch D er 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 157 CONFIGURING MATH AND LOGIC How CML Operates Verbose Level Parameters When you
157. ll formed expressi ons assuming the data types of each operand are valid with the operators xc X 3 5 temp lt 0 OR temp gt 100 outrange AND valvel 1 OR valve2 1 100 sin voltagel voltage2 display MENU logical comparison for IF or if WHILE not an assignment This is message to the operator Operators Operators are symbols or keywords that are used in expressions to specify the type of operation to be performed Operators can be either unary or binary Unary operators operate on only one operand at a time while binary operators operate on two operands at a ti me Math and Logic employs the following operator groups They are listed in order of relative precedence that is the order in which thetask performs the operations in an expressi on e Arithmetic e Relational e Logical e Bitwise e Grouping e Change Status Assignment 208 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Arithmetic Operators Arithmetic operators perform arithmeti c operati ons on their operands The following chart illustrates arithmetic operators Table 8 5 LIJECNIHEIIE E binary x y numeric addition binary x y string concatenation binary x y numeric subtraction unary X numeric negation i binary x y numeric multiplication binary Xy numeri c di vi sion di binary x y numeric exponenti ati on MOD binary xMOD y int
158. lower temperature SEC2 PID COMPILED Process value derivative ini Cancel Enter Exit ade In this example the M ath and Logic procedure SETTEMP is run as interpreted at run timeand the procedure PI D is compiled at run time When the value of trigger element SEC1 becomes 1 ON Math and Logic runs SETTEMP When the value of trigger element SEC2 becomes 1 ON Math and Logic runs the executable for PID 142 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Procedures Table MATH AND LOGIC PROCEDURES TABLE Toconfigure the Math and Logic Procedures table 1 Choose Math and Logic Procedures from the Main Menu to display the Select a File dialog Select a File settempl 2 Either choose a program to edit or enter thename of a programto create In this example the program name SETTE MP was entered The system automati cally adds the PRG program extension 3 Click Enter The Math and Logic Procedure panel is displayed e f you entered a new program name the panel is blank e f you selected an existing program it is displayed in the panel D er 2 5 a m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 143 CONFIGURING MATH AND LOGIC Math and Logic Procedures Table Example T he program SETTEMP is shown in the panel below Math and Logic Procedure settemp prg loj x File Edit Exit Help PROC SETTEMP l BEGIN I
159. mum message length int fl tagname to id TAG function prototype Ob 2 35 missing from CML H TAG tags 2 MSG tagl tag2 char string buff MAX LEN 1 max length plus terminating O tagl m ptr tag2 m ptrestring buf tagl m max tag2 m max MAX LEN fl tagname to id tags 2 TAG1 TAG2 fl read Task id amp tags 0 1 amp tag1 strcat string buf X tag2 m lenestrien string buf fl write Task id amp tags 1 1 1 amp tag2 j cend END 170 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Calling C Code When values are assigned to MESSAGE tags the MAX LEN field is not transferred As a result all message values are truncated at 80 characters To store values longer than 80 characters into a MESSAGE tag thefundtionfl write must be called directly The following example shows how to use a C macroto call the procedure msgtest to store a 90 character constant into the ME SSAGE tag msgtag p MSGTEST PRG N cbegin void fl tagname to id TAG int jidefine assign msg tagname value TAG tag MSG msg char buf value fl tagname to id amp tag l tagname msg m ptr buf msg m len strlen buf msg m max strlen buf 100 leave plenty of room fl write Task id 8 amp tag l1 amp msg cend PROC msgtest BEGIN cbegin assign msg msgtag 712345678901234567890123456789012345678 9012345678901234567890123456789
160. n beprinted between files Control characters Codes that instruct a printer to perform an action Control characters have ASCII values from 00 through 1F hexadecimal To placea control character in a sequence enter a backslash followed by the two character hexaded mal value of the control character For example toincludea form feed command between files enter the command sequences as follows form feed has the ASCII hex value OC Initialization Sequence QC File Separator Sequence OC The backslash character itself can be entered as two backslashes Refer to the user manual for the appropriate printer for information about control characters and their hexadecimal values Valid Entry alphanumeric string of between 1 to 16 characters 108 FactoryLink ECS Core Tasks Configuration Guide PRINT SPOOLER Configuring the Print Spooler Binary On Binary Enter an alphanumericstri ng of between 1 to 16 characters that Off specifies for useonly with the Report Generator and File Manager not for use with the Alarm Supervisor command sequences sent to the printers to print binary files These command sequences can consist of two types of characters Display characters Printable ASCII characters such as A that can be printed between files Control characters Codes that instruc a printer to perform an action Control characters have ASCII values from 00 through 1F hexadecimal To place a control ch
161. n flow into and out of an application 120 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC OVERVIEW Procedures PROCEDURES Math and Logic executes procedures containing logically grouped and organized statements that have a singl e continuous thread of exeauti on or control flow between the decision points branches Typically you analyze the actions needed in the application and organize the operations needed for each action into one or more procedures At run time procedures can be either e Triggered in response to changes in the real time database e Executed directly from within another Math and Logic procedure One or more procedures are contained within an editable plai n text program file A program PRG filecan contain several separate procedures that may call or refer to one another D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 121 MATH AND LOGIC OVERVIEW Creating Programs CREATING PROGRAMS In order to use Math and Logic you must first create a program by configuring tables Configuration Tables UsetheM ath and Logic configuration tables to e Define variables used by a task e Identify the type of program either interpreted or compiled e Identify where the programs are stored e Identify when a program should be invoked The number of elements triggers and programs that can be defined is limited only by the amount of available memory
162. na au o e o2 c o EE 4 gt FactoryLink ECS Core Tasks Configuration Guide 57 PROGRAMMABLE COUNTERS Programmable Counters Information Panel Preset Value Enter a number between 32 768 and 32 767 tospecify the starting valuefor a count This numerical value is written to the Current Value element whenever the value of the Clear element is set to 1 ON The default is O Valid Entry numeric value between 32 768 and 32 767 default 0 Increment Value Enter anumber between 0 and 32 767 to specify the numerical value that is combined with the Current Value when the Up or Down Clock is triggered The default is 1 Valid Entry numericvaluebetween 0 and 32 767 default 1 Terminal Value Enter anumber between 32 768 and 32 767 todefinethe numerical value that spedfies a limit for counting activity When the Current Value is the sameas the Terminal Value counting stops and Positive and N egative Outputs are triggered Counting remains stopped until the Clear element is triggered H owever if AutoClear is set a Clear is performed immediately after the Positive and Negative Outputs are triggered Valid Entry numeric value between 32 768 and 32 767 Autoclear Indicator that a Clear should be performed each ti me the Terminal Value is reached This can be one of the foll owing YES Clear is performed each time the Terminal Value is reached This is the default NO Current Value remains equal to the Term
163. names el ement names variables and constants are all case sensiti ve in Math and Logicand must beunique However to avoid confusion and a possible error do not give any two procedures el ement names variables or constants the same name even if the case is different Remember in UNIX names must be lower case Be careful not to confuse the name of a procedure with the name of the program filein which the procedureis contai ned While procedure names are case sensiti ve the nameof the programfilein which the procedures are contained is not case sensitive At run time if a program file does not contain a procedure that fits these criteria no procedures in that file are triggered and the error message Proc procedure name does not exist is displayed on the Run Time Manager screen andin thelog file D 5 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 231 MATH AND LOGIC PROCEDURES AND FUNCTIONS Program Files Procedures A procedureis a sequential arrangement of statements that manipulate data items in a repeatablefashion al ways behaving the same way under the same circumstances and providing a well defined and logical flow of control through the procedure Define procedures using the following general form with no arguments PRO C name Procedure definition statement BEGIN Body of procedure dedarations and statements END Each procedure definition statement or pr
164. nce Save Information Jol x Edit View Utilities Exit Help Timed Save Trigger Cache Buffers Buffer Size Message Copy Size persist_trig 16 512 2048 Cancel Enter Exit eal In this example when the value of the element persist trig changes to 1 ON it triggers the Persistence task to write to disk the values of all el ements in the application configured as persistent by time The number of buffers set aside for theinternal cacheis 16 with 512 bytes per buffer A disk cacheis a way to compensate for the slowness of the disk drive in comparison to RAM memory The Persistence task s cache process speeds up computer operations by keeping data in memory Rather than writing each piece of data to be saved to the hard disk the task writes the data to its internal disk cache reserved memory area Then when the disk is not busy with other processing or when the cache process can perform several writes in an order that minimizes the movements of the disk s heads the cache process writes the saved data to the hard disk Themaximum length for message el ements during persistent saves is 2048 bytes When the value of the element persist backup changes to 1 it triggers Persistence to copy the current persistence save fileto a backup file FactoryLink ECS Core Tasks Configuration Guide 25 U D E e o D 3 Qo D PERSISTENCE Persistence Task Start Order PERSISTENCE TASK START ORDER This secti on des
165. nctions FactoryLink ECS Core Tasks Configuration Guide 185 D pus 2 5 2 e O MATH AND LOGIC SYNTAX Constants To store ASCII data including non printing ASCII characters as string constants enter the ASCII codein a call to the built in Math and Logicfunction chr which has thefollowing format chr xx where xx is the ASCII code to generatethe character For example chr 27 sets the string variable x to the escape character p X x lt ll chr 124 assigns to x the vertical bar symbol p N bM E a Refer to any chart of standard ASCII character codes to determine the proper ASCII value of any character The following examples illustrate the use of string constants Table 8 2 CHR 27 ESC character ABC n A B C new line NUL MENU M E N U NUL Am Double quotation mark NUL Use double quotes to include special characters inside quoted strings Refer to the system software documentati on supplied with that operating system for spedalized information about ASCII characters and the details of string handling under a particular operating system such as val ues of the machine s character set 186 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure STRUCTURE This section describes the ways the procedure tokens can be grouped together to form dedarations expres
166. nd Logic Reserved Keywords rnm 176 COMES iis cse bara aea b Re eR ac cn Ode t ena aie a cde a oe o x RU RR 179 Constants tc ars Mt aie Marche EET 181 Symbolic Constants l isses eese sees sess s 181 NumeaicConstants 0 cece enses s 182 StringConstants llllesee lesse sees s 184 Str ct le Lcixedxerkka Peed be ee eee EX iE vee lE Ex 187 Declarations x xac terme Face le t Ue aa cedo abe ExpressionS usus RI ll gu dbdome xr ku mu oro es cs 207 StatenentS ee eee nnn n n n n nn nn nns 220 Directives s sek ee kx R3 3k kk x x x kk Saas a css 228 9 Math and Logic Procedures and Functions 231 Program Files 2 520 isse xix iR eye Gk xkeiBerk da we dda ee lk 231 Procedures Lec CUE Re ae ho lo OA LO Arguments Pega i4 4maxsgusuminribiriceo 233 Running Programs as Interpreted Programs dando eds oc doo edens 235 Technical Notes 0 0 cee enn 236 e a eee ean aes 236 Local Procedures sale te dua aR oe AB OM ab Raed eee ene aaa LOO Library Functions Va RENTES Y Calling Functions that Operateon Tag IDs CML Only Dese 248 10 Compiled Math and Logic 20 00 cece ee ee ee es 251 System Configuration Panel Setup Under IML CML 253 6 FactoryLink ECS Core Tasks Configuration Guide Part VII 11 Core Tasks Configuration Guide MakefilesS eee osos E senes e e ect PR ee 254 EditingCML MAK 0 cc ccc et nns 254 TheCML Pro
167. ne if any D er 2 5 2 r e 7 5 Repeat Steps 2 and 3 until all errors are corrected FactoryLink ECS Core Tasks Configuration Guide 145 CONFIGURING MATH AND LOGIC Math and Logic Procedures Table You can clear the red lines from the screen at any time by choosing Clear Err from theF ile menu However you cannot display error help Configuration Examples Using Element Arrays This section shows sample Math and Logic configuration panels for an application that contains el ement arrays A sample Math and Logic Variables Information panel is displayed ut Math and Logic Variables Information BEE Edit View Utilities Exit Help Tag Name Tag Type Tag Description E lastcar ANALOG Number of cars worked today cars 0 ANALOG Autos manufactured errors 0 0 DIGITAL 10 possible errors for 100 cars E Cancel Enter Exit K Z The cars array stores color information about the colors of cars produced during the current run with 1 indicating a whitecar 3 a red car and so forth the errors array contains zeroes in thefirst column unless a probl em occurs in paintinga car Notice the array subscripts are defined to index from zero so arrays containing 100 elements actually contain elements 0 to 99 The trigger element midnight causes the exeaution of the PRINTRE D procedure as defined in the sample M ath and Logic Triggers I nformation panel us Math and Logic Triggers Info
168. nel Setup Under IML CML 253 EditingCML MAK sess ee nn nnns 254 Generation of CML Executables sse RII 257 Core Tasks Configuration Guide FactoryLink ECS Core Tasks Configuration Guide 117 Math and Logic 118 FactoryLink ECS Core Tasks Configuration Guide Chapter6 Math and Logic Overvi ew TheFactoryLink Math and Logictask coordinates interactions among many of the FactoryLink tasks Thesefeatures indude e Uses a structured BASIC likesyntax e Exeautes in the background with no operator intervention at run time e Supports both interpreted and compiled Math and Logic IML and CML e Supports block structures ooping constructs and callabl e mathematical functions e Supports automatic conversion of data types e Supports multi dimensional arrays D er 2 5 2 m fo FactoryLink ECS Core Tasks Configuration Guide 119 MATH AND LOGIC OVERVIEW Uses USES Math and Logicis called from other applications to perform functions such as Manipulate real time database elements and local variables Batch control Performing computational calcul ations Comparing logically two values stored in database elements Settingthe value of an element to a value chosen by an end user at run time Controlling the system activity resulting from end user interaction with on screen buttons Validating end user input Controlling screen changes Controlli ng informatio
169. nformation 7 Ifyou areconfiguring CML torun in both domains return to Step 1 and repeat this procedure for the other domain 152 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Running CML RUNNING CML CML compiles and runs on both devel opment systems and run time systems Running CML ona Development System Torun CML on a development system start the application by typing FLRUN at the system prompt Windows users must open the command line from the Program Manager using the Run option on the File menu Before starting the Run Time Manager FLRUN invokes several utilities to compile programs intoa single executable the CML task onetask per domain The compiled programs will have COMPILED entered in the Mode field of the Math and Logic Triggers Information panel Running CML ona Run Time Only System Torun CML on a run time only system you must transfer the CML executables from the development system to the run time system H ow you do this depends on whether the development and run time systems run on the same operating system If the operating system for the development and run time system is the same perform the following steps torun CML ona run time only system 1 Use either of the following two methods to transfer the CML executables to the run time system e Use the FLSAVE and FLREST utilities to perform a platform specific save and restore of the application from the development sys
170. nitiates the count upward Down Clock initiates the count downward Clear resets the counted valueto the starting point Positive Output contains the value 1 on when the counting limit has been reached Negative Output contains the value 0 off when the counting limit has been reached Current Value indicates the current value of the count Digital and Analog Values e Preset Value analog value that specifies the starting value Increment Value analog value that specifies the amount by which the count is to increase or decrease each ti me Terminal Value analog valuethat spedfies the counting li mit e AutoClear digital value that resets the count to the starting poi nt whenever the terminal value is reached Counting begins when another F actoryLink task such as Math and Logic or EDI writes a 1 ON tothe Up Clock element This triggers the Programmable Counters task to move the Current Value toward the Terminal Value by the Increment Value If the Preset Valueis less than the Terminal Value the Increment is added to the Current Value If the Preset Valueis more than the Terminal Value the Increment is subtracted from the Current Value 52 FactoryLink ECS Core Tasks Configuration Guide PROGRAMMABLE COUNTERS Principles of Operation Example One Inthis example counting is triggered to count bottles 20 per case The Preset Value start count is 0 and the Terminal Value count li
171. o for success Sets new Example status setdir test Current directory Therefore status 0 if current directory successfully set to test Programming Routines The chart below lists programming routines alphabetically 244 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes TRACE is not supported in the compiled mode of M ath and Logic Table 9 7 Programming Routines EXIT status Exit the program and set the program return status CALL procname p1 Call a procedure Thekeyword CALL is not required Refer to Procedure Calls on page 226in Chapter 8 Math and Logic Syntax INPUT string prompt var1 var2 Accept input from keyboard Thefirst field entered is placed in var1 The first comma entered begins second field which is placed in the var2 and Soon LOCK Lock the database No other task can access the database whileit is locked A LOCK statement delimits a block of code to be executed in critical mode that is without interference from other FactoryL ink tasks running on the system For each LOCK statement there MUST bean UNLOCK statement UNLOCK Unlock the database allowing other tasks to access it Must be issued for every LOCK If time consuming codeis included between LOCK and UNLOCK statements performance may be affected becauseno other tasks can access the database whileit remains locked PRINT R
172. oc statement starts with the word PROC followed by theunique name of the procedure followed by any arguments parameters the procedure requires Any procedure except the main procedure for thefile can have arguments Place the keyword BEGIN on the next line For example PROC name type namel type name2 UN BEGIN END NC zt where type is SHORT LONG FLOAT or STRING name1 isthename of a variable or constant or a database element tag name name2 isthenameof a variable or constant or a database element tag name other than namel Math and Logic does not provide return codes for developer defined procedures Therefore the task cannot set a variable s value to the return code froma procedure call 232 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Program Files Do not confuse procedure definitions with procedure ded arations which are forward references to procedures defined later in the samefileor in a different file Arguments Arguments Arguments are values passed to a procedure for it to use in its computations arguments areinput onl y parameters Declare arguments by pladngtheir types and names in the procedure definition statement as shown in the example above Local and global variabl e names and tag names can be used The data type of the argument is the same as that of the original variable or database element SHORT LONG FLOAT STRING Math
173. ocedure you must specify a procedure call using one of the following interchangeable forms S ACALL proc name typel argl type2 arg2 or CALL proc_name typel argl type2 arg2 N where the keyword CALL is optional 234 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Running Programs as Interpreted Programs RuNNING PROGRAMS AS INTERPRETED PROGRAMS Torun as interpreted those programs that have Interpreted entered in the Mode field of the Math and Logic Triggers Information panel start the application by typing the FL RUN command at the system prompt Math and L ogic begins executing interpreted programs by loading them into memory After loading and validating the programs Math and Logic waits for changes to thetrigger elements in the real time database associated with the procedures in the program When a trigger element is set to 1 ON the task executes the program associ ated with that trigger Each timean interpreted program is executed M ath and Logic first reads or interprets the instructions within the program to determinethe actions to perform then it executes those actions D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 235 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes TECHNICAL NOTES Calling Procedures and Functions Twotypes of routines can be called from within an expressi
174. ocedures must first be defined in the Math and Logic Variables tabl e Because many Math and Logic procedures can access them these elements are gl obal in scope Remember global elements are not the same as global variables which are declared inside program files and are used only within procedures When a procedure is triggered by an element the name of this element must be entered in the Math and Logic Triggers table sothe procedure will load and run Completing the Tables Complete the configuration tables in the following order e Math and Logic Variables table e Math and Logic Triggers table e Math and Logic Procedures table Converting Previous Versions Previous versions of Math and Logic operated in the IML mode only Run the FLCONV utility to convert previous versions to the new one Opening the Configuration Manager Main Menu Refer to F actoryLink Fundamentals for information on how to open the Configuration Manager Main M enu screen D er 2 5 2 e O FactoryLink ECS Core Tasks Configuration Guide 123 MATH AND LOGIC OVERVIEW Modes MODES Math and Logicruns in one of two modes e Interpreted mode e Compiled mode Interpreted Mode Interpreted mode is a subset of Compiled Math and Logic IML means when the values of trigger elements associated with one or more procedures change in the real ti me database IML determines which procedures are affected Math and Logic then interprets ev
175. oler Table 5 2 Continued Sample Print Spooler Information Panel Fed Sample Entry Explanation Status TAG devicel status Is an analog element containing the status of the printing device Other tasks can read thevalue of devicel status to determine whether the printer is busy beforethey send output toit Message devicel msg Is a message element containi ng a message TAG aboutthe status of theprinting device This message is displayed on a graphics screen because you al so configured an output text object in the Application Editor to contain the value of this el ement U eu 3 w xe o 2 D FactoryLink ECS Core Tasks Configuration Guide 111 PRINT SPOOLER Configuring the Print Spooler 112 FactoryLink ECS Core Tasks Configuration Guide Part VI Math and Logic Y Table of Contents Math and Logic 6 Math and Logic Overview i c0 Do rr RR RE 119 USES e deaa ae o EE a N E OE E AA a Aa 120 PrOCEQ TES aiani ia padda a aR cod iG dieu a OE A a D A a a ee 121 Creating Programs ssssseslees n 122 Configuration Tables is sess eeee ee ee ee ees 122 Modes cider px ERR eae p ke o RC e e E RR ERR e 124 Interpreted Mode sux god to E ORC o bul Ru KR ee tee sd bad Switching from ML to CML veda dexded squad ux RES Sede eee 2d Compiled Mode WINNER EET CML Operation c esse I6 Triggering Calling 06 ccc III 128 Triggering on
176. omain selected is the correct one in the Configuration Manager Domain Selection box Choose F ile Manager to display theF ile Manager Control and File Manager Information panels Complete the File Manager Control panel first u File Manager Control ojx Edit View Utilities Exit Help Table Name Command Position Command Source Trigger Trigger File Spe La Enter L Exit Next Prev Following are field descri ptions for this panal Table Name Required for TYPE and DIR operations Enter an al phanumeric string of between 1to 16 characters that specifies the name of the operation bei ng defined or modified For TYPE and DIR operations this field connects the entry in theFile Manager Control panel with the associated File M anager Information panel for that entry This field is optional for COPY REN DEL and PRINT operations Y ou can use itto distinguish different operations of thesametype Valid Entry alphanumericstring of between 1 to 16 characters 66 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER File Manager Control Panel Command Trigger Nameof an element used to initiate the file operation If the tag spedfied in this field is not already defined a Tag Definition dialog is displ ayed when you dick on Enter Valid Entry standard element tag name Valid Data Type digital analog longana float message Position Trigger Required only for DIR and TYPE operations not used for
177. on e Developer defined local procedures Library functions Local Procedures Calls to local procedures with or without arguments are normally made using one of the forms in the chart bel ow Table 9 1 Syntax Purpose f arg1 To pass argl f arg1 arg2 To pass argl and arg2 Procedure names can be up to 16 characters must conform tothe naming rules for variables and can befoll owed by a set of parentheses containing the functi on s input parameters arguments if any arerequired To be compatible with all operating systems the main procedurefor each PRG file should havea name of up to8 characters 236 FactoryLink ECS Core Tasks Configuration Guide Library Functions MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes A number of specialized procedures known as functions are predefined by or built into Math and Logic Functions built into Math and Logic are known as library functions Expressions can indude calls to library functions Thelibrary functions supplied with Math and Logic are grouped into five categories Mathematical Directory Path Control e String Manipulation e Programming Routines e Miscellaneous Routines The functions within each category are described in the following sections Included in each functi on s description is a sample format of the function and an example of its use Functions can vary among different operating systems Refer to your operating system s docum
178. on needed by the CCCML utility to compilethe C files produced by PARSECML and create an executable for the current domain The name of the makefile used by CCCML is CML MAK andis unique for each operating system The CML MAK file located inthe FLINK CML directory contains the following information to create the final executable file e Nameof the C compiler to use for a given operating system e Command line switches to be used when compiling e Nameof the operating system s object linker e Linker command line switches e References to the FactoryLink libraries to be linked e References to the devel oper suppli ed libraries to be linked Editing CML MAK As an aid for advanced users CML provides a method for editingthe CML MAK file You can changethe compiler and linker options specify command line switches and specify which object files and libraries to link giving you the flexibility to create a makefile unique to an application for a given domain CML provides two options on the Main Menu for editing CML MAK Math and Logic System Makefile Math and Logic Domain Makefile Math and Logic System Makefile Any changes made to this file are global they apply toall applications on the system To edit CML MAK 1 Choose Math and Logic System Makefile from the Main Menu to display a text editor containing the CML MAK file from the FLINK CML directory 2 Edit the file as required 3 Saveand exit the file 254 FactoryLink
179. ontents using a hex editor DOS debug Thetags bin files contain a listing of the tag segment and offset in theFactoryLink RTDB FacoryLink typein integer format and the dimension of array if thetagis an array CML references this information at run time by lookingthis information up and not havingto calculate it This reduces the CML overhead and makes for a very efficient process e The pure C code that lies between the CBE GIN CEND keywords will not be parsed It will be translated directl y tothe generated C file The location in thefile will be preserved f The parsecml executable can be run from the command line This is an excell ent debug tool to assure yourself that the associated PRG files have the correct syntax If the FLAPP environment variable is set you may execute parsecml with no arguments If you want control in executing parsecml you can call it with the following arguments 258 FactoryLink ECS Core Tasks Configuration Guide COMPILED MATH AND LOGIC Generation of CML Executables parsecml V 1 5 Nuser C Syntax of arguments V 1 5 This specifies the verboselevel built intothe parsed C code that FL produces The different levels do the following Usage V2 or V5 etc Verbose L evel Action 1 prints out filenames as they are parsed 2 prints out funcs proc names as they are parsed 3 places printf s in each function to show entry and exit of that function 4 places printf s in
180. operati ng system and or compiler in compiled mode onl y Refer tothe documentation supplied for compiler information Y ou must configure three tables to create a program e Math and Logic Variables table Defines elements M ath and Logic reads or writes An element must be defi ned before it can be used in a procedure or it will be consi dered an undefined variable and will not validate Define each element referenced by the procedures in a program file by entering its tag name inthis table This tablehas one panel Math and L ogic Variables Information Math and Logic Triggers table Defines the elements used totrigger the Math and Logic procedures to run For each trigger element defined enter the associated procedure the trigger element is responsible for triggering and the method of execution interpreted or compiled This table has one panel Math and Logic Triggers Information e Math and Logic Procedure table Writes the Math and Logic procedures required by the application Each program file must be named exactly as it is named in the Math and Logic Triggers nformation panel but with a PRG extension After writing a procedure and saving it to a program file name edit itin this panel This table is a text entry panel Math and Logic Procedure filevameprg 122 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC OVERVIEW Creating Programs Trigger Elements Trigger elements used in Math and L ogic pr
181. ors assign a value toa variable Refer to the discussion of assignment statements in Assignment Statements on page 221 216 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Operator Precedence Most high level languages use relati ve operator precedence and associativity to determinethe order in which procedures perform operations If one operator has higher precedence than another the procedure executes it before the other If two operators have the same precedence the procedure eval uates them according totheir assodativity which is either left to right or right to left and is always the samefor such operators Because parentheses are operators with very high precedence they can be used to alter the evaluation order of other operators in an expression The Math and Logic operators are di vi ded into ten categories in the following chart of operator precedence The Change status category has the highest precedence the Grouping category takes second precedence and so on to the Assignment category which has the lowest precedence The operators within each category have equal precedence TheUnary third category operators associate from right toleft all other operators associate from left toright Table 8 17 Precedence T 1 is highest Category Operator Description 1 Change status 7 Checks changestatus of database elements Grouping Grouping or function call Array subscript Un
182. otes TECHNICAL NOTES Toenablea local node to perform file management operations with a remote node at run time theFLFM SERVER task must berunning in the SHARE D domain on the node that does not initiate the FLFM command Either start the FLFM SERVER task manually from the Run Ti me Manager screen at startup or configure F actoryLink tostart the FLFM SERVER task automatically at system startup Complete the following steps todo this 1 Open the System Configuration Information panel in the SHARED domain from the Main Menu on the remote node ay o o gt o Q D Locate the row containing theentry FLFM SERVER in the Task field Place thecursor over FLFM SERVER Tab totheFlags field a Ff o N Enter an R in the Flags field This configurestheFLFM SERVER task on the remote node to start up automatically whenever F actoryL ink is started FactoryLink ECS Core Tasks Configuration Guide 93 FILE MANAGER Operating System Notes OPERATING SYSTEM NOTES For Windows NT and Windows 95 Users Configuring File Manager Source File Spec 5 5 andDestination File Spec 5 7 Table 4 14 DRIVE DIR SUBDIR For C LOG HISTORY FILE EXT stand alone HISTORY ARC systems STATION DRIVE A For NODE 1 CA HIST PI CV DIR SUBDIR FILE EXT networked SCREENILPIC systems Using Wildcard Characters in File Specifications 5 17 Format path names as follows Do not specify a filename for
183. otethat the deadbanding portion of the functi on cannot be implemented without configuring the scaling portion of the function Refer to the Application Editor Guidefor more information on how the Scaling and Deadbanding feature works in the Application Editor FactoryLink ECS Core Tasks Configuration Guide 273 SCALING amp DEADBANDING Principles of Operation PRINCIPLES OF OPERATION Scalingis only available in the SHARED domain Thescaling function only applies for tags with an analog longana or float data type Scaling is configured using a pair of ranges one for raw values and one for scaled values These ranges can be specified as constants or tags If oneor more of the rangetags is changed thescaling formula is adjusted accordingl y If Scaling and Deadbanding is configured from the Application Editor the system automatically assigns default tag names for raw and scaled values even if entered as a constant deadbanding and scaling lock functions However if Scaling and Deadbanding is configured from within the Configuration Manager only thosetags speci fied by the designer are created When a valueis written to a raw value tag its related scaled valuetag is updated accordingly When a value is written to a scaled value tag its raw value tag is updated accordingly The former is called a raw to scaled conversion Thelatter is called a scaled to raw conversion Prior to changing a range tag raw value tag or scale
184. ow and line row line Send each listed print parameter variable to the display converting to ASCII if necessary D pun 5 2 2 2 m fo 2 O FactoryLink ECS Core Tasks Configuration Guide 245 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 7 Programming Routines Continued TRACE expr While expr remains true each line TRACE will not besupported in future assignment and the procedure s exit add on products point are printed as they run Miscellaneous Routines Table 9 8 Miscellaneous Routines argent Example Therefore X argcnt X argcnt x 3 if thenumber of program arguments is 3 Returns the number of program arguments getarg Example x getarg argnbr x getarg 2 x TEST if the second argument is the directory name which is TEST Returns the spedfi ed program argument system Example Result X system system command x system copy CA autoexec bat bA bat 0OS 2 system call x 0 if the copy request was successful Allows system calls The command is formatted as a string Returns success 0 of failure 1 of operation The return code from the operating system is placed in the variable represented hereby xto check whether the requested system command was completed without errors If therewere noerrors thefunction returns 0 otherwise at least one error on the req
185. pecifiers in File Specificatio ONS aici i dak adeste ee oe ea 85 Using Wildcard Characters in File Specifications 87 Using the File Manager with Networks 0 0 00 e cee eee aes 88 Usingthe COPY Command with FLLAN eres 89 Usingthe COPY Command with a Network without FLLAN TERTIO 92 Technical Notes s s s ssa sanaan eee teen tenet eee nea 93 Operating System NOteS 0 cece eee 94 For Windows NT and Windows 95 Uses 0 cc eee eee For OS 2 U Sere uui iis ete sie hee Aid ot ae Note HERS ACE ae ab es iioii Fo UTnbCU Sets x utis Gusto ome rte E ee eee ae eee 96 98 Y FactoryLink ECS Core Tasks Configuration Guide 63 File Manager 64 FactoryLink ECS Core Tasks Configuration Guide Chapter4 File Manager n TheFactoryLink File Manager task can be used to perform basi c operating E system fil e management operations initiated by a FactoryL ink application at run Ez time Thetask can work in conjunction with FactoryLink s FLLAN option to 5 initiate operations within other FactoryLink stations on a network The File e Manager initiates the operations listed below which are performed by the o operating system z e Copy afile Renamea file e Deleteafile e Printa file e Display a directory e Typea file File Manager initiates these operations with six commands COPY REN DEL PRINT DIR and TYPE These commands perform the same functions as their opera
186. phics screen To di splay the status of a printing device on a graphics screen configure an output text object in the Application Editor to contain the value of this element If you specify more than one device be sure to distinguish between devices when assigning element names If the tag specified in this field is not already defined a Tag Definition dialog is displayed when you click on Enter with a tag type of message in the Type field Accept this default CAUTION All Print Spooler job requests are routed through the F LAP P SP OOL directory If all such requests are not effecti vel y transferred for instance if the printer is off line this directory can get backlogged To ensure effective processing chec the di rectory periodi cally and delete any obsolete job requests When you have completed the panel it resembles the sampl e panel shown in the Valid Entry standard element tag name following table Table 5 2 Sample Print Spooler Information Panel ELM Sample Entry Explanation Device dev tty1 Indicates a printer on a UNIX system File 0C Is a command sequence consisting of Separator control characters The OC control Sequence characters instruct printing device dev tty1 toinsert a formfeed after each file it prints This ensures that each file printed begins on a new page 110 FactoryLink ECS Core Tasks Configuration Guide PRINT SPOOLER Configuring the Print Spo
187. puted desti nation specification is as follows NOD2 C NFLINKNRECIPE Completion copydone When the COPY operation is compl ete File Trigger Manager forces the value of this element to 1 ON This element can be used by another F actoryLink task or to trigger another File Manager operation 90 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Using the File Manager with Networks Table 4 13 Continued Sample File Manager Control Panel Sample 2m Completion copystat When the COPY operation is complete File Status Manager writes the status information to this analog element a o o gt o Q D Refer to F actoryLink Fundamentals for details for information about variable specifiers FactoryLink ECS Core Tasks Configuration Guide 91 FILE MANAGER Using the File Manager with Networks Using the COPY Command with a Network without FLLAN When spedifying a COPY command for networks without FLLAN do not specify a station namein the Source Format and Destination Format fields nstead specify a network device which is any logical device on a remote computer used as if it were alocal device Different operating systems reference network devices in different ways To find the proper syntax for referencing these devices consult the user s manual for the appropriate operating system 92 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Technical N
188. r a variable array is limited to 32K Declare array dimensions that do not exceed this limit Notetheselimitations when planningapplication data design in other words any global or local variables which must be larger than 64K to servethe needs of the application designer should be partitioned logically during design so no data item as declared exceeds 64K Contact Customer Support for suggestions on workarounds such as declaring several linked data items if large buffers are needed in an application 200 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure For UNIX The size of global and local data declared is limited only by the amount of availabl e memory availableto thetask running under UNIX However if the application is to be ported back down to a segmented architecture such as OS 2 the 64K barrier presents a limitation on the size of some variable data in ML In procedures to be ported later to an OS 2 system global and local variable arrays or data items such as strings or message buffer data which tend to become large should be partitioned so no data item as declared exceeds 64K Also notethat the index sizing value for a variable array under OS7 is limited to 32K 32 767 if software is to be portable array dimensions must be declared so as not to exceed this limit Thelimit under UNIX is normally 64K 65 534 depending on the amount of free memory allocated to the run ti me process
189. r you arerunning Interpreted or Compiled Math and Logic e For Interpreted Math and Logic declare global procedure variables before the first procedure definition in a program file For purposes of validation dedare global variables in each program filein which they areused After thefirst invocation they retain their values across procedure calls The following model shows where you declare global and local variables d 1H comments N Global DECLARE d comments Variables DECLARE J comments PROC name BEGIN Local DECLARE Variables DECLARE A A t 1 A B 1 END e For Compiled Math and Logic you can declare global procedure variables in either of two ways e Beforethe first procedure definition in a program file as in Interpreted e Inanindudefile An include file contains all of the global variables and procedures that woul d otherwise be declared at the top of each program file that referenced them Create and edit an include file using any text editor as in the following example M DECLARE PROC testproc N DECLARE SHORT vall DECLARE FLOAT val2 Ses D pus 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 193 MATH AND LOGIC SYNTAX Structure Save the file with an INC extension Include files must have an N C extension so the system can open and save them during an FLSAVE Include files are located in the PROCS directory of the cu
190. rates Math and Logic Domain Makefile The first time you choose Math and Logic Domain Makefile from the Main Menu an empty text editor is displayed because a domain spedfi c makefile does not exist Y ou can createoneusing the master makefile CML MAK in the FLINK CML directory as a model To create a domain specific makefile 1 Copy CML MAK fromthe FLINK CML directory to either e FLAPP USER CML directory for the user domain e FLAPP SHARED CML directory for the shared domain 2 OpentheMain Menu and ensurethe current domain selected in the Configuration Manager Selection box matches the domain of the makefile you are creati ng 3 Choose Math and Logic Domain Makefile from the Main Menu to display a text editor containing the domain specific makefile CML MAK copied in Step 1 4 Editthefileas required Any definitions in the domain spedfic makefile in the application directory overri de the definitions in the master makefilein FLINK CML directory 5 Saveand exit the file 160 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Advanced Concepts for CML ADVANCED CONCEPTS FOR CML Utilities and Commands CTGEN and GENDEF CTGEN and GENDEF will run normally as part of F LRUN but if you are debugging and need to run the items separately you should always run CTGEN and GENDEF beforerunning MKCML MKCML Utilities TheMKCML utility coordinates the creation of the CML executables It has three fund
191. ration does not require completion of the File Manager Information panel you can leavethis field blank However we recommend you fill in this field to distinguish different operations of the same type Command copytrig Name of the digital element that tri ggers Trigger the copy operation Y ou can configureother tasks towritetothis element totrigger the copy operation Command COPY Designates a COPY operation 76 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Sample File Manager Operations Table 4 2 Continued Sample File Manager Control Panel Sample E Source C history The path and file name of the file to be File Spec hist 03d copied In this example the source path name contains a variable specifier At run time whenever the operator or another task triggers the digital element copytrig File Manager replaces this variable with the value of the analog element fx1 ext a o o gt o Q D Source fx1_ext At run time File Manager replaces the Variable 1 variable 03d in the Source File Spec field with the value of this analog element In this example this value is a three number file extension such as 001 Destination aXarchive The path name where the source file is to File Spec be copied Becausethis entry contains a static specifier Destination Variables are not necessary Completion copydone When the COP Y operation has been Trigg
192. rected e the operation of a Software Program will not be interrupted for short periods of time by reason of a defect therein or by reason of fault on the part of USDATA or f the Software Programs will achieve the results desired by the user or any third person U S GOVERNMENT RESTRICTED RIGHTS The Software is provided with RESTRICTED RIGHTS Use duplication or disclosure by the government of the United States is subject to restrictions as set forth in subparagraph c 1 ii of The Rights in Technical Data and Computer Software clause at DFARS 252 227 7013 or in subparagraphs c 1 and 2 of the Commercial Computer Software Restricted Rights clause at 48 CFR 52 227 19 as applicable Contractor Manufacturer is United States Data Corporation 2435 North Central Expressway Suite 100 Richardson TX 75080 2722 To the extent Customer transfers Software to any federal state or local government agency Customer shall take all acts necessary to protect the rights of USDATA in Software including without limitation all acts described in the regulations referenced above The Software Programs are furnished under a software license or other software agreement and may be used or copied only in accordance with the terms of the applicable agreement It is against the law to copy the software on any medium except as specifically allowed in the applicable agreement No part of this manual may be reproduced or transmitted in any form or by any means elec
193. rmation _ ol x Edit View Utilities Exit Help a Trigger Tag Procedure Mode Description PRINTRED COMPILED Trigger for the PRINTRED procedure a Cancel Enter Exit IST A 146 FactoryLink ECS Core Tasks Configuration Guide CONFIGURING MATH AND LOGIC Math and Logic Procedures Table A sample Math and Logic Procedures panel containing the procedure PRINTRED is displayed Math and Logic Procedure printred prg Bl xj File Edit Exit Help PROC PRINTRED l BEGIN Uses element arrays cars 100 errors 10 100 Remember that these arrays are indexed from 0 Declare local variables DECLARE short r Number of red cars today Body of procedure begins here r 0 Initially no red cars IF lastcar gt 99 THEN We would index out of cars LASTCARD 99 Stay within array range PRINT More than 99 cars skipped some n ENDIF User has been notified WHILE r lt lastcar IF cars r 3 THEN Color no 3 is red PRINT tAuto no r is red n ELSE IF errors 1 r THEN Bad paint flag is on PRINT tBad paint on auto no r ll n ENDIF Bad paint test ENDIF Car not red Terl Look at next car WEND While r loop END PRINTRED gt Thesample procedure PRI NTRED displayed in the panel above is a procedure to print informati on about red cars PRIN TRE D is executed when the value of the digital element midnight defined in the Math
194. rrent domain and qurrent application For example the above indude file is saved to the following path FLAPP FLDOMAIN PROCS MY PROG INC where MYPROG INC is a developer defined file name U se the keyword indudeto dedare theinclude file with any program file to be run in the compiled mode The syntax is include MYPROG INC The keyword include instructs Math and Logic to read the contents of the include file and include it as part of the current program file Include files can be nested to a depth of 64 files to protect you from recursive includes The following example shows how to use an include file Procedures p1 and testproc without an include file Pr ocedure pl DECLARE PROC testproc DECLARE SHORT vall DECLARE FLOAT val2 PROC pl BEGIN CALL testproc END Procedure testproc DECLARE SHORT vall DECLARE FLOAT val2 PROC testproc BEGIN vall 0 val2 0 0 END 194 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Procedures p1 and testproc with an include file Include file test inc s DECLARE PROC testproc DECLARE SHORT vall DECLARE FLOAT val2 J Procedure p1 Procedure testproc ON include test inc include test inc PROC pl PROC testproc BEGIN BEGIN CALL testproc val1 0 END val2 0 0 END J Constraints on using variables Variables declared inside a procedure must have different names from variab
195. rsion 5 10 Copyright C Microsoft Corp 1984 1990 All rights reserved BJ NOE ST 16384 5E 512 test BJ syscp ject Modules bject Modules bject Modules cfunk ject Modules BJ cbwtags Cy e 0 OS E co bject Modules BJ glvars 0BJ CMLPROCO Run File test exe D CMLDOC ZIP FLAPP user cml cuser exe List File NUL MAP cml map Libraries LIB D FLOS2431 1ib flib lib Libraries LIB D NFLOS2431M ibNeml lib Definitions File L NUL DEF D FLOS2431 cm1 cm1 def S2 Au 0d Zp G2s nologo c ID FLOS2431 inc CMLPROCO c Linking link Gcml lnk Executing D FLOS2431 bin ctgen exe diml ctg AD CMLDOC ZIP FLAPP V Oo O O O Or C N ee bject Modules Switching to domain user Updating Compiled Math and Logic Task for Domain user Executing D FLOS2431 bin parsecml exe AD CMLDOC ZIP FLAPP nuser y2 OG Executing D FLOS2431 bin cccml exe AD CMLDOC ZIP FLAPP nuser v2 C The execution of flrun will call the utility mkcml for you We recommend running mkcml before running flrun In this way all errors are clearly seen and the application does not start up until you are sure that all Math and Logicis syntactically correct 268 FactoryLink ECS Core Tasks Configuration Guide Part VII Scaling amp Deadbanding Scaling amp Deadbanding Table of Contents Scaling amp Deadbanding 272 FactoryLink ECS Core Tas
196. rval Timer Task Mins Refer to the discussion of Hours Mins and Secs that follows Hours Mins Secs Hours Mins minutes and Secs seconds fields define the specific time in 24 hour format at which an event is to occur The event timer assumes a default val ue of 0 for blank fields The conventions for use are Hours Hour the event is to occur 0 to 23 Mins Number of minutes 0 to 59 after the hour the event is to occur If the event is to occur on the hour leave this field blank Secs Number of seconds 0 to 59 after the minute or hour the event is to occur Between mi dni ght 00 00 00 and theti me indicated in the Hours Mins and Secs fields thevalueof the element to which an event is linked is O OFF After the timed event occurs the element s value changes to 1 ON and stays this way until midnight when it changes back toO OFF Hours 0 23 0is midnight and 23is 11 00 pm Mins 0 59 Secs 0 59 First Valuethat determines the action taken upon system startup if startup occurs after a timed event Becausethis field only affects events scheduled for the current date the system checks the date before changing any values Yes Theelement s value immediately changes to 1 ON indicating thetimed event has ocaurred for that date The changestatus flags arealso set to 1 ON No Default the element s valueis left as is and does not changeto 1 ON until the next occurrence of the timed event
197. s for exampl e Monday at 8 00 am They are configured in the E vent Ti mer Table e Timeintervals occur at least once every twenty four hours at regular intervals of the system clock for example every 60 seconds They are configured in the Interval Ti mer Table The Event and Interval Timer task links ti med events and intervals to real time database el ements used as triggers whenever the event or interval occurs It is defined in the SHARE D domain The use of Event and Interval timers requires an understanding of change status flags Refer to the F actoryLink Fundamentals manual for this discussion There is no limit except the amount of available memory to the number of event and interval timers that can be defined m lt 3 e Q 3 i E lt m FactoryLink ECS Core Tasks Configuration Guide 37 EVENT AND INTERVAL TIMER Principles of Operation PRINCIPLES OF OPERATION The Event and Interval Timer task operates in synchronization with the system dock For each defined interval or event you must create a digital element in the real ti me database When the system dock matches the specified event or interval the task forces the value of this digital element to 1 ON The Event and Interval Timer task also updates global information used by FactoryL ink such as the current ti me the day of the week and the month Such global information is stored in predefined FactoryL ink real time database
198. s an integer the decimal porti on of the floating point constant is truncated before the assignment Example 3 Appending numerics to messages Let pressure be an analog element with the value 99 string1l is a message element The statement stringl RPT pressure results in string1 having the value RPT 99 pressure is converted to a string and then concatenated to the string constant RPT The result RPT 99 is then assi gned to stringl The compiled mode of Math and Logic does not support appending numerics to messages Example 4 E quatinga floating point element to the contents of message data Let messagel be a message element set to 1e308 representing the number 10 raised to the power 308 a large floating point constant stated in string form Assume you set message defined the same way as messagel to a value of 1e 308 representi ng the very small floating point constant 10 raised to the power 308 206 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Let float1 bea floating point element that recei ves the total of these two message elements The statement floatl messagel message2 which should add thetwo values instead results in float1 receiving an undefi ned value represented in the system as 1 4 NF is not float or something similar leading to an unpredictable result T his happens because the system performs string concatenation the operator acts
199. s down the system as soon as it comes up Note that theR Run flag for each task in the System Configuration Information panel supersedes the value of the digital start trigger associated with a task Examples Thefollowing examples show the relationship between the R flagin the System Configuration Information panel and the restored value of a digital element Example 1 TheR flagis NOT set for task A and the digital start trigger assodated with task A is defined as persistent by Exception al ways updated with Force Change Status ON if e Task A is running when the system is shut down then the value of thetask s digital start trigger is 1 When a warm start is performed the system restarts task A becausethe value of the digital start trigger is restored to 1 e Task A is not running when the system is shut down then the value of the task s digital start trigger is 0 When a warm start is performed the system does not restart task A because the value of the digital start trigger is restored toO FactoryLink ECS Core Tasks Configuration Guide 27 e PERSISTENCE Persistence and Digital Elements Example 2 The R flag IS set for task A and the digital start trigger associated with task A is defined to be persistent by Exception al ways updated with Force Change Status ON if e Task A is running when the system is shut down then the value of the task s digital start trigger is 1 When a warm start is performed the
200. s the associated procedure s PRG fileinto memory at startup Each time the Interpreted procedure is executed the task interprets the procedure sinstructions and then performs the actions requi red Compiled Theoriginal PRG file remains unaltered The C fileis then compiled and linked with FactoryLink and developer suppli ed libraries to createthe Compiled M ath and Logic run time task The words Interpreted and Compiled can bein all upper case all 7 lower case or initial caps Description Enter an alphanumericstring of between 1 to 80 characters that describes the intended use of the element specified in the Trigger Tag field Valid Entry alphanumeric string of between 1 to 80 characters 3 When you have entered all the information for this panel click Enter to savethe data If you have entered the name of any tags not already defined the Tag Definition dialogis displayed D er D 5 2 m fo m 7 FactoryLink ECS Core Tasks Configuration Guide 141 CONFIGURING MATH AND LOGIC Math and Logic Triggers Table 4 Enter data for any tags that display in the Tag Definition dialog Refer tothefield description where the tag nameis defined for details on valid tag types When all information is specified the panel resembles the following example u Math and Logic Triggers Information BEE Edit View Utilities Exit Help E Trigger Tag Procedure Mode Description SECI SETTEMP INTERPRETED Proc to raise and
201. s the string toindude onl y the first 79 characters 184 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Constants You can assign string constants to message type elements or string type local variables Math and Logic supports operator input in both interpreted and compiled modes In string constants the si ngle backslash V character introduces print formatting characters Print formatting characters are shown on thefollowing page The Math and Logic parser recognizes the single backslash as a signal that a print format character that is an escape code follows Therefore the string causes a parsing error during Math and Logic processing because nothing follows the backslash If you require a backslash within the string itself use a double backslash VY The following table lists the meanings of the print formatting characters in Math and Logic Table 8 1 b backspace Vf form feed t horizontal tab v vertical tab backslash V double quote V si ngle quote r carriage return in new line carriage return ine feed combi nation end of li ne character Other special ASCII characters such as non printing control characters for example the escape character are sometimes needed as constants Use the chr function to refer to these characters as described in the T echnical Notes on page 236 in Chapter 9 Math and Logic Procedures and Fu
202. sabled temporarily in order to alter thetemperature range a scaling lock tag named disabl temp could be spedfied This tag would havethefunction of di sabling the tank temp tag Once tank temp has been changed theuser would need to come back tothis table and remove disabl temp from the Scaling Lock Tag field 4 Click on Enter to savethe data when you have completed entering all the information on this panel If you have entered the names of any tags not al ready defined the Tag Definition dialog is displayed 278 FactoryLink ECS Core Tasks Configuration Guide
203. se element x without altering its value use the forced assignment operator to equate the element to itself as shown in the examples below Table 8 20 ENTRE EET NN a 3 a 0 a 1 aL 2 a 31 4 Local array assignment rtdb2 rtdb2 Forced write assignment leaving the value of rtdb2 unchanged x 47 1 xis a local FLOAT X xt rtdbl x Forced write assignment of element RTDB1 rtdb2 rtdb2 Forced write assignment leaving the value of rtdb2 unchanged 222 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Control Statements Control statements sometimes called conditional statements include instructions about the circumstances under which a block of procedure code a sequence of consecutive statements is to be executed E nd a control statement line with an end of line character 1 only Never end a control statement with a semicolon Thereare two types of control statements e F ENDIF WHILE WEND ENDWHILE IF E NDIF AnIF ENDIF statement specifies an action is to be executed only if a specified condition is true Syntax ThelF ENDIF control statement has the following syntax F expr THEN Block to be executed if expr is true ELSE 1 Optional block to be executed if expr if is false a DIF J 4 If the test expression of the statement is true the THEN block is executed If the test expression is not true and
204. shared exe 6 Utility mkcml exe This utility encompasses all of the utilities that comprise the generation of C code Usually you will call mkcml instead of separately calling all of the other steps This utility calls ctgen to make surethe iml ct is up to date then it calls parsecml to parsethe code and finally it calls cacml tolink theassociated files and produce an executable Remember that arguments are not case sensitive Thesyntax of mlcml is as follows D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 265 COMPILED MATH AND LOGIC Generation of CML Executables mkcml V 1 5 NDOMAIN C Syntax of arguments V 1 5 This specifies the verbose level built into the parsed C code that FL produces The different levels do the following Usage V2 or V5 etc Verbose Level Action 1 prints out file names as they are parsed 2 prints out funcs proc names as they are parsed 3 pl aces printf s in each function to show entry and exit of that function 4 places printf s in each function to display each lineas it executes Also prints out the recei ved values of procedures to the display when they are called 5 Displays the lexemes of the functions as they are parsed N DOMAIN This argument specifies domain F actoryL ink utility Usage N user or Nshared C This argument specifies that you want a clean rebuild of all the c files generated This is the same as del
205. si ons statements and directives Declarations Variable dedarations create storage in memory for values A CONSTANT declaration creates a READ ONL Y storage area in memory CONST declarations store values that remain constant throughout the enti re process For example CONST PI 3 E 2 718281828459 A DECLARE dedaration creates a fully functional variable A DECLARE variable behaves li ke a tag except it does not change status Variables can be different data types Declare short counter SHORT variables hold a signed integer whose value ranges from 32768 to 32768 SHORT local variables and analogtag variables store the sameinformation This is the sameas a Ctype INT on most platforms u 16 or ana valuein FLIB Declare long initial time LONG variables hold a signed integer whose values range from 32768 to 32768 LONG local variables and longana tag variables store the same information Thisis the same as a C typeLONG INT on most platforms u32 or LANA valuein FLIB Declare float average temp F LOAT variables hold a 64 bit floating point value This gives floats an 18 digit signed mantissa with a two digit signed exponent FLOAT local variables and FLOAT tag variables hold the same format for information as the same accuracy This is the sameas a C type DOUBLE on most platforms FLP valuein FLIB Declare string old name STRING variables are essentially arrays of shorts comprised of a maximum of 80 characters The length of the
206. ssions on page207 for more informati on A significant difference exists between thetwo assignment operators Refer tothe examples below using database elements fptemp and itemp fptemp itemp Will not change the value of fptemp unless it is different from the valuein itemp although it will still place the integer value into a floating point storage format This form is used to assign values to local and global variables as well as database elements fptemp itemp Forces the value of itemp to be stored in the variable fptemp whether or not fptemp already contains that value and sets all the change status flags associated with fptemp This form is used only to assign values to database elements eo D pus 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 221 MATH AND LOGIC SYNTAX Structure Syntax To obtain the most efficient F actoryL ink task performance use the simplest assignment statement necessary The following chart summarizes assi gnment statement syntax Table 8 19 Assignment Data Types Operator of Operands Operation Result gvar1 1var2 any Normal local global variable assignment tagl varl any Assi gnment is made via database write call tagl var 1 database Assi gnment is made via database forced write elements only call End an assignment statement with an end of li ne character fl or a semi colon Toset the dhangesstatus bit for databa
207. sult is 1 less than If x lt y result is 1 If x gt y result is 0 greater than If x gt y resultis 1 If x y result is 0 less than or equal If x y resultis 1 to If x gt y result is 0 greater than or If x gt y result is 1 equal to If x lt y result is 1 210 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Given the short analog variable x 3 the results of various relational operati ons done using x as an operand are shown in thefollowing chart Table 8 8 Operation Return Value x lt 10 Aa AE e e ejlo le e e olo e lo le lo lolo le e D pus 2 5 2 r e O FactoryLink ECS Core Tasks Configuration Guide 211 MATH AND LOGIC SYNTAX Structure Logical Operators Logical operators test operands for TRUE non zero or FALSE zero values and return a result of 1 TRUE or 0 FALSE Math and Logic resolves all operands to numeric form The following chart illustrates logical operators Table 8 9 Operation Name Operation Definition Operator Type Usage NOT unary NOT x logical NOT Ifxis zero result is 1 negation If xis non zero result is O logical AND Ifx 0 andy 0 result is 1 conjunction If xor y or both areO result is 0 logical OR If x or y or both are 0 disjunction result is 1 If xiszeroand y is zero result is O Placespaces before and after t
208. tart OFF Restores the domain s elements with their change status bits set to 0 OFF after a warm start FactoryLink ECS Core Tasks Configuration Guide 21 PERSISTENCE Configuring Persistence for All Elements in a Domain For example you may have several Math amp Logic procedures triggered by digital tags but the application controls when these tags are force written toa 1 value 1 change status bits 1 If you perform a warm start with Change Bits ON then all of the digital tags change status bits are written to a 1 and all of your IML procs run at once 22 FactoryLink ECS Core Tasks Configuration Guide PERSISTENCE Configuring the Persistence Task CONFIGURING THE PERSISTENCE TASK In addition to configuring persistence for elements and domains you must also configure the operation of the Persistencetask itself Choose Persistence to display the Persistence Savel nformation panel ul Persistence Save Information ol x Edit View Utilities Exit Help Timed Save Trigger Cache Buffers Buffer Size Message Copy Size U o e o t 3 Qo 1 Cancel Enter Exit Following arefield descriptions for this panel Timed Save Name of an element used to trigger a ti med save of the values of Trigger all elements marked as persistent by ti me When the element defined here is triggered at run ti me the Persistence task reads all elements in the current domain instance
209. tdir dolte dogetdrive dogt dogte doinstr dolenstr dolock dolower dolt doltrim domod domul doneg doneq donot door dopow doprint dosetdir dosetdrive dosub dosubstr dosys dotrans dotrim double dounlock doupper doxor else end endif endwhile entry equ exit exp extern f2s fatal fixtype fl cmlpp fl tagname to id float flp for ge getarg getchng getdir getdrive get entry get tag types goto gt i2f idl in if include init input instr int 12f 12s lana le len line load_trig lock FactoryLink ECS Core Tasks Configuration Guide 177 log loge long lower It trim main msg mod mul nalloc ne nfree not or pop popdbvar popflp popint popstr poplong pow print proc process procnam push pushdbvar pushflp pushint pushlong pushstr register resetstack return rnd run time s2f s2i savestr setdir setdrive short shutdown short pause signed sin sizeof sqr static status string struct substr switch system tan Task desc Task name Task id then tos tosflp tosint toslong tosstr trace trprint trim typedef union unlock unsigned upper void wait wend while xor pus o Z 2 e m O MATH AND LOGIC SYNTAX Math and Logic Reserved Keywords Thereserved keywords in bol dface italic type are C keywords reserved by the C compiler Program files cannot use C keywords because when M ath and Logic
210. teand Time cece eee Configuring the Event and Interval Timer Task 00 ee eee Event Timer Information Dialog 0 0200 eres Interval Timer Information Dialog lise ellen Programmable Counters Programmable Countes n n nunnana eX ie D Eun Oa teas Principles of Operation sausas anaana ees 13 13 15 17 18 18 19 21 23 26 27 29 30 37 38 40 40 40 43 51 52 52 SN FactoryLink ECS Core Tasks Configuration Guide 3 Core Tasks Configuration Guide au suma pain unm ExampleOne TT 53 ExampleTwo TETTE Programmable Counters Information Pane DERIT 55 Part IV File Manager 4 HO MADE essct IAQEUEDEYPIEIDPADEMOHA ARA Rada rriebebpRr2 88 File Manager Control Panel 0 000 eee eee ee eee 66 File Manager Information Panel 00 cece eet ee 74 Sample File Manager Operations 00 0 eee eee 76 Example 1 COPY i c uis ise ee ee xk x ek ex eee EE Sy oe ee Sy br Example2 PRINT a0 5 eed ceed brav exe eee ee eae Cae Example 3 REN Rename sls 76 79 80 Example4 TYPE sessseee eene ee ees BL Example5 DIR Directory 82 Example6 DEL Delete DTP Using Variable Spedfiers in File Specifications EA E E EA 85 Using Wildcard Characters in File Specifications llis anaa 87 Using the File Manager with Networks sessseseeeenn 88 Using theCOPY Command with FLLAN m
211. tem to the run time system This saves and restores the compiled CML task along with therest of the application e Copy the executables from FLAPP USER CML and or FLAPP SHARED CML on the development system to the same path on the run time system 2 Start CML Depending on whether the R flag was set in the System Configuration Information panel do one of the following If the R flag was Set enter FLRUN e Not set start CML from the Run Time Manager The compile process begins and CML creates the executables Because the development and run time operating systems are the same CML runs asis D er 2 5 2 r e 7 FactoryLink ECS Core Tasks Configuration Guide 153 CONFIGURING MATH AND LOGIC Running CML Different Development and Run time Operating Systems If the operating systems for the development and run time systems are different perform the following steps to run CML on a run time onl y system 1 Usethe FLSAVE utility to perform a multiplatform save of the application from the development system Because of the different operating systems CML will not run as originally compiled and must be recompiled either on the run ti me system or on a system with the same operating system as the run ti me system A compiler is required for the system on which you will recompile CML 2 Usethe FLREST utility to perform a multiplatform restore of the application to the system on which you will recompile CML
212. the destination path as File Manager will doit for you Path names with wildcard characters in the file specifications might resemble the following examples Table 4 15 source C FLINK SAMPLE SAMPLE destination C FLINK EXE 94 FactoryLink ECS Core Tasks Configuration Guide FILE MANAGER Operating System Notes Using Variable Specifiers in File Specifications 5 16 The following chart contains Windows specific examples of variable specifiers used to designate paths The last example shows the path name of a station on a network m Table 4 16 a Samples of Variable Specifiers in Path Names 5 Standard c history exe sample exe Base example E path 1 variable C 8s exei sample exe Variablefor directory 2variables c 8s 8s sample exe Variables for directory and subdirectory 3 variables c 8s 8s sample 3s Variables for directory subdirectory and 3 character file extension Avariables ls 8s 8s Variables for drive sample 3s directory subdirectory and file extension Standard node2 cA history exei nodeA is thename of a path for a sample exe remote station network stati on FactoryLink ECS Core Tasks Configuration Guide 95 FILE MANAGER Operating System Notes For OS 2 Users Configuring File Manager Source File Spec 5 5 and Destination File Spec 5 7 Table 4 17 DRIVE A DIR SUBDIR For CA LOG HIST
213. theses x y z x NOT NOT y The program evaluates the expressi on as if it contained the following parentheses x NOT NOT y This expression assigns the valueltoxify is nonzero Otherwise the expression assigns 0 to x and is equivalent tox y 0 The program evaluates the expression as if it contained the following parentheses x NOT Y The program evaluates the expression as if it contained the following parentheses x NOT y 22 This expression is different from x NOT y z The latter is equivalent tox y z a 1ANDb 2O0Rc 3 The program evaluates the expression as if ANDd 4 it contained the following parentheses a 1 AND b 2 OR c 23 AND d 4 91607 pue yen FactoryLink ECS Core Tasks Configuration Guide 219 MATH AND LOGIC SYNTAX Structure Table 8 18 Continued Example Statement Explanation of Operator Precedence The program evaluates the expression as if it contained the following parentheses x a b lt Q This expression assigns x the flue 1 if a has the same truth value 1 or 0 as the comparison b c Otherwise the expression assigns Oto x x amp 1 y amp 2 z amp 4 The program evaluates the expression as if it contained the following parentheses x amp 1 y amp 2 Z amp 4 If this case it does not really matter which the program executes first the program executes first the program evaluates the expression from left to right f 2 x 3
214. time it is run e Manages the changes between the persistence save file and theFadoryLink configuration files e Determines if the persistence save fileis usable and if not the program looks for and uses the persistence backup file RESOLVE makes the following changes e Removes element names from the persistence save file that have been deleted from the application or changed to a different data type Updates the element name ID for element names that were deleted then recreated e Adds element names to the persistence save file that have been reconfigured to have persistence These element names are added with no data values e Copies the persistence backup file over the persistence savefileifthe savefileis corrupted FactoryLink ECS Core Tasks Configuration Guide 17 PERSISTENCE Configuring Persistence for Existing Applications CoNFIGURING PERSISTENCE FOR EXISTING APPLICATIONS The methods for configuring persistence are the same for both new and existing applications For existing applications however you must first run the FactoryLink Conversion Utility FL CONV FL CONV assigns the following default persistence options to an existi ng application Saving No persistence e Restoring Set Change Status OFF After you run the FL CONV utility you can changethe persistence opti ons for the elements in that application Determine the database elements in the application to be persistent and configure persistence
215. ting system counterparts The FileManager controls all file operations through the F actoryLink real time database You can configure other FactoryLink tasks toinitiate File Manager operations For example e You can configure input functions in Graphics so an operator can usethem to initiate file management operations at run time such as to display a list of recipes or reports e TheTimer task can trigger File Manager to automatically back up fil esto a networked server at certain intervals such as each day at midnight e TheTimer task can alsotrigger File M anager to delete log files automatically at certain intervals such as once every four hours or after certain events such as when log files reach a spedfied size e Alarm Supervisor can trigger File Manager to print alarm files FactoryLink ECS Core Tasks Configuration Guide 65 FILE MANAGER File Manager Control Panel FILE MANAGER CONTROL PANEL The File Manager Table has two panels e File Manager Control configure one e File Manager Information All operations are defined in one File Manager Control panel For COPY REN DEL and PRINT operations do not complete a File Manager Information panel However for each TYPE or DIR operation defined in the File Manager Control panel complete one File Manager Information panel File Manager defaults tothe USER domain but you can configure ittorun in either domain Before opening and configuring File Manager ensure the d
216. tion Guide MATH AND LOGIC OVERVIEW Modes MKCML The MKCML utility is a shell that calls the PARSECML and CCCML utilities as needed for the current application F or each domain MKCML checks the dependencies between the configuration tables and the program files by e EnsuringthelML CT fileis up to date by calling CTGEN CTGEN compares IML CT against the database files upon which IML CT is dependent If the database files have a later time date stamp than IML CT CTGEN rebuilds IML CT to bring them up to date Checkingthe time date of IML CT to determine if the Math and Logic configuration has changed If so it reproduces and recompiles all of the C files by calling PARSECML and CCCML When you redirect the output of MKCML toa file the messages in the dump may appear out of order because of the way the operati ng system buffers and outputs messages when redirecting output I f you do not redirect the output of MKCML the MKCML reports the messages to the standard output in the correct order PARSECML ThePARSECML utility parses the appli cation program fi eld and produces C files for a given domain It produces a C file for each program file listed as compiled has COMPILED in the Mode field in the Math and Logic Triggers Information panel The utility also checks the dependencies between the program field and the C files to determine if any procedures have been updated sincethe C files were last produced D er 2 5
217. tring with trailing blanks trimmed upper Example Therefore string upper string msgvar upper not msgvar NOT Returns the input string converted to upper case 240 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes For Windows NT and Windows 95 Table 9 4 Directory Path Control Functions getdir string getdir drive Returns the aurrent path of specified drive drive 20 current drive drive 21 a drive 22 b and so on Example string getdir 1 Therefore string a getdrive drive 2gedrive Returns current disk number drive 21 a drive 22 b and so on Example drive getdrive Therefore drive 2 if current driveis drive b setdir status setdir drive Returns zero for success Sets new path current dri ve di rectory drive 20 current drive drive 21 a drive 2 b and so on Example status setdir 1 a test Therefore status 0 if current drive directory successfully set to aA test FactoryLink ECS Core Tasks Configuration Guide 241 D 5 2 5 2 m fo m 7 MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 4 Directory Path Control Functions Continued setdrive stat setdrive drive Returns zero for success Sets new current drive drive 21 a drive 22 b and soon Example stat setdrive 1 Therefore stat 0
218. tronic or mechanical including photocopying and recording for any purpose without the express written permission of USDATA Trademarks USDATA FactoryLink and FactoryLink ECS are registered trademarks of United States Data Corporation Open Software Bus is a registered trademark licensed to United States Data Corporation All other brand or product names are trademarks or registered trademarks of their respective holders Table of Contents Part I Part Il 2 Part Ill 3 Core Tasks Configuration Guide Persistence Pasia aaa aa UR ERROR A A EA vat Persistence Overview 0 0 ett eee Principles of Operation 0 2 0 cc tt eee Resolving Configuration Changes 0 cece ee eee Configuring Persistence for Existing Applications Configuring Persistence for New Applications 000 Configuring Persistence for Individual Elements 0 000000 Configuring Persistence for All Elements in a Domain Configuring the Persistence Task 0 ccc cece eens Persistence Task Start Order 0 0 00 00 cet eee Persistence and Digital Elements 0 cece eee eee Persistence SaveFileName ananuna te eee Editing Tag Persistence Settings UsingBH SQL Utility Event and Interval Timer Event and Interval TIME vids cada bajudacided edaded EX EAE pays Principles of Operation 20 2 ee tt eee Changing the Operating System Da
219. uest occurred 246 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Totransmit one backslash V character type two backslashes Doubling the character causes the system to recognizeit as a literal character System command represents a call made tothe operating system This might bea simple directive such as DIR C or it might be complex such as a request to execute a batch file to request values or inputs from the user GGE TID or to request another operati ng system shell DOSSHELL Arguments tothe SY STEM function are operating system dependent For Windows NT and Windows 95 Under Microsoft Windows the SY STEM function is asynchronous that is the SYSTEM function returns immediately The operating system command runs in parallel to Math and Logic f the command is started the return value of the SYSTEM funcion is O zero otherwise the return valueis 1 Notethat usingthis feature makes procedures non portable without manual conversion of the system calls to those appropriatein the target system For OS2 The SYSTEM function sends the specified operati ng system command tothe operating system and begins a subprocess that passes the request to a DCL Command Line Interpreter CLI The Run Time Manager screen for the particular domain in which Math and Logicis running displays the output the CLI produces while processing the request Enclose the desired system
220. value of 0 if the assigned value is non zero after any fractional part is truncated the digital variabletakes on a value of 1 Floating point Assigning a floating point value to an analog or long analog conversion variable can result in a loss of precision loss of least significant bit s when the system truncates the fractional portion of the value The integer portion of the floating point value might also exceed the maximum number of bits allocated toan integer which causes an overflow in the analog el ement The maximum number of bits used by an integer depends on the data type of the el ement or variable Data types and maximum number of bits areas foll ows Table 8 4 Data Types Maximum Number of Bits SHORT analog 16 FLOAT floating point 202 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC SYNTAX Structure Data type precision When numeric data types are used in arithmetic operations the result has the precision of the most accurate data type If either data type is floating point the result is floating point Otherwise theresult is analog Digital and analog data types are internally represented as signed integers Overflow Execution of arithmetic operations can result in an out of range value being placed intoan analog or float variable This results in a condition known as overflow loss of most significant bit s in that variable To avoid causing overfl ow do not use cal
221. variable tag name a Math and Logic variable or a constant but it may not be a function expr standsfor an arbitrary expression block refers to any sequence of consecutive statements Endosea system call appropriateto the operating system within the double quotation marks Virtually any system call such as the dir command is valid The SYSTEM directive requires operating system specific arguments D pus D 5 2 m fo uL FactoryLink ECS Core Tasks Configuration Guide 229 MATH AND LOGIC SYNTAX Structure 230 FactoryLink ECS Core Tasks Configuration Guide Chapter9 Math and Logic Procedures and Functions PROGRAM FILES A program file is a text file containing the text of one or more Math and Logic procedures and has the extension PRG A program fileis composed of procedures and dedarations P rogram files can contain multiple procedures however a program file must contain one procedure call ed the main procedure that fits two criteria e Themain procedure has the same name as the name of the program file minus the extension F or example the program file MYPROC PRG must contain a main procedure with the name MY PROC myproc M yProc or some variation Program filenames are not case sensitive e The procedure name entered in the Math and Logic Triggers table must be exactly the same as the name entered in the program file ind udi ng upper and lowercase characters Procedure
222. y tag referenced in the PRG files Failureto list a tag in this panel results in validation errors and run time errors Tags listed in this panel for the SHARED domain are handled separately from thetags listed in the USER domain For this reason if a SHARED tagis used in both SHARED and USER procedures it must be referenced in both the SHARE D Math and Logic Variables table and the USER table Array tags are handled differently in this panel To use any element of an array only the zeroth element array 0 should be listed here A common mistakeis defining an array in this panel by typing array 19 to define a 20 el ement array This method of definition is fine for definition purposes but to ensure proper functioning of Math and Logic the subscript must be changed to zero array 0 This table has one panel Math and Logic Variables I nformation D er 2 5 2 m fo 2 7 FactoryLink ECS Core Tasks Configuration Guide 135 CONFIGURING MATH AND LOGIC Math and Logic Configuration Tables Math and Logic Triggers Table The Math and Logic Triggers table lets you define the trigger elements used to trigger the Math and Logic procedures to run For each trigger element defined you enter the associated procedure the trigger element is responsible for triggering The Math and Logic Triggers table lists a trigger tag a procedure name and the run mode of the procedure Digital tags serve as the most common trigger typ
223. ystem Pure random numbers are normally not needed but we recommend you investigate writing a custom randomizer functi on seeded differently each timethe function is called It is beyond the scope of this document to discuss the uses and characteristics of randomizing functions but many texts providea point of reference This function however is serviceable for the devel oper who wants to spedfy a different number for a sort or pointer each timethe routine is entered such as start at a different belt each time red cars are sought on the conveyors If randomness is necessary contact Customer Support sin x sin y Returns thesineof y Specify y in Example x sin 1 5 radians Therefore x 0 9974951 sqr x sqr y Returns the square root of y Example x sqr 144 Therefore x 12 238 FactoryLink ECS Core Tasks Configuration Guide MATH AND LOGIC PROCEDURES AND FUNCTIONS Technical Notes Table 9 2 Mathematical Functions Continued tan x tan y Returns the tangent of y y is specified in Example x tan 785 radians Therefore x 1 Directory Path Control Functions Directory and path control functions are unique to each operating system Table 9 3 String Manipulation Functions alltrim string alltrim string Returns string with leading and Example msgvar trailing blanks trimmed alltrim SMITH Therefore msgvar SMITH asc x asc string Returns the ASCII value of the

Download Pdf Manuals

image

Related Search

Related Contents

The INTREPID DDF format (R08)  Ergolift Wall Lift User Manual  Multimedia Interface Bedienungsanleitung Instruction manual 1289  Guia de instalação - Epson America, Inc.  Vist  CS 79 - Cassese  User Manual - SensiCardiac    Mode d'emploi  Plantronics P620  

Copyright © All rights reserved.
Failed to retrieve file