Difference between revisions of "TestIT:Programming Functions"

From Nolek Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
==5.3 Functions Window==
 +
 
The function window encompasses all the codes, which can be inserted in the program. To get information about the function, then, press on the wanted line and use the info button.
 
The function window encompasses all the codes, which can be inserted in the program. To get information about the function, then, press on the wanted line and use the info button.
 
When a function is going to be created, the wanted function can be selected, or if the code is known then it is possible to write it. To get help with filling in the function, the Config button can be selected and it will show the parameters.
 
When a function is going to be created, the wanted function can be selected, or if the code is known then it is possible to write it. To get help with filling in the function, the Config button can be selected and it will show the parameters.
Line 5: Line 7:
 
==5.3.1 Functions==
 
==5.3.1 Functions==
 
===If===
 
===If===
 +
 
'''Description:''' <br />
 
'''Description:''' <br />
 
Evaluates a statement and continues if true and skips if it is not true. It compares two values and is always used together with EndIf.
 
Evaluates a statement and continues if true and skips if it is not true. It compares two values and is always used together with EndIf.
Line 277: Line 280:
 
|}
 
|}
  
==5.3.2 Misc (Miscellaneous)==
+
[[TestIT:Programming#5.3_Commands|Back to Programming - Commands]]
===Move===
 
'''Description:''' <br />
 
It will move a value into a symbol.
 
 
 
'''Code example:'''
 
:<code>Misc.Move(_IN01,2)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Symbol
 
|Int symbol or Double symbol
 
|Symbol to move value to
 
|-
 
|Value
 
|Int, Double, Int symbol or Double symbol
 
|Value to move into symbol
 
|}
 
 
 
===Set===
 
'''Description:''' <br />
 
It will set symbols in symbol array to true.
 
 
 
'''Code example:'''
 
:<code>Misc.Set(_B01;_B02;_B03)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Bool Symbols
 
|Symbol array
 
|Bool symbols to set
 
|}
 
 
 
===Reset===
 
'''Description:''' <br />
 
It will reset symbols in symbol array to false.
 
 
 
'''Code example:'''
 
:<code>Misc.Reset(_B01;_B02;_B03)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Bool Symbols
 
|Symbol array
 
|Bool symbols to reset
 
|}
 
 
 
===SetUniqueID===
 
'''Description:''' <br />
 
It will set the Unique ID to the value. The Unique ID will be logged together with results in the database.
 
 
 
'''Code example:'''
 
:<code>Misc.SetUniqueID(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Unique ID
 
|String symbol
 
|Unique ID
 
|}
 
 
 
===GetUniqueID===
 
'''Description:''' <br />
 
It will return a Unique ID for the Unique ID Device. The Unique ID will be logged together with results in the database.
 
 
 
'''Code example:'''
 
:<code>Misc.GetUniqueID(Unique,_ST01,_B01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Device name
 
|String or String symbol
 
|The device name
 
|-
 
|Unique ID
 
|String symbol
 
|Receive the unique ID from the device
 
|-
 
|Set as Object ID
 
|Bool symbol
 
|If true, the Object ID in the production will be set to this unique ID. If Object ID is selected, max length is 50
 
|}
 
 
 
===AddResult===
 
'''Description:''' <br />
 
It will add a result to the production window. If LogToDB is set to true, the result will be logged to the database as well.
 
All the results which are logged in the database can be found in Report/Results.
 
 
 
'''Code example:'''
 
:<code>Misc.AddResult(1010,"Leak result","Result from S9",_ST01,LeakResult,"Pa",0,2,3,ObjectStatus,AlwON)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Number
 
|Int or Int symbol
 
|Result number
 
|-
 
|Result name
 
|String or String symbol
 
|Result name (Max 50 char)
 
|-
 
|Description Short
 
|String or String symbol
 
|Description Short (Max 50 char)
 
|-
 
|Description Long
 
|String or String symbol
 
|Description Long (Max 250 char, is not shown on screen)
 
|-
 
|Result Symbol
 
|Number symbol
 
|Symbol value will be logged as result
 
|-
 
|Unit
 
|String or String symbol
 
|String to describe the unit
 
|-
 
|Min
 
|Int, Double, Int symbol or Double symbol
 
|Minimum value
 
|-
 
|Max
 
|Int, Double, Int symbol or Double symbol
 
|Maximum value
 
|-
 
|Icon
 
|Int
 
