Home

- Expression Editor - Expression Editor

image

Contents

1. like StringSource StringCompare BooleanMatchCase len String substring String StartPos Length Hox Expression h Arithmetic Bitwise DK Wildcard String Compare String Length Substring Extraction replace StringSource StringFindwhat StringReplacewWith Substring Replacement left String Length right String Length concat String1 String2 IndexOf StringToSearch StringToFind StartIndex trim StringToTrim CharactersToRemove trimleFt StringToTrim CharactersToRemove trimright StringToTrim CharactersToRemove tolower String toupper String tostring Number Left Substring Right Substring String Concatenation String Search Trim Left and Right Trim Left Trim Right Lower Case Cast Upper Case Conversion Type Conversion String Functions Relational Logical Sn Tags Help 15 Expression Editor User s Manual In all the string functions which are listed in the table below the position of the first character is zero Thus if a position is returned or a starting position is provided as a parameter then they all refer to a zero indexed string STRING FUNCTION DESCRIPTION like StringSource StringCompare BooleanMatchCase Wildcard string compare see note below len String Returns the length of String substring String StartPos Length Returns Length characters of String starting from StartPos replace StringSource StringFindWhat StringRe
2. MYTAG min 13 Expression Editor User s Manual Mathematical The Mathematical functions are shown in the figure below Edit Expression Expression Es B Arithmetic Relational Logical Bitwise Tags Der a EEREN GEMELO sinelAngleInRadians Sine era 1 gt cos AnglelnRadians Cosine Constant gt tan AnglelnRadians Tangent OPC gt asin Number Arcsine acos Mumber Arccosine atan Mumber Arctangent sqrt Number Square Root pow Base Exponent Raised to Power log Number Logarithm In Number Natural Logarithm exp Number Exponential abs Mumber Absolute Value ceil Number Integer Ceiling Floor Mumber Integer Floor min Number1 Number2 Minimum max Number1 Number2 Maximum Mathematical Functions The symbols sin asin cos acos tan atan log In exp sqrt abs ceil and floor use the following format symbol parameter The symbols pow min and max use the following format symbol parameter parameter Note The parameter should be a valid number or a string convertible to a number see the Data Type Conversion section above Note also that the parameter should belong to the domain of values acceptable for the function in which it is used For example function asin variable exists only when 1 lt variable lt 1 For additional information please refer to a mathematical reference book Not
3. e charlist Accepts a single character if it is part of the characters list e charlist Accept a single character if it is not part of the characters list Note To match the special characters left bracket question mark number sign and 17 Expression Editor User s Manual asterisk enclose them in brackets The right bracket cannot be used within a group to match itself but it can be used outside a group as an individual character By using a hyphen to separate the upper and lower bounds of the range charlist can specify a range of characters For example A Z results in a match if the corresponding character position in string contains any uppercase letters in the range A Z Multiple ranges are included within the brackets without delimiters Other important rules for pattern matching include the following e An exclamation point at the beginning of charlist means that a match is made if any character except the characters in charlist is found in string When used outside brackets the exclamation point matches itself e A hyphen can appear either at the beginning after an exclamation point if one is used or at the end of charlist to match itself In any other location the hyphen is used to identify a range of characters e When a range of characters is specified they must appear in ascending sort order from lowest to highest A Z is a valid pattern but Z A is not The ch
4. CONSTANT viii ii ee ne iv RO a AA E A as 19 OPSQUAL Vo A A ed ae DB 21 TAGS A A te eS A IA a eae 22 SELECTING ALARMATTRIBUTE Sc ueonisdrn add ata tee 26 IlI Expression Editor User s Manual IV Creating Expressions Using the Expression Editor CREATING EXPRESSIONS USING THE EXPRESSION EDITOR The Expression Editor shown below is available to assist you in creating expressions for your ProcessView applications The window is resizable and can be stretched as well as maximized or minimized The drop down list at the top of the Edit Expression dialog box keeps track of the last 50 expressions you have entered The expression entered most recently is the first one in the drop down list W Edit Expression ioj x Expression x SMAR x 5mar Simulator 1 SimulatePLC Sine x Smar Simulator 1 Simulate COOL Quiz Arithmetic Relational Logical Bitwise Functions Tags OK Cancel Help gt G Expression Editor id Writing Expressions An expression is a string that defines and evaluates a data connection between a client and an OPC server During runtime mode OPC servers resolve the data value for the expression To indicate that a data connection is an expression precede the string with the x token as shown below x Smar Simulator 1 SimulatePLC PumpSpeed You can either type your expressions directly into the text box of the Edit Expression dialog bo
5. Creating Expressions Using the Expression Editor io Expression z AlarmType 1 AlarmType 2 AlarmType 3 Arithmetic Relational Logical Bitwise Eunctions ag i Filter Wizard Canc Advanced Global Alias Browser Language Alias Browser Editing Alarm Filters Using the Expression Editor Filter Wizard The Filter Wizard shown in the figure below allows you to choose from the following items to enter in your expression Select one or more items and then click OK The filter string is automatically inserted into the Edit Expression dialog box Alarm Types Alarm Ack Unack Normal Tracking and Operator Subconditions LoLo Lo Hi HiHi ROC and Digital Severity This is the OPC defined value for alarm priority The valid OPC severity range is 1 lowest to 1000 highest The first number is the low limit and the second number is the high limit Source The tag name Message Description of the tag Node Name of the PC from which the tag originates Clicking the Advanced button opens the Expression Editor Note Alarm Types are logically or with Alarm Types Subconditions are logically or with Subconditions Alarm Types Subconditions Severity Source Message and Node are logically combined and to create the expression string 25 Expression Editor User s Manual Filter Wizard x pes Sub Conditions k Normal I
6. ready y left Left substring x left Hello World 5 Hello right Right substring x right Hello World 5 World String w concat concatenation x concat Hello World Hello World IndexOf String search x indexof Hello World World 0 6 16 Creating Expressions Using the Expression Editor SYMBOL DESCRIPTION EXAMPLE RESULT trim Trim left and right x trim Hello World Hadl ello Wor trimleft Trim left x trimleft Hello World Hdl ello World trimright Trim right x trimright Hello World Hdl Hello Wor tolower Lower case cast x tolower Hello World Hdl hello world Upper case toupper conversion x toupper Hello World Hdl HELLO WORLD tostring Type conversion See below See below Note When a string value which can be converted into a number is passed as a numeric parameter for a string function then an automatic conversion is attempted For example the expression x Left Hello World 4 is a valid expression If the automatic conversion is not possible then the expression result will have bad quality See the data type conversion section above for additional details Note that is also possible to pass a number to a string parameter refer to the Data Type Conversion section above For example x len 35 will return 2 Note also that the string functions will return bad quality when the parameters are non meaningful e g a negative length
7. 0 or 1 Examples Symbol Description Example Result lt Less than yari lt var2 8 lt 3 0 gt Greater than var1 gt gt var2 8 gt 3 1 lt Less than or equal to vari lt var2 8 lt 3 0 gt Greater than or equal to varl gt var2 8 gt 3 1 Equal to vari var2 8 3 0 l Not equal to yari var2 8l 3 1 Logical The Logical menu symbols are shown in the figure below Creating Expressions Using the Expression Editor o xi Expression y A EA Arithmetic Relational Bitwise Functions amp amp AND II OR Exe Ze Logical Symbols The symbols amp amp and use the following format parameter symbol parameter The symbol uses the following format symbol parameter Where GATA A local variable an OPC tag a constant or another expression SYMBOL amp amp or or Result The expression results in a Boolean value 0 or 1 Truth table vario var2 Varl gt is rta levar 1 o Examples SYMBOL DESCRIPTION EXAMPLE RESULT amp amp And varir gt amp amp var2 88 amp amp 3 1 Or evari var2 8 3 1 Not l var1 18 0 Bitwise The Bitwise menu symbols are shown in the figure below Expression Editor User s Manual Edit Expression me Beak Expression z Ar
8. 26 Creating Expressions Using the Expression Editor Example Alarm Filters EXPRESSION RESULT X Severity gt 500 Only alarm messages with a severity greater than 500 will be visible E a i Only messages with the tag in the source name X Like Source Tag 0 wal La dieplave a 9 Only messages with a description beginning with X Liket Messagej Boiler Purp nar 40 Boiler Pump not will be displayed BR i i Only messages from Node Alpha will be X Like Node Alpha 0 displayed X Like Attribute1 Plant Area 1 0 Tag values Attribute1 through Attribute20 are server specific They can be strings numeric values or arrays The most common array usage is for Areas When dealing with areas use the X Attribute2 40 Like function X 1 Filter displays all messages X 0 Filter does not display any messages All filters resolve to TRUE or FALSE All nonzero values resolve to TRUE For more information please see the AlarmWorX Server documentation 27 Expression Editor User s Manual 28
9. LoLo 7 HiHi I Tracking 1 I ROC I Unack Operator I Hi T Digital I Severity min max fo Source a Message i of Node Cancel Advanced Filter Wizard Selecting Alarm Attributes Selecting Advanced from the Tags menu of the Expression Editor opens the Alarm Tag list shown in the figure below which allows you to choose alarm attributes for your alarm filter Select the attribute that you want to include in the filter expression and click OK Note You can also perform a wildcard string compare using the like operator syntax Check the String Compare check box and type the desired string in the text field Alarm Tag wy xi Tag Name Change Mask New State Source Time I String Compare Event Type Event Categor severity Condition Name SubCondition Name Quality Ack Required Active Time Alarm Attributes List There are two additional attributes available for use in filtering Alarm Type and Current Time The Alarm Type attribute allows you to filter alarms according to ALARM 1 ACK 2 UNACK 3 OPER 4 TRACK 5 or NORM 6 For example you can set up a filter with the condition X AlarmType If the Alarm Type is true then the alarms are displayed If they are false then the alarms are not displayed The Current Time attribute allows you to filter according to the current time Only alarms occurring around the current time will be displayed
10. or a negative starting position Function like StringSource StringCompare BooleanMatchCase The like function is used to perform string comparison it searches for a pattern inside a string and returns a value that indicates whether the pattern is contained in the string or not The like operator accepts three parameters 1 The first parameter is the string in which you want to perform the search 2 The second parameter is the pattern that you want to find 3 The third parameter is a Boolean parameter that allows you to specify whether the search must be case sensitive or not 1 meaning case sensitive and O meaning case insensitive A string can be a variable of type string a process point TAG of type string an array of strings meaning OPC tag of type array of string or a constant value of type string or a numeric value An example of a constant string is This is a string Notice that the quotation mark indicates the beginning of the string and the quotation mark indicates the end of the string For the like operator string equals the string to search in pattern equals the string to search for can include wildcards nonzero for case sensitive search zero for case insensitive search String syntax is string You can use these special symbols in pattern matches to match a single character in the source string e Accepts any single character e Accept a single character if it is digit 0 9
11. 0 1 10 Creating Expressions Using the Expression Editor Examples The following two examples use the variables var1 and var2 in several expressions that use bitwise symbols In Example 1 the decimal values for these variables are e vari 8 e var2 10 In Example 2 the decimal values for these variables are e varl 96 e var2 8 The binary values are also listed in the tables below The representation chosen is 16 bits per variable Variable Values for Example 1 and Example 2 Example 1 Values Example 2 Values Decimal Decimal Binary Binary Varl 8 96 0000 0000 0000 1000 0000 0000 0110 0000 Var2 10 8 0000 0000 0000 1010 0000 0000 0000 1000 Example 1 Expression Result vario 8 Decimal var2 10 Binary varl amp var2 8 0000 0000 0000 1000 varios var2 10 0000 0000 0000 1010 varios var2 2 0000 0000 0000 0010 shl var1 3 64 0000 0000 0100 0000 shr var1 3 1 0000 0000 0000 0001 var1 9 1111 1111 1111 0111 bittest var1 3 1 0000 0000 0000 0001 11 Expression Editor User s Manual Example 2 Expression Result varl 96 Decimal ovare 8 Binary ovarl amp var2 0 0000 0000 0000 0000 martes var2 104 0000 0000 0110 1000 o va
12. 10 1610 2 256 0 16 10 1 512 0 10 522 e Octal 0t36 3 71 6 740 3 7 6 1 21 6 27 e Binary 0b110 1 2 2 1 2M 0 2X0 1 4 1 2 0 1 4 2 40 6 20 Creating Expressions Using the Expression Editor OPC Quality The OPC Quality function is shown in the figure below lolx Expression zl Arithmetic Relational Logical Biwise Conditional em Mathematical String Constant OPC Tags v EJ A AS 4 quality value OPC Quality OPC Quality Function The quality option on the Functions menu of the Expression Editor is used to evaluate the quality of an OPC tag or an expression The following general syntax is used for quality expressions x quality expression Note The expression can also be a simple expression composed of a single tag The quality function returns the OPC quality of the string between parentheses as one of the following results e 192 quality is GOOD e 64 quality UNCERTAIN e 0 quality BAD Note The OPC Foundation establishes the value ranges for quality There are actually varying degrees of quality e GOOD 192 252 e UNCERTAIN 64 191 e BAD 0 63 For more information refer to the OPC Data Access Custom Interface Standard available for download at the OPC Foundation s Web site www opcfoundation org Example Quality Expression EXPRESSION RESULT x quality Smar Simulator 11SimulatePLC PumpStatus 192 Q
13. 6 O Hvac L Ramps SimulatePLC Ramp5 H Panell UL Ramp4 SimulatePLC Ramp4 4 Panel2 L Ramp3 SimulatePLC Ramp3 H RecipeStorage L Ramp2 SimulatePLC Ramp2 E SimulatePLC Ramp SimulatePLC Ramp Q 1 WebHMI A L PumpStatus SimulatePLC PumpStatu y gt gt 20 Objects 1 Selected Selecting OPC Tags from the Unified Browser Local and Global Aliases An alias is a string that represents or describes an object or data point in a display Both local and global aliases can be used in expressions Local Aliases For local aliases within the expression use the following syntax lt lt local_alias_name gt gt Example x lt lt TankLevel gt gt Global Aliases For global aliases within the expression use the following syntax lt global_alias_name gt Example x lt RoomTemperature gt Select a global alias from the Unified Browser which includes all global aliases in the global alias database This eliminates the need to manually type in the alias name All global aliases that are configured in the Global Alias Engine Configurator are conveniently available to choose from inside the browser The tree control of the Global Alias Engine Configurator is mimicked in the tree control of the Global Alias Browser Select a global alias by double clicking the alias name e g Floor in the figure below The alias name appears at the top of the browser which automatically adds the lt and gt delimiters to the al
14. N Note The quality of an invalid expression or number is always BAD Da options available under the Tags button of the Expression Editor vary with each type of application and may include the following e OPC Tags e Local and Global Aliases e Variables e Alarm Filters Some of these options may not be available in some applications For more information about the available options please refer to the application s help documentation 22 Creating Expressions Using the Expression Editor OPC Tags An OPC tag or data point is a data connection between a client and an OPC server OPC tags can be used in expressions when the tag is embedded between double brackets as shown below tag_name Example x Smar Simulator 1 SimulatePLC PumpSpeed You can use the Unified Browser shown below to select OPC Alarm and Event AE Data Access DA and Historical Data Access HDA tags to include in your expressions e gt solatla ale a x o Que SMAR Simulator 1 SimulatePLC Sine OPC DA Database Access Global Aliases Graphworx 94 Smar DF65Server 1 A Name Fullitemid 2 4M Smar DfiOleServer 0 U Tagy SimulatePLC TagY 48 Smar hseoleserver 0 LY Tagx SimulatePLC TagX ce de Smar IServer 0 Square SimulatePLC Square A SMAR Simulator 1 a SimulatePLC Sine HE BridgeWorxRecipe L Random SimulatePLC Random y DiskIO L Ramp SimulatePLC Ramp7 H Globalvariables Ramp6 SimulatePLC Ramp
15. aracter sequence is considered a zero length string You can also use the asterisk to match zero or more characters in the string It is important to note that the like function performs a character by character comparison of the source and the compare strings If these strings have different length then the comparison will not be possible and the function will return FALSE The only exception to the aforementioned rule is through the use of the asterisk which can take the place of zero or more characters The following is an example of the like function Like var_user_name mark 1 The above expression will look inside the string variable var_user_name and will return true if it contains the exact string mark If the variable var_user_name contains the string MaRk then the above expression will return false because we have set the comparison to be case sensitive the third parameter is 1 If we write the following expression Like var_user_name mark 0 Then it will return true even if var_user_name contains the string MaRk because we have set the comparison to be case insensitive If we write the following expression Like var_user_name mark 0 And the variable var_user_name contains the string mark twain then the expression will return false because the two strings do no match exactly As mentioned above you can use wildcard characters to compare pa
16. e Str Number where Str is a string convertible to a Number results in a Number If the string is not convertible into a number then the result will have a bad quality The following is an example of a valid expression x 546 Point Extension Syntax The Point Extension Syntax PES allows for retrieving additional information related to OPC tags such as quality and timestamp To use the PES 1 Prefix your tag name with tag 2 Postfix your tag name with followed by a PES token Valid PES tokens are e quality returns the OPC quality associated with the tag value e timestamp returns the timestamp associated with the tag value Creating Expressions Using the Expression Editor The following are example expressions using a valid PES request e tag Smar Simulator SimulatePLC Ramp timestamp e tag Smar Simulator SimulatePLC Ramp quality e tag pc1 Smar Simulator SimulatePLC Ramp timestamp e tag pc1 Smar Simulator SimulatePLC Ramp quality Please see the OPC Quality section below for additional information about OPC quality Sometimes it may be necessary to enforce the request data type to a specific type such as string in order to display the extended syntax information in a process point Arithmetic The Arithmetic menu symbols are shown in the figure below 51xi Expression bei Relational Logical Addition Tags Subtraction Multiplication Divi
17. e Since the constant pi presented here actually is the rounded number pi the expression such as tan PI N 2 where N is an odd number is considered here as a valid expression Please see the Constant section below Examples SYMBOL DESCRIPTION EXAMPLE RESULT sine of an angle in _ sin radians sin var1 sin 0 785 0 71 cosine of an angle cos intadiane 9 cos vari cos 0 785 0 71 tangent of an tan angle in radians tan var1 tan 0 785 1 0 arc sine returns asin an angle in asin var1 asin 0 5 0 52 14 Creating Expressions Using the Expression Editor String SYMBOL DESCRIPTION radians EXAMPLE RESULT arc cosine returns two acos an angle in acos var1 acos 0 5 1 05 radians atan an z gle atan var1 atan 1 0 785 in radians sqrt Sa sqrt var1 sqrt 100 10 Returns value 1 pow raised to the pow varl var2 pow 100 1 5 1000 power value 2 10 based log logarithm log var1 log 100 2 In o i pnyarias In 7 389 2 Exponential exp exp var1 exp 2 7 389 abs enone Ne Ue abs var1 abs 1 1 cei nteger ceiling ceil var1 ceil 7 39 8 floor teger floor floor var1 floor 7 39 7 Lowest value of N min t min var1 var2 min 10 5 5 wo max mighest value of max var1 var2 min 10 5 10 The String functions are shown in the figure below
18. he expression is GOOD Thus the result of the expression is not affected by the quality of Tag2 the else branch of the expression which is ignored In cases 4 6 the quality of Tag1 is UNCERTAIN and therefore the result of the expression is the quality of Tag2 In cases 7 9 the quality of Tag1 is BAD and therefore the result of the expression is the quality of Tag2 Note The quality function returns a value that represents the quality of the expression within the parentheses but is always GOOD_QUALITY For example if Tagi is BAD QUALITY then the expression x quality Tag1 will return O with GOOD_QUALITY The result of an expression is the minimum quality of the evaluated tag in the expression and is affected only by the quality of the conditional if then or else branch that is executed Consider the following sample expression x if TAG_01 gt 0 TAG_02 TAG_03 This expression can be read as follows If the value of TAG_01 is greater than 0 then the expression result x is TAG_02 If the value of TAG_01 is less than or equal to 0 then the expression result x is TAG_03 Let s assume that the following values and qualities for these tags TAG_01 5 with quality GOOD TAG_02 6 with quality UNCERTAIN TAG_03 7 with quality BAD Because the value of TAG_01 is 5 greater than 0 the expression result is TAG_02 Thus the final expression result is 6 and the final expression quality is UNCERTAI
19. ias name Click the OK button 23 Expression Editor User s Manual lt Floor gt Global Aliases a Aliases Name Description 0000000000000 Building BuildingIdent Building human readable identification string a Floor E FloorCaption FloorIdent Floor human readable identification string l Room RoomCaption amp Roomident Room human readable identification string RoomTemper bd me Selecting a Global Alias From the Unified Browser Variables Variables can be used in expressions How the variable needs to be referred depend on the type of variable A local variable can be used in expressions when the variable is embedded between double tildes Local Variables For local variables within the expression use the following syntax local_variable_name Example x Setpoint Simulation Variables For simulation variables within the expression use the following syntax simulation_variable_name x gfwsim random long Alarm Filters The Expression Editor dialog box shown in the figure below can also be used to edit alarm filters see the AlarmWorX help documentation for additional information about filters The Expression Editor provides a Filter Wizard and an Alarm Tag list to help you create simple alarm filters If you want to customize your alarm filters you can use the other functions in the Expression Editor to set up your alarm filters manually 24
20. in the source string like mark ma def k 0 0 Similar to the above example but in this case we are trying to match the third character like mark a z ark 0 1 In this example we are accepting for the first character any character between a and z like mark a z a 0 1 This is similar to the above example but we are accepting anything after the first two characters like mark a z a 0 0 This is similar to the above example but in this case the like function returns zero because there are characters left after the first two characters have been compared In other words the two strings have different lengths and there are no asterisks to accept for the extra characters like mark m bc rk 0 1 This will return 1 because we have prefixed the character array with a exclamation mark and the second character does not belong to the character array like mark2 mark 0 1 This will return 1 because the last character is a number Function tostring number The tostring option on the Functions menu of the Expression Editor accepts anything that can be interpreted as a valid number in parentheses and converts it into a string Example Expressions Type Conversion EXPRESSION RESULT x The value is The value is 543 2345152 Watt tostring gfwsim ramp float Watt Constant The Constant functions are shown in the figure below Edit Expression TAT Exp
21. ints or expressions Note that the numerical value O will be evaluated as FALSE while all the other values will be evaluated as TRUE The following table shows some examples of if functions If the local variable var is a positive number then If var gt 0 1 0 the expression will return 1 In all other cases the expression will return 0 If the local variable var is a negative number then If var lt 0 10 55 the expression will return 10 In all other cases the expression will return 55 If the local variable pressure is greater than 100 If pressure gt 100 level then the expression will return the value of the variable pumpstatus level In all other cases the expression will return the value of the variable pumpstatus If the value of pump_on is 1 then the expression will If pump_on 1 0 1 return O In all other cases the expression will return 1 If the value of pump_on is 1 then the expression will return 1 In all other cases the expression will return the maximum between the value of var1 and var2 If pump_on 1 1 max varl var2 If the value of the process point MYTAG is greater than or equal to the value of the local variable min then the expression will return the value of the process point itself In all other cases the expression will return the value of the local variable min If MYTAG gt min
22. ion Editor Express Fieldbus snnalr IN o t o Firs MAY 06 Expression Editor VERSION 8 FOUNDATION USER S MANUAL Expression Editor Edit Expression 5 x Expression I A si Relational Logical Bitwise Functions Tags OK Cancel Help OK _Coel _ Heb EWEX EME PV smar www smar com Specifications and information are subject to change without notice Up to date address information is available on our website web www smar com contactus asp Table of Contents TABLE OF CONTENTS CREATING EXPRESSIONS USING THE EXPRESSION EDITOR uu 222000200000000000000000n0nnann0nnnnnnnnn nun 5 WRITING EXPRESSIONS ii iini danio ii Sn He Beeren eisen end 5 STRINGS IN EXPRESSIONS see tn ne nenn ns nenn rn een 5 STRINGS COMPARISON u nnd an un ee 6 DATA TYPE CONVERSI N incio A A ne ine a ne eine ee 6 POINT EXTENSION SYNTAX en en antenne nee ae ee 6 ARITHMETIC net sees 23 82 ee area ak ee Nae cone alee ved ERE 7 LOGICAL nt ees dele E il eg ER Ri ed ibe viele da A Li FREE 8 BITWISE cuneta 2 2 te bus tek ected Ran eltern reger au a 9 FUNGTIONS SPPRER tics dieden E T T a E atdieanussesestas deg ERSTEFTERFERPFEFTFEPRTEFFFEFPIEFTPEREFFR FE 12 CONDITION A Lo 4 2 ae RE dd dad Giada 13 MATHEMATICAL ica A A Ei 14 STRING 0 a A A A AE EA ATEOS 15
23. ithmetic Relational Logical Functions Tags amp AND OR NOT e XOR shl Mumber ShiftBy Shift Left shr Wumber ShiftBy Shift Right bittest Number BitPos Bit Test Bitwise Symbols The symbols amp and of the bitwise group use the following format parameter symbol parameter Where INIA A local variable an OPC tag a constant or another expression The symbol of the logical group uses the following format parameter Where uuig A local variable an OPC tag a constant or another expression The symbols shl and shr of the bitwise group use the following format symbol number shift by Where J0 shl or shr BER A local variable an OPC tag a constant or another expression B The number of bits to shift The symbol bittest of the bitwise group uses the following format BitTest number bit position BER A local variable an OPC tag a constant or another expression B The position of the bit to test A bit position of 0 indicates the less significant PO O bit Examples SYMBOL DESCRIPTION EXAMPLE RESULT amp Bit And vari amp var2 8 amp 3 0 Bit Or vari var2 8 3 11 A Bit eXclusive Or vari var2 8 3 11 shl Bit shift left shl var1 3 8 lt lt 3 64 shr Bit shift right shr var1 3 8 gt gt 3 1 gt Not two s complement varl 18 9 bittest Bit Test bittest 5
24. placeWith Replaces all the occurrences of StringFindWhat in StringSource with the string StringReplaceWith left String Length Returns the first Length characters of String right String Length Returns the last Length characters of String concat String1 String2 Returns the concatenation of the two strings String1 and String2 IndexOf StringT oSearch String T oF ind StartIndex Returns the index of the first occurrence of StringToFind within StringToSearch starting from Startindex A value of 1 is returned if the search string is not found trim StringToTrim CharactersToRemove Removes the characters listed in CharactersToRemove from the beginning and the end of StringToTrim trimleft StringToTrim CharactersToRemove Removes the characters listed in CharactersToRemove from the beginning of StringToTrim trimright StringToTrim CharactersToRemove Removes the characters listed in CharactersToRemove from the end of StringToTrim tolower String Converts String into lowercase toupper String Converts String into uppercase tostring Number Converts Number into a string Examples SYMBOL DESCRIPTION EXAMPLE RESULT i Wildcard string like compare See below See below len String length x len Hello World 11 substring Substring extraction x substring Hello World 0 5 Hello replace Sal x replace Status Status read P replacement busy busy
25. ression z Arithmetic Relational Logical Bitwise Tags Conditional gt Ek Mathematical gt anes String Constant 2 pi Math Constant PI OPC gt e Math Constant E Ox Hexadecimal Constant Ot Octal Constant Ob Binary Constant Constant Functions 19 Expression Editor User s Manual The Functions menu of the Expression Editor supports constant values including pi e hexadecimal octal and binary formats Examples SYMBOL DESCRIPTION EXAMPLE RESULT pi Melconstant pi segi 3 14159265358979323846 e Math constante _ 2 7182818284590452354 Hexadecimal 0x constant x 0x11 17 ot Octal constant x 0t11 9 Ob Binary constant x 0b11 3 Note The numeric constants pi and e are approximations of their real values The rounded values are shown in the table above Using rounded values for the mathematical constants pi and e may produce in unexpected results For example since the constant pi presented here actually is the rounded number pi the expression such as tan PI N 2 where N is an odd number is considered here as a valid expression Interpreting and Translating Constants The examples below show how values are calculated for the hexadecimal octal and binary constants The Expression Editor conveniently inserts the 0x and Ot and Ob prefixes for you so do not have to recall them Hexadecimal 0x20A 2 1612 0 1611
26. rl A var2 104 0000 0000 0110 1000 shl var1 3 768 0000 0011 0000 0000 shr var1 3 12 0000 0000 0000 1100 var1 97 1111 1111 1001 1111 bittest var1 3 0 0000 0000 0000 0000 Functions The Functions menu options are shown in the figure below edit Expression A Expression y A m4 Arithmetic Relational Logical Biwise Conditional En Mathematical gt gt String gt gt gt Tags Constant OPC Functions Menu Options 12 Creating Expressions Using the Expression Editor Conditional The Conditional function is shown in the figure below Edit Expression 3 lolx Expression z a Ed Arithmetic Relational Logical Bitwise Tags nik if BooleanCondition YaluelfTrue YaluelfFalse Condition Mathematical gt String gt Constant Conditional If Function The symbol if is a conditional statement that uses the following format symbol parameter parameter parameter The if function is used to evaluate an expression and assign a value based on the result of the evaluation The syntax of the if function is as follows result If Condition value1 value2 If condition is TRUE then the result will be value1 If condition is FALSE then the result will be value2 Condition valuet and value2 can be constant values variables process po
27. rtial strings The following table contains examples The first parameter is normally a variable but for this purpose it has been resolved FUNCTION RETURN COMMENTS like mark mark 1 1 The two strings are exactly the same thus the expression returns true like mark Mark 1 0 We have set the comparison to be case sensitive and the case of the two strings does not match thus the expression returns false like mark Mark 0 1 The two strings have different cases but the expression returns true because we have set the string comparison to case insensitive like mark ma 1 1 The constant part of the string is a match The syntax causes the rest of the string to automatically match like mark ma 1 1 The constant part of the string matches The allows any character to exist in that location like mark ma 1 0 The constant part of the string matches The allows any 18 Creating Expressions Using the Expression Editor FUNCTION RETURN COMMENTS character to exist in that location In this case there are not enough to match the length of the string Thus the resolution is mar which does not match mark like mark m rk 1 1 The can be used anywhere in a string This allows m rk to be resolved mark like mark m abc rk 0 1 In this example the square brackets enclose a list of characters that can be used to match the second character
28. sion Modulus Open Parenthesis Close Parenthesis Arithmetic Symbols The symbols and use the following format parameter symbol parameter Where NINA A local variable an OPC tag a constant or another expression SYMBOL or or or or Result The expression results in a number of any type float long etc Examples SYMBOL DESCRIPTION EXAMPLE RESULT Addition vari var2 8 3 11 Subtraction varl var2 8 3 5 hi Multiplication varios var2 8 3 24 Division varl var2 8 3 2 66667 Calculates the remainder varl var2 8 3 2 after division and Gives precedence to parts varl 8 3 2 1 6 of the calculation var2 var3 Relational The Relational menu symbols are shown in the figure below Expression Editor User s Manual Edit Expression loj x Expression z Arithmetic Logical lt Less Than gt Greater Than OK lt Less Than Or Equal gt Greater Than Or Equal Equal To l Not Equal To Bitwise Relational Symbols The symbols lt gt lt gt and use the following format parameter symbol parameter Where INIA A local variable an OPC tag a constant or another expression P S24 10 i lt Or gt or lt or gt Or Or Result The expression results in a Boolean value
29. uality GOOD The quality of an expression is determined through the evaluation of each single tag in the expression Thus if you have multiple tags in an expression and each tag has a different quality the result of the expression i e 192 GOOD 64 BAD or 0 UNCERTAIN corresponds to the quality of the tag with the lowest quality If an expression contains a conditional statement e g if then or else then the result of the expression is affected only by the quality of the branch being executed Consider the following sample expression x if quality Tag1 192 Tag1 Tag2 This expression can be read as follows 21 Expression Editor User s Manual If the quality of Tag1 is GOOD i e 192 then the expression result x is the value of Tag1 In all other cases i e the quality of Tag1 is UNCERTAIN or BAD the expression result x is the value of Tage We can calculate the results for this expression using different qualities for Tagi and Tag2 as shown in the figure below 1 GOOD GOOD Tag 192 GOOD 2 GOOD UNCERTAIN Tagi 192 GOOD 3 GOOD BAD Tag 192 GOOD 4 UNCERTAIN GOOD Tag2 192 GOOD 5 UNCERTAIN UNCERTAIN Tag2 64 UNCERTAIN 6 UNCERTAIN BAD Tag2 0 BAD 7 BAD GOOD Tag2 192 GOOD 8 BAD UNCERTAIN Tag2 64 UNCERTAIN 9 BAD BAD Tag2 0 BAD In cases 1 3 above the quality of Tagi is GOOD and therefore the result of t
30. value 20 may be provided as the string 20 character 2 followed by character 0 This may be lead an incorrect expression evaluation see the String Comparison section above There is a workaround If you add a numerical zero to each of the tags the logic operators will work properly For example x JC N1OPC 1 0 HDQTRS sys2 ad 3 Present Value 0 gt JC N1OPC 1 0 HDQTRS sys2 ad 4 Present Value 0 An alternative way is to change the OPC server so that it sends the strings with a fixed number of digits with leading zeros or to use DataWorX registers for a conversion from a string to a number Some of the functions provided in the Expression Editor use parameters of type numeric When possible the Expression Editor automatically converts the string into a number For example The string 20 can automatically be converted to the number 20 If the string contains alphabetic characters or symbols then the automatic conversion is impossible For example The string 20hello cannot be converted into a number Even if the string contains only numeric characters and valid symbols there may still be cases in which an automatic conversion is not possible For example The string 123 45 23 cannot be converted into a number because it contains two decimal separators Sometimes strings and numbers are mixed in expressions In this case the Expression Editor attempts to convert the string into a number For exampl
31. x or you can use the symbols and functions provided that help you use the proper string syntax when writing expressions The following categories are available e Arithmetic e Relational e Logical e Bitwise e Functions e Tags Strings in Expressions Strings can be used in expressions Constant strings are delimited with double quotation marks For example Hello World Constant strings can also be enclosed between and characters For example Hello World Strings Comparison Expression Editor User s Manual When comparing strings or numeric data coming from the server as strings the comparison is based on the orders of the characters For example the expression x world gt hello evaluates as true because the character w comes after the character h in alphabetical order Sometimes the string comparison may be misleading For example x 20 gt 100 evaluates as true because the character 2 comes after the character 1 in the character table Of course if there were an expectation of a numeric comparison 20 lt 100 and the above expressions might seem to be evaluated incorrectly but they are not Data Type Conversion Expressions allow calculations to be performed on incoming data An OPC server can provide data in one or more data types such as float long integer string etc Some OPC servers provide numeric data as a string For example the numeric

Download Pdf Manuals

image

Related Search

Related Contents

Lennox International Inc. LEGACY C260 User's Manual  Public User Guide  取扱説明書[MC-SU120A] (7.31 MB/PDF)  FLENDER couplings - Service, Support  JK20-680FN Operating Instructions E Instrucciones  DeWalt DW9106 Cordless Saw User Manual  Xilinx UG230 Spartan-3E FPGA Starter Kit Board User Guide  Equip 3m VGA M/F  USER GUIDE  Conditions générales d`utilisation - Télédéclaration  

Copyright © All rights reserved.
DMCA: DMCA_mwitty#outlook.com.