|Select Icon (0 = None, 1 = Info, 2 = Error, 3 = Success, 4 = Warning)
 
|-
 
|Object Status
 
|Bool symbol
 
|Symbol value will be logged as overall result
 
|-
 
|LogToDB
 
|Bool symbol
 
|Log to database if true
 
|}
 
 
 
===AddResultValidate===
 
'''Description:''' <br />
 
It will add a result to the production window and validate OK/NOK. If LogToDB is set to true, the result will be logged to the database as well. It will show the OK/NOK icon according to the validation and set the object status as well.
 
All the results which are logged in the database can be found in Report/Results.
 
 
 
'''Code example:'''
 
:<code>Misc.AddResultValidate(1010,"Leak result","Result from S9",_ST01,LeakResult,"Pa",0,2,3,2,ObjectStatus,AlwON)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Number
 
|Int or Int symbol
 
|Result number
 
|-
 
|Result name
 
|String or String symbol
 
|Result name (Max 50 char)
 
|-
 
|Description Short
 
|String or String symbol
 
|Description Short (Max 50 char)
 
|-
 
|Description Long
 
|String or String symbol
 
|Description Long (Max 250 char, is not shown on screen)
 
|-
 
|Result Symbol
 
|Number symbol
 
|Symbol value will be logged as result
 
|-
 
|Unit
 
|String or String symbol
 
|String to describe the unit
 
|-
 
|Min
 
|Int, Double, Int symbol or Double symbol
 
|Minimum value
 
|-
 
|Max
 
|Int, Double, Int symbol or Double symbol
 
|Maximum value
 
|-
 
|IconOK
 
|Int
 
|Select Icon (0 = None, 1 = Info, 2 = Error, 3 = Success, 4 = Warning)
 
|-
 
|IconNOK
 
|Int
 
|Select Icon (0 = None, 1 = Info, 2 = Error, 3 = Success, 4 = Warning)
 
|-
 
|Object Status
 
|Bool symbol
 
|Symbol value will be logged as overall result
 
|-
 
|LogToDB
 
|Bool symbol
 
|Log to database if true
 
|}
 
 
 
===ValidateObject===
 
'''Description:''' <br />
 
It will validate the status of the actual object and show the Icons Good or Bad in the production window.
 
 
 
'''Code example:'''
 
:<code>Misc.ValidateObject(ValidationResult,ObjectResult,3,Retest,Lamp01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Int symbol
 
|Symbol to receive result [1:Retest,2:Can retest,3:Max retest,4:Failed,5:TestOK]
 
|-
 
|Object result
 
|Bool symbol
 
|Symbol representing the object status
 
|-
 
|Max retest
 
|Int or Int symbol
 
|Max retest count
 
|-
 
|Actual test count
 
|Int symbol
 
|Symbol to hold actual retest count
 
|-
 
|Object Failed
 
|Bool symbol
 
|Set true if failed. Can turn on indicator if failed
 
|}
 
 
 
===IsNewProduct===
 
'''Description:''' <br />
 
It will return a Boolean whether the current product is running for the first time or not
 
 
 
'''Code example:'''
 
:<code>Misc.IsNewProduct(_B01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|IsNewProduct
 
|Bool symbol
 
|Symbol for is new product
 
|}
 
 
 
===IsDeviceActive===
 
'''Description:''' <br />
 
It will check if the device is set to active.
 
 
 
'''Code example:'''
 
:<code>Misc.IsDeviceActive(_B01, _ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Bool symbol
 
|True if device is active
 
|-
 
|Device name
 
|String or String symbol
 
|Name of the device
 
|}
 
 
 
===GetBatchNumber===
 
'''Description:''' <br />
 
It will return the current batch number.
 
 
 
'''Code example:'''
 
:<code>Misc.GetBatchNumber(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|String symbol
 
|Receive current batch number
 
|}
 
 
 
===GetProductName===
 
'''Description:''' <br />
 
It will return the current product name.
 
 
 
'''Code example:'''
 
:<code>Misc.GetProductName(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|String symbol
 
|Receive current product name
 
|}
 
 
 
===GetCurrentLanguage===
 
'''Description:''' <br />
 
It will return the language TestIT is set to.
 
 
 
'''Code example:'''
 
:<code>Misc.GetCurrentLanguage(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|String symbol
 
|Get current language code
 
|}
 
 
 
===GetTestCountOK===
 
'''Description:''' <br />
 
It will return the current OK test count.
 
 
 
'''Code example:'''
 
:<code>Misc.GetTestCountOK(_IN01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Int symbol
 
|Receive current OK test count
 
|}
 
 
 
===GetTestCountNOK===
 
'''Description:''' <br />
 
It will return the current NOK test count.
 
 
 
'''Code example:'''
 
:<code>Misc.GetTestCountNOK(_IN01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Int symbol
 
|Receive current NOK test count
 
|}
 
 
 
===GetUserName===
 
'''Description:''' <br />
 
It will return the username of the active user.
 
 
 
'''Code example:'''
 
:<code>Misc.GetUserName(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|String symbol
 
|Receive current user name
 
|}
 
 
 
===GetGuideObjectID===
 
'''Description:''' <br />
 
It will return the object ID from the current guide.
 
 
 
'''Code example:'''
 
:<code>Misc.GetGuideObjectID(_ST01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|String symbol
 
|Receive current guide objectID
 
|}
 
 
 
===StartFlash===
 
'''Description:''' <br />
 
It will start flashing a bool symbol, and continues the code.
 
 
 
'''Code example:'''
 
:<code>Misc.StartFlash(_B01,500,1000,MS,_B02)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Symbol to flash
 
|Bool symbol
 
|Symbol to flash
 
|-
 
|On time
 
|Int or Int symbol
 
|Length of on/set state
 
|-
 
|Off time
 
|Int or Int symbol
 
|Length of off/reset state
 
|-
 
|Time unit
 
|String
 
|Time unit
 
|-
 
|Stop flash symbol
 
|Bool symbol
 
|Set symbol to stop flash
 
|}
 
 
 
==5.3.3 Display==
 
===OpAddSymbol===
 
'''Description:''' <br />
 
It will add a symbol or symbols to the operator display.
 
 
 
'''Code example:'''
 
:<code>Display.OpAddSymbol(_ST01;_B01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Symbol Array
 
|Symbol array
 
|Symbol or symbol array to add to the operator display
 
|}
 
 
 
===OpRemoveSymbol===
 
'''Description:''' <br />
 
It will remove symbol or symbols to operator display.
 
 
 
'''Code example:'''
 
:<code>Display.OpRemoveSymbol(_ST01;_B01)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Symbol Array
 
|Symbol array
 
|Symbol or symbol array to remove from the operator display
 
|}
 
 
 
===OpClear===
 
'''Description:''' <br />
 
It will clear operator display.
 
 
 
'''Code example:'''
 
:<code>Display.OpClear()</code>
 
 
 
''No parameters''
 
 
 
===UpAddButton===
 
'''Description:''' <br />
 
It will add a button to the user prompt.
 
 
 
'''Code example:'''
 
:<code>Display.UpAddButton(_B01;_B02)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Bool Symbols
 
|Symbol array
 
|Bool symbols to add to the user prompt
 
|}
 
 
 
===UpShow===
 
'''Description:''' <br />
 
It will display the user prompt.
 
 
 
'''Code example:'''
 
:<code>Display.UpShow(_B01,"Header","Text for info",1)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Bool symbol
 
|True when command is done
 
|-
 
|Header
 
|String or String symbol
 
|Header to display
 
|-
 
|Text
 
|String or String symbol
 
|Text to display
 
|-
 
|Icon
 
|Int
 
|Select Icon (Icon: 1 = Message; 2= Alert; 3 = Question)
 
|}
 
 
 
===UpScanShow===
 
'''Description:''' <br />
 
It will display the user scan prompt.
 
 
 
'''Code example:'''
 
:<code>Display.UpScanShow(_B01,_ScannedValue,"Header","Text for info",1)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Result
 
|Bool symbol
 
|True when command is done
 
|-
 
|ScannedValue
 
|String symbol
 
|Symbol to hold the scanned value
 
|-
 
|Header
 
|String or String symbol
 
|Header to display
 
|-
 
|Text
 
|String or String symbol
 
|Text to display
 
|-
 
|Icon
 
|Int
 
|Select Icon (Icon: 1 = Message; 2= Alert; 3 = Question)
 
|}
 
 
 
===Message===
 
'''Description:''' <br />
 
It will set a text message in the production window.
 
 
 
'''Code example:'''
 
:<code>Display.Message(1010,"Pressure OK",3)</code>
 
 
 
{| class="wikitable"
 
!colspan="3"|Parameters
 
|-
 
|'''Parameter'''
 
|'''Type'''
 
|'''Description'''
 
|-
 
|Message number
 
|Int or Int symbol
 
|Message number
 
|-
 
|Message
 
|String or String symbol
 
|Symbol or string message to display
 
|-
 
|Icon
 
|Int
 
|Select Icon (0 = None, 1 = Info, 2 = Error, 3 = Success, 4 = Warning)
 
|}
 

Latest revision as of 15:14, 11 September 2019

5.3 Functions Window

The function window encompasses all the codes, which can be inserted in the program. To get information about the function, then, press on the wanted line and use the info button. When a function is going to be created, the wanted function can be selected, or if the code is known then it is possible to write it. To get help with filling in the function, the Config button can be selected and it will show the parameters. In symbol handler, it is possible to add a symbol, and it is also possible to insert a symbol in the function. To insert a symbol, just double-click on the wanted symbol.

5.3.1 Functions

If

Description:
Evaluates a statement and continues if true and skips if it is not true. It compares two values and is always used together with EndIf.

Code example:

Function.If(_B01,=,1)
'Code will only be executed if _B01 = 1
Function.EndIf()
Parameters
Parameter Type Description
Criteria1 Number or number symbol Value 1
Sign Sign Select sign to use for comparison. Must be (<,>, <>,=, >=, ⇐)
Criteria2 Number or number symbol Value 2

IfMinMax

Description:
Evaluates a value against a min. and max. It continues if the value is between the min. and max, and skips if it is not.

Code example:

Function.IfMinMax(_IN01,1,5)
'Code will only be executed if _IN01 is between 1 and 5
Function.EndIf()
Parameters
Parameter Type Description
Value/Symbol to compare Number or number symbol Value 1
Min value Number or number symbol Minimum value
Max value Number or number symbol Maximum value

EndIf

Description:
It is used together with If or IfMinMax. It will stop the if code.

Code example:

Function.If(_B01,=,1)
'Code will only be executed if _B01 = 1
Function.EndIf()

No parameters

Wait

Description:
It will wait until the time has run out or criteria is met.

Code example:

Function.Wait(_D01,>,10,30,S,_TO01)
Function.If(_TO01, =, 1)
'Code will enter if wait times out
Function.EndIf()
Parameters
Parameter Type Description
Criteria1 Number or number symbol Value 1
Sign Sign Select sign to use for comparison. Must be (<,>, <>,=, >=, ⇐)
Criteria2 Number or number symbol Value 2
Timeout Int or Int symbol Time before command times out
Time unit String Select the time unit from the list
Timeout active Bool symbol True if wait command times out

Sub

Description:
It is used to split the program up in smaller programs. The main sub is the sub which TestIT always starts in. The program cannot run if there is no main sub. It must always end with an EndSub.

Code example:

Function.Sub(1000)
'Execute this sub routine
Function.EndSub()
Parameters
Parameter Type Description
Sub name String Name of the sub. Must be unique in the program

EndSub

Description:
It is the end mark of a sub.

Code example:

Function.Sub(1000)
'Execute this sub routine
Function.EndSub()

No parameters

GoSub

Description:
It will jump to a specific sub.

Code example:

Function.GoSub(1000)
Parameters
Parameter Type Description
Sub name String Name of the sub.

Label

Description:
It will set a fix point to jump to.

Code example:

Function.Label(startLoop)
Parameters
Parameter Type Description
Label name String Name of the label. Must be unique within the sub

GoLabel

Description:
It will jump to a specific label.

Code example:

Function.GoLabel(startLoop)
Parameters
Parameter Type Description
Label name String Name of the label

Delay

Description:
It will delay the program, for a specified time.

Code example:

Function.Delay(30,S)
Parameters
Parameter Type Description
Delay time Int or Int symbol Delay time
Time unit String Time unit

StopTest

Description:
It will go to EndSub() in main sub.

Code example:

Function.StopTest()

No parameters

NewPart

Description:
It will clear the production window, the results, and prepare the production to run a new product.

Code example:

Function.NewPart()

No parameters
The command is often used together with a label that jumps to the beginning of the program.

Code example:

Function.NewPart()
Function.GoLabel(lbl_newPart)

IsValue

Description:
It will convert a symbol to a numeric value if it is possible.

Code example:

Function.IsValue(_D01,_B01,_ST01)
Parameters
Parameter Type Description
Result Double symbol Value or symbol to use
IsValue Bool symbol Time unit
ValueToTest String or String symbol String value to test

Back to Programming - Commands