Difference between revisions of "NVGate Macro"

From OROS Wiki
Jump to navigation Jump to search
(40 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[category:NVGate]]
===Tutorial===
===Tutorial===
A macro is a powerful automation tool of NVGate allowing to create your own programs from a simple graphic interface, and doesn't require any software development skills.<br>
A macro is a powerful automation tool of NVGate allowing to create your own programs from a simple graphic interface, and doesn't require any software development skills.<br>
Line 6: Line 6:


====Creating a new Macro====
====Creating a new Macro====
Go in the [[NVGate Ribbons: Tools Tab|"Tools" tab of the NVGate ribbon]], and select "New" in the Macro section :  
Go in the [[NVGate Ribbons: Tools Tab|"Automation" tab of the NVGate ribbon]], and select "New" in the Macro group:  


[[Image:NewMacro.png|framed|none]]
[[File:Macro_new_2022.JPG|700px]]


====Add a parameter====
====Add a parameter====
Line 36: Line 36:
In order to loop as long as needed, we will use a "while" loop that iterates as long as "EnableMacro" is set on "True".  
In order to loop as long as needed, we will use a "while" loop that iterates as long as "EnableMacro" is set on "True".  


The while loop is an Algorithmic command, and will be added the same way as the Affectation command. Click on "End of Macro", click on the [[Image:AlgoCommandIcon.png]] icon and select "while loop. Then set the loop as follows :  
The while loop is an Algorithmic command, and will be added the same way as the Affectation command. Click on "End of Macro", click on the [[Image:AlgoCommandIcon.png]] icon and select "while loop". Then set the loop as follows :  
[[Image:WhileLoop.png|600px|none]]
[[Image:WhileLoop.png|600px|none]]


Line 66: Line 66:
You can stop the macro anytime by using the "pause" option of the macro editor [[Image:PauseMacro.png]] and set the "EnableMacro" parameter on "False".
You can stop the macro anytime by using the "pause" option of the macro editor [[Image:PauseMacro.png]] and set the "EnableMacro" parameter on "False".


We advice to use the [[NVGate Control Panel|control pannel]] to launch the macro in NVGate.
====Launch the Macro====
Use the [[NVGate Control Panel|control panel]] to launch the macro in NVGate.
 
====Execute a .exe in a macro====
This allows you to launch an external .exe or .bat. with a macro.
<br>
[[File:macro_link.png]]
 
Process:<br>
- Put your .exe in C:\OROS\NVGate data\Links<br>
- click on "record on line buton".
[[File:RecordOnLine.png]]<br>
- Select the .exe using the [[NVGate_Ribbons:_Tools_Tab#Link|NVGate Link]]<br>
- stop the "record on line".<br>
 
===Macros group===
 
<Youtube>https://www.youtube.com/watch?v=6IIKsHwZi2Y</Youtube>
 
The macros group is used to create/manage macros that perform automatically recurrent operations.


===Parameters of the Macros===
[[Image:Reports_Tools_Ribbons_58.png|200px|none]]
====Macros Tab====
The macro Tab is used to create/manage macros that perform automatically recurrent operations...


[[Image:Reports_Tools_Ribbons_58.png|framed|none]]
{|border="0" cellspacing="0" cellpadding="4" width="100%" align="center"
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_59.png|30px|none]]
|'''Manage''': Open the [[NVGate_Macro#Macros_Manager|macros manager]].


=====Manage=====
|-valign = "top"
[[Image:Reports_Tools_Ribbons_59.png|framed|none]]
|[[Image:Reports_Tools_Ribbons_62.png]]  
|'''New''': Create a new macro and load it in the macro editor. This menu is disabled if another macro is being edited.


Open the macro manager. Display the macro list and the associated hot-keys. A hot-key is a shortcut to run the macro.
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_75.png]]
|'''Save''': Save the macro currently edited. Only available if a macro is being edited.


[[Image:Reports_Tools_Ribbons_60.png|framed|none]]
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_76.png]]
|'''Save as''': Save the macro currently edited with a new name. Only available if a macro is being edited.


Note that the three first hot keys are automatically assigned in the "Macro" menu from the OR38/OR36 Front Panel, labeled as "0", "1" and "2".
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_77.png]]
|'''Record''': Start recording the user action on the software. Each recorded action is appended to the Macro and will be a visible line in the macro editor.
 
Prior to start the macro recording user must enter the macro name and the recording mode:


* '''Edit: '''Edits the macro selected. Available if no macro is being edited, recorded, or executed.
* Macro name: Name of the macro.
* '''New: '''Creates a new macro. The new macro is opened in the editor. Available if no macro is being edited, recorded, or executed.
* Recording mode:
* '''Delete: '''Deletes the macro selected.
 
* '''Run: '''Runs the macro selected. Available if no macro is being executed.
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="70%"
* '''Properties: '''Edits macro properties (name, read-only flag, and assigned hot-key). Available if no macro is being edited, recorded, or executed.  
|'''Mode'''
|'''Description'''
 
|-
|On-line
|Commands corresponding to user actions are recorded in the macro.
 
|-
|Off-line
|User actions have no effect. Commands corresponding to user actions are recorded in the macro.
 
|}
 
''Note: Click on the record button to stop recording the macro. The macro is saved with the name specified in the "Record" dialog.''
 
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_78.png]]
|'''Pause record''': Pause the ongoing macro record. User actions are not yet recorded. Available if macro is being recorded.
 
Useful to prepare the system for an action to be recorded without filling the editor with unwanted lines.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_79.png]]
|'''Stop run''': Stop the execution of the running macro. Available if macro is running.
 
|}<br clear="all">
 
====Macros Manager====
 
Display the macros list and the associated hot-keys. A hot-key is a shortcut to run the macro.<br><br>
 
[[Image:Reports_Tools_Ribbons_60.png|300px|none]]
 
''Note: the three first hot keys are automatically assigned in the "Macro" menu from the OR38/OR36 Front Panel, labeled as "0", "1" and "2".''
 
* '''Edit: '''Edit the macro selected. Available if no macro is being edited, recorded, or executed.
* '''New: '''Create a new macro. The new macro is opened in the editor. Available if no macro is being edited, recorded, or executed.
* '''Delete: '''Delete the macro selected.
* '''Run: '''Run the macro selected. Available if no macro is being executed.
* '''Properties: '''Edit macro properties (name, read-only flag, and assigned hot-key). Available if no macro is being edited, recorded, or executed.  


[[Image:Reports_Tools_Ribbons_61.png|framed|none]]
[[Image:Reports_Tools_Ribbons_61.png|framed|none]]


* '''Name:''' Changes the name of the macro.
* '''Name:''' Change the name of the macro.
* '''Read-only:''' If the macro is read-only, the macro can be loaded to the macro editor but can<nowiki>’</nowiki>t be modified.
* '''Read-only:''' If the macro is read-only, the macro can be loaded to the macro editor but can<nowiki>’</nowiki>t be modified.
* '''Hot key:''' Defines a hot-key to run the macro.
* '''Hot key:''' Define a hot-key to run the macro.
* '''Assigned macro:''' Macro associated with the hot-key selected in "Hot-key" combo-box. If hot-key selected is already assigned, a message is generated when the window is closed, requesting confirmation of the new assignment.
* '''Assigned macro:''' Macro associated with the hot-key selected in "Hot-key" combo-box. If hot-key selected is already assigned, a message is generated when the window is closed, requesting confirmation of the new assignment.
=====New=====
[[Image:Reports_Tools_Ribbons_62.png]] Creates a new macro and loads it in the macro editor. This menu is disabled if another macro is being edited.


* '''Properties [[Image:Reports_Tools_Ribbons_63.jpg]]: '''Opens a dialog box intended to edit macro properties. Macro properties consist of a set of parameters of different types, which can be used to define macro command properties.
===Macro Editor===
This command is enabled if the macro item is selected in the macro tree.
 
[[File:Macro_Editor_2022.JPG|400px]]
 
{|border="0" cellspacing="0" cellpadding="4" width="100%" align="center"
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_63.jpg]]
|'''Properties''': Open a dialog box intended to edit [[NVGate_Macro#Macro_properties|macro properties]].
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_66.jpg]]
|'''Delete''' : Delete the selected command in the macro tree. If the macro selected contains a set of commands (for example a loop command), a dialog box appears in order to confirm command removal. If removal is confirmed, the command and all commands it contains are deleted.
This command is enabled if the macro is not running and it is not read-only.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_67.jpg]]
|'''Run''': Run the macro from the current command (indicated by execution pointer) to the next breakpoint. If no breakpoint follows, the execution goes to the end of the macro. Enabled if the macro is not running.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_68.jpg]]
|'''Pause''': Stop macro execution. The command running is completed, and then execution stops.
This command is enabled when the macro is running only.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_69.jpg]]
|'''Step next''': Run current command (indicated by execution pointer). This command is enabled when the macro is not running.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_70.jpg]]
|'''Reset''': If the macro is running, stop the execution, and then set the execution pointer to the first command of the macro.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_71.jpg]]
|'''Record on-line''': Record commands in the macro. The record on-line mode applies the user actions. The commands corresponding to actions are recorded and inserted in the macro before the selected command. This command is enabled if the macro is not running and it is not read-only.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_72.jpg]]
|'''Record off-line''': Record commands in the macro. The record off line mode applies the user actions only when the macro will start. The commands corresponding to actions are recorded and inserted in the macro before the selected command. This command is enabled if the macro is not running and it is not read-only.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_73.jpg]]
|'''Insert an algorithmic command''': Insert an [[NVGate_Macro#Algorithmic_commands|algorithmic command]] before the selected command. This command is enabled if the macro is not running and it is not read-only.
 
|-valign = "top"
|[[Image:Reports_Tools_Ribbons_74.jpg]]
|'''Save''': Save the macro.
 
|}<br clear="all">
 
====Macro properties====
Macro properties consist of a set of parameters of different types, which can be used to define macro command properties. This command is enabled if the macro item is selected in the macro tree.


[[Image:Reports_Tools_Ribbons_64.png|framed|none]]
[[Image:Reports_Tools_Ribbons_64.png|framed|none]]
Line 110: Line 226:
* '''Type''': type of the parameter. The different types available are
* '''Type''': type of the parameter. The different types available are


{|border="2" cellspacing="0" cellpadding="4" width="100%"
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="100%"
|'''Type'''
|'''Type'''
|'''Description'''
|'''Description'''
Line 137: Line 253:


* '''Value''': default value of parameter
* '''Value''': default value of parameter
* '''Edit: '''Opens the "Parameter properties" dialog box, which is used to edit the parameter selected in parameters list. It is possible to change the name, the type, or the default value of the parameter. If the parameter is used by one or more macro commands, the type can<nowiki>’</nowiki>t be edited (the "Type" combo-box is disabled).
* '''Edit: '''Open the "Parameter properties" dialog box, which is used to edit the parameter selected in parameters list. It is possible to change the name, the type, or the default value of the parameter. If the parameter is used by one or more macro commands, the type can<nowiki>’</nowiki>t be edited (the "Type" combo-box is disabled).
* '''Remove: '''Removes the selected parameter. If the parameter is used by one or more macro commands, the parameter is not removed and an error message is generated.
* '''Remove: '''Removes the selected parameter. If the parameter is used by one or more macro commands, the parameter is not removed and an error message is generated.


* '''Delete''' [[Image:Reports_Tools_Ribbons_66.jpg]]: Deletes the selected command in the macro tree. If the macro selected contains a set of commands (for example a loop command), a dialog box appears in order to confirm command removal. If removal is confirmed, the command and all commands it contains are deleted.
====Algorithmic commands====
This command is enabled if the macro is not running and it is not read-only.
=====Affectation=====
 
* '''Run''' [[Image:Reports_Tools_Ribbons_67.jpg]]: Runs the macro from the current command (indicated by execution pointer) to the next breakpoint. If no breakpoint follows, the execution goes to the end of the macro.
Enable if the macro is not running.
 
* '''Pause''' [[Image:Reports_Tools_Ribbons_68.jpg]]: Stops macro execution. The command running is completed, and then execution stops.
This command is enabled when the macro is running only.
 
* '''Step next''' [[Image:Reports_Tools_Ribbons_69.jpg]]: Runs current command (indicated by execution pointer).
This command is enabled when the macro is not running.
 
* '''Reset''' [[Image:Reports_Tools_Ribbons_70.jpg]]: If the macro is running, stops the execution, and then sets the execution pointer to the first command of the macro.
* '''Record on-line''' [[Image:Reports_Tools_Ribbons_71.jpg]]: Records commands in the macro. The record on-line mode applies the user actions. The commands corresponding to actions are recorded and inserted in the macro before the selected command.
This command is enabled if the macro is not running and it is not read-only.
 
* '''Record off-line''' [[Image:Reports_Tools_Ribbons_72.jpg]]: Records commands in the macro. The record off line mode applies the user actions only when the macro will start. The commands corresponding to actions are recorded and inserted in the macro before the selected command.
This command is enabled if the macro is not running and it is not read-only.
 
* '''Insert an algorithmic command''' [[Image:Reports_Tools_Ribbons_73.jpg]]: Inserts an algorithmic command before the selected command.
This command is enabled if the macro is not running and it is not read-only.
 
* '''Save''' [[Image:Reports_Tools_Ribbons_74.jpg]]: Saves the macro.
 
=====Save=====
[[Image:Reports_Tools_Ribbons_75.png]] Saves the macro currently edited. Only available if a macro is being edited.
 
=====Save As=====
[[Image:Reports_Tools_Ribbons_76.png]] Saves the macro currently edited with a new name. Only available if a macro is being edited.
 
=====Record=====
[[Image:Reports_Tools_Ribbons_77.png]] Start recording the user action on the software. Each recorded action is appended to the Macro and will be a visible line in the macro editor.
 
Prior to start the macro recording user must enter the macro name and the recording mode:
 
* Macro name: Name of the macro.
* Recording mode:
 
{|border="2" cellspacing="0" cellpadding="4" width="70%"
|Mode
|Description
 
|-
|On-line
|Commands corresponding to user actions are recorded in the macro.
 
|-
|Off-line
|User actions have no effect. Commands corresponding to user actions are recorded in the macro.
 
|}
 
Note: Click on the record button to stop recording the macro. The macro is saved with the name specified in the "Record" dialog.
 
=====Pause record=====
[[Image:Reports_Tools_Ribbons_78.png]] Pause the ongoing macro record. User actions are not yet recorded. Available if macro is being recorded.
 
Useful to prepare the system for an action to be recorded without filling the editor with unwanted lines.
 
=====Stop run=====
[[Image:Reports_Tools_Ribbons_79.png]] Stops the execution of the running macro. Available if macro is running
 
=====Algorithmic commands=====
======Affectation======
   
   


Line 210: Line 264:
Sets a value to a parameter. The new value can be defined by a parameter.
Sets a value to a parameter. The new value can be defined by a parameter.


======Break======
=====Break=====


[[Image:macro_break.png|border|500px]]
[[Image:macro_break.png|border|500px]]
Line 216: Line 270:
Used to exit a loop. It can be used inside a "for" loop to stop before the end of the iteration, inside a "while" loop to exit the loop without fulfilling the condition. It is the only way to exit a "Periodic loop".
Used to exit a loop. It can be used inside a "for" loop to stop before the end of the iteration, inside a "while" loop to exit the loop without fulfilling the condition. It is the only way to exit a "Periodic loop".


======Call Macro======
=====Call Macro=====
Calls another macro.
Calls another macro.


Line 223: Line 277:
The only parameter is the name of the macro that is called. The body of the command is divided into three steps in order to exchange parameters between the calling macro and the called macro.
The only parameter is the name of the macro that is called. The body of the command is divided into three steps in order to exchange parameters between the calling macro and the called macro.


======Comment======
=====Comment=====
The purpose of this command is to facilitate understanding of the macro. It is used to add a comment line to the body of the macro.
The purpose of this command is to facilitate understanding of the macro. It is used to add a comment line to the body of the macro.


Line 230: Line 284:
The only parameter is the comment.
The only parameter is the comment.


======"For" loop======
====="For" loop=====


[[Image:macro_for_loop.png|border|500px]]
[[Image:macro_for_loop.png|border|500px]]
Line 236: Line 290:
Runs a set of commands several times. The number of iterations can be defined by an integer value or by an integer parameter.
Runs a set of commands several times. The number of iterations can be defined by an integer value or by an integer parameter.


======Get Current Time======
=====Get Current Time=====
This command retrieves the time and stores it in a string parameter. This string may be use to send a trace, to create a measurement name...
This command retrieves the time and stores it in a string parameter. This string may be use to send a trace, to create a measurement name...


Line 243: Line 297:
The "Time format" specifies the way in which the time should be written. "Date", "Time" and "Date and Time" use the regional settings of the host computer while the three other formats are fixed formats.
The "Time format" specifies the way in which the time should be written. "Date", "Time" and "Date and Time" use the regional settings of the host computer while the three other formats are fixed formats.


======Get Macro Parameter======
=====Get Macro Parameter=====
Gets the value of a parameter of a called macro. This command must be inserted between the "Exit macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.
Gets the value of a parameter of a called macro. This command must be inserted between the "Exit macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.


Line 256: Line 310:
In this example, the command gets the value of the parameter nNumberOfLoop of the macro CheckInput and sets this value to the parameter nCount of the calling macro.
In this example, the command gets the value of the parameter nNumberOfLoop of the macro CheckInput and sets this value to the parameter nCount of the calling macro.


======Group======
=====Group=====
The purpose of this command is to facilitate understanding of the macro. It creates a branch that contains a set of instructions. It has no effect during execution, but it helps to organize the macro and facilitates copying and pasting, since all commands are copied at once.
The purpose of this command is to facilitate understanding of the macro. It creates a branch that contains a set of instructions. It has no effect during execution, but it helps to organize the macro and facilitates copying and pasting, since all commands are copied at once.


Line 263: Line 317:
[[Image:Reports_Tools_Ribbons_89.png|border|none]]
[[Image:Reports_Tools_Ribbons_89.png|border|none]]


======If…Then…======
=====If…Then…=====


[[Image:macro_if_then.png|border|500px]]
[[Image:macro_if_then.png|border|500px]]
Line 296: Line 350:
* '''Alarm results'''
* '''Alarm results'''


[[Image:Reports_Tools_Ribbons_96.png|framed|none]]
[[Image:Reports_Tools_Ribbons_96.png|600px|none]]


* '''Advanced alarm: '''This condition is available only when at least one alarm on a double template result has been declared.
* '''Advanced alarm: '''This condition is available only when at least one alarm on a double template result has been declared.
Line 306: Line 360:
[[Image:Reports_Tools_Ribbons_98.png|framed|none]]
[[Image:Reports_Tools_Ribbons_98.png|framed|none]]


{|border="2" cellspacing="0" cellpadding="4" width="100%" align="center"
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="70%" align="center"
|'''Operator'''
|'''Operator'''
|'''Test'''
|'''Test'''
Line 401: Line 455:
[[Image:Reports_Tools_Ribbons_99.png|framed|none]]
[[Image:Reports_Tools_Ribbons_99.png|framed|none]]


{|border="2" cellspacing="0" cellpadding="4" width="100%" align="center"
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="70%" align="center"
|'''Operator'''
|'''Operator'''
|'''Test'''
|'''Test'''
Line 494: Line 548:
|}<br clear="all">
|}<br clear="all">


======Incrementation======
=====Incrementation=====


[[Image:macro_incrementation.png|border|500px]]
[[Image:macro_incrementation.png|border|500px]]
Line 504: Line 558:
Available if one or more integer or float parameter is defined.
Available if one or more integer or float parameter is defined.


======Make String======
=====Make String=====
Command used to create a string.
Command used to create a string.


Line 515: Line 569:
"Add to existing string" is a Boolean parameter that indicates if the second parameter replaces or is added to first one. If the value is false, the command behaves like the Affectation command
"Add to existing string" is a Boolean parameter that indicates if the second parameter replaces or is added to first one. If the value is false, the command behaves like the Affectation command


======Message box======
=====Message box=====


[[Image:macro_message_box.png|border|500px]]
[[Image:macro_message_box.png|border|500px]]
Line 523: Line 577:
When the command is executed, the box is displayed. A click on one of the buttons closes the message box and sets the Boolean parameter value.
When the command is executed, the box is displayed. A click on one of the buttons closes the message box and sets the Boolean parameter value.


======Periodic loop======
=====Periodic loop=====


[[Image:macro_periodic_loop.png|border|500px]]
[[Image:macro_periodic_loop.png|border|500px]]
Line 529: Line 583:
Runs a set of commands at each interval of time specified in the "Time lap" parameter. The time lap is specified in seconds, the "Break" command must be used to exit the loop.
Runs a set of commands at each interval of time specified in the "Time lap" parameter. The time lap is specified in seconds, the "Break" command must be used to exit the loop.


======Set Macro parameter======
=====Set Macro parameter=====
Sets the parameter value of a called macro. This command must be inserted between the "Open macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.
Sets the parameter value of a called macro. This command must be inserted between the "Open macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.


Line 550: Line 604:
The message generated in the top of the dialog box can be defined in the "command properties". A control is used to edit the parameter value. A click on the OK button changes the parameter value, and closes the dialog box. A click on the Cancel button closes the dialog box without changing parameter value.
The message generated in the top of the dialog box can be defined in the "command properties". A control is used to edit the parameter value. A click on the OK button changes the parameter value, and closes the dialog box. A click on the Cancel button closes the dialog box without changing parameter value.


======Set Parameter Value======
=====Set Parameter Value=====


[[Image:macro_set_parameter_value.png|border|500px]]
[[Image:macro_set_parameter_value.png|border|500px]]


======Trace======
=====Trace=====
Command used to send a message in the log window.
Command used to send a message in the log window.


Line 563: Line 617:
"Play sound" is used to play a sound when the message is sent. The host computer must have speakers connected.
"Play sound" is used to play a sound when the message is sent. The host computer must have speakers connected.


======Wait======
=====Wait=====


[[Image:Reports_Tools_Ribbons_110.png|framed|none]]
[[Image:macro_wait.png|border|500px]]


Waits for a given time. The wait time is specified in seconds.
Waits for a given time. The wait time is specified in seconds.


======"While" loop======
====="While" loop=====


[[Image:Reports_Tools_Ribbons_111.png|framed|none]]
[[Image:macro_while.png|border|500px]]


Runs a set of commands several times until the condition is false. The condition can depend on an event, status value or parameter. The event condition can be "event x occurred" or "event x not occurred".
Runs a set of commands several times until the condition is false. The condition can depend on an event, status value or parameter. The event condition can be "event x occurred" or "event x not occurred".
Line 595: Line 649:
[[Image:Reports_Tools_Ribbons_116.png|framed|none]]
[[Image:Reports_Tools_Ribbons_116.png|framed|none]]


[[Image:Reports_Tools_Ribbons_117.png|framed|none]]
[[Image:Reports_Tools_Ribbons_117.png|700px|none]]


* '''Advanced alarm: '''This condition is available only when at least one alarm on a double template result has been declared.
* '''Advanced alarm: '''This condition is available only when at least one alarm on a double template result has been declared.
Line 601: Line 655:
[[Image:Reports_Tools_Ribbons_118.png|framed|none]]
[[Image:Reports_Tools_Ribbons_118.png|framed|none]]


{|border="2" cellspacing="0" cellpadding="4" width="100%" align="center"
{|border="0" cellspacing="0" cellpadding="4" width="100%" align="center"
|
|
[[Image:Reports_Tools_Ribbons_119.png|framed|none]]
[[Image:Reports_Tools_Ribbons_119.png|framed|none]]


|
|
{|border="2" cellspacing="0" cellpadding="4" width="100%"
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="100%"
|'''Operator'''
|'''Operator'''
|'''Test'''
|'''Test'''
Line 708: Line 762:


|
|
{|border="2" cellspacing="0" cellpadding="4" width="100%"
{|class="wikitable" style="background:white" border="2" cellspacing="0" cellpadding="4" width="100%"
|'''Operator'''
|'''Operator'''
|'''Test'''
|'''Test'''
Line 803: Line 857:
|}<br clear="all">
|}<br clear="all">


=====Editor contextual menu=====
====Editor contextual menu====
======Setting properties======
=====Setting properties=====
* '''Cut: '''Removes the command selected and copies it to the clipboard.
* '''Cut: '''Removes the command selected and copies it to the clipboard.
* '''Copy: '''Copies the command selected in the clipboard.
* '''Copy: '''Copies the command selected in the clipboard.

Revision as of 10:46, 7 January 2022

Tutorial

A macro is a powerful automation tool of NVGate allowing to create your own programs from a simple graphic interface, and doesn't require any software development skills.

In this section, we will create a macro that will automatically restart the recording as soon as the measurement is stopped. To do so, add the channels into the recorder.

Creating a new Macro

Go in the "Automation" tab of the NVGate ribbon, and select "New" in the Macro group:

Macro new 2022.JPG

Add a parameter

This will open the Macro editor :

Our macro needs to restart the recording as soon as it had been stopped. The macro needs to loop as long as necessary, and the user must be able to stop the loop when needed. To do so, we will create a boolean parameter to control the loop. The loop will then iterate as long as this parameter is "True", and the user can change it to "False" to stop the loop and the Macro.

To create this parameter, right click on the name of the macro and select "Properties":

RightClick.png


Then click on "Add", and define the Boolean parameter "EnableMacro" as follows:

AddProp.png

Affectation

In order to control the Macro, we will must be able to change the value of "EnableMacro" from "True" to "False".

This can be done with an "affectation" on the Macro editor. An affectation being an Algorithmic command, it must be add from the "add an Algorithmic command" icon AlgoCommandIcon.png.

To create an affectation, select "End of Macro" and click on the AlgoCommandIcon.png icon. You need to select "End of Macro" because the affectation will come just before this line.
Select "Affectation" in the list and set it up as follows :

Affectation.png


You can now change the value of "EnableMacro" by double-clicking on the Affectation command.

While Loop

In order to loop as long as needed, we will use a "while" loop that iterates as long as "EnableMacro" is set on "True".

The while loop is an Algorithmic command, and will be added the same way as the Affectation command. Click on "End of Macro", click on the AlgoCommandIcon.png icon and select "while loop". Then set the loop as follows :

WhileLoop.png

If instruction

Inside the while loop, we need to test if the measurement has been stopped. An IF instruction can be used to perform such logical test. The IF instruction allow you to chose between two different actions to take regarding the current state of an event, or the value of parameter. Here, we will test if the event "Measurement is stopped" occurred.

To add the IF instruction inside the loop, select the "End while", open the Algorithmic list and select "If... Then...". Setup the If test as follows :

If.png

Add the Run Command

Now that the If test is setup, we only need to add the "Run" instruction inside the If test to have the macro re-starting the measurement as soon as it has been stopped. However, the "Run" command is not an Algorithmic, but an NVGate command.

To add an NVGate command into the Macro, we will need to use "record off line" RecordOffLine.png or "record on line" RecordOnLine.png options. These icons will allow you to add one or serveral NVGate command in the macro by simply clicking on them. Once you added all the NVGate commands you want, you need to re-click on the "record on line" or "record off line" icon to stop the recording and validate the sequence.

The "record on line" RecordOnLine.png command will add the NVGate command in the macro and execute it at the same time. By example, clicking on RecordOnLine.png and RunIcon.png will add the "Run" command in the macro and start the acquisition in NVGate. Clicking on RecordOffLine.png and then RunIcon.png will add the "Run" command in the macro, but will not start the acquisition in NVGate.

To add the NVgate "Run" command into our macro, we don't need to actually start the acquisition in NVGate. To add it, select the "End if" line in the macro (because we want to add the "Run" command before this line), click on RecordOffLine.png. Then click on RunIcon.png and re-click on RecordOffLine.png to stop the recording of the command :

Run.png

The complete Macro

The macro is now complete :

Final.png

You may save it with the floppy-disk icon MacroFloppyIcon.png.

To try it, you can Run the acquisition by clicking on "Run" RunIcon.png in NVGate and then start the macro by clicking on the play icon RunMacro.png of the macro editor. If you stop the recording, a new one will be automatically restarted by the macro. For on optimised use, set the NVgate save option on "Without name confirmation".

You can stop the macro anytime by using the "pause" option of the macro editor PauseMacro.png and set the "EnableMacro" parameter on "False".

Launch the Macro

Use the control panel to launch the macro in NVGate.

Execute a .exe in a macro

This allows you to launch an external .exe or .bat. with a macro.
Macro link.png

Process:
- Put your .exe in C:\OROS\NVGate data\Links
- click on "record on line buton". RecordOnLine.png
- Select the .exe using the NVGate Link
- stop the "record on line".

Macros group

The macros group is used to create/manage macros that perform automatically recurrent operations.

Reports Tools Ribbons 58.png
Reports Tools Ribbons 59.png
Manage: Open the macros manager.
Reports Tools Ribbons 62.png New: Create a new macro and load it in the macro editor. This menu is disabled if another macro is being edited.
Reports Tools Ribbons 75.png Save: Save the macro currently edited. Only available if a macro is being edited.
Reports Tools Ribbons 76.png Save as: Save the macro currently edited with a new name. Only available if a macro is being edited.
Reports Tools Ribbons 77.png Record: Start recording the user action on the software. Each recorded action is appended to the Macro and will be a visible line in the macro editor.

Prior to start the macro recording user must enter the macro name and the recording mode:

  • Macro name: Name of the macro.
  • Recording mode:
Mode Description
On-line Commands corresponding to user actions are recorded in the macro.
Off-line User actions have no effect. Commands corresponding to user actions are recorded in the macro.

Note: Click on the record button to stop recording the macro. The macro is saved with the name specified in the "Record" dialog.


Reports Tools Ribbons 78.png Pause record: Pause the ongoing macro record. User actions are not yet recorded. Available if macro is being recorded.

Useful to prepare the system for an action to be recorded without filling the editor with unwanted lines.

Reports Tools Ribbons 79.png Stop run: Stop the execution of the running macro. Available if macro is running.


Macros Manager

Display the macros list and the associated hot-keys. A hot-key is a shortcut to run the macro.

Reports Tools Ribbons 60.png

Note: the three first hot keys are automatically assigned in the "Macro" menu from the OR38/OR36 Front Panel, labeled as "0", "1" and "2".

  • Edit: Edit the macro selected. Available if no macro is being edited, recorded, or executed.
  • New: Create a new macro. The new macro is opened in the editor. Available if no macro is being edited, recorded, or executed.
  • Delete: Delete the macro selected.
  • Run: Run the macro selected. Available if no macro is being executed.
  • Properties: Edit macro properties (name, read-only flag, and assigned hot-key). Available if no macro is being edited, recorded, or executed.
Reports Tools Ribbons 61.png
  • Name: Change the name of the macro.
  • Read-only: If the macro is read-only, the macro can be loaded to the macro editor but can’t be modified.
  • Hot key: Define a hot-key to run the macro.
  • Assigned macro: Macro associated with the hot-key selected in "Hot-key" combo-box. If hot-key selected is already assigned, a message is generated when the window is closed, requesting confirmation of the new assignment.

Macro Editor

Macro Editor 2022.JPG

Reports Tools Ribbons 63.jpg Properties: Open a dialog box intended to edit macro properties.
Reports Tools Ribbons 66.jpg Delete : Delete the selected command in the macro tree. If the macro selected contains a set of commands (for example a loop command), a dialog box appears in order to confirm command removal. If removal is confirmed, the command and all commands it contains are deleted.

This command is enabled if the macro is not running and it is not read-only.

Reports Tools Ribbons 67.jpg Run: Run the macro from the current command (indicated by execution pointer) to the next breakpoint. If no breakpoint follows, the execution goes to the end of the macro. Enabled if the macro is not running.
Reports Tools Ribbons 68.jpg Pause: Stop macro execution. The command running is completed, and then execution stops.

This command is enabled when the macro is running only.

Reports Tools Ribbons 69.jpg Step next: Run current command (indicated by execution pointer). This command is enabled when the macro is not running.
Reports Tools Ribbons 70.jpg Reset: If the macro is running, stop the execution, and then set the execution pointer to the first command of the macro.
Reports Tools Ribbons 71.jpg Record on-line: Record commands in the macro. The record on-line mode applies the user actions. The commands corresponding to actions are recorded and inserted in the macro before the selected command. This command is enabled if the macro is not running and it is not read-only.
Reports Tools Ribbons 72.jpg Record off-line: Record commands in the macro. The record off line mode applies the user actions only when the macro will start. The commands corresponding to actions are recorded and inserted in the macro before the selected command. This command is enabled if the macro is not running and it is not read-only.
Reports Tools Ribbons 73.jpg Insert an algorithmic command: Insert an algorithmic command before the selected command. This command is enabled if the macro is not running and it is not read-only.
Reports Tools Ribbons 74.jpg Save: Save the macro.


Macro properties

Macro properties consist of a set of parameters of different types, which can be used to define macro command properties. This command is enabled if the macro item is selected in the macro tree.

Reports Tools Ribbons 64.png
  • Add: Defines a new parameter.
Reports Tools Ribbons 65.png
  • Name: name of the parameter
  • Type: type of the parameter. The different types available are
Type Description
Boolean Parameter that can take only 2 values: True or False. This type of parameter is necessary for the MessageBox command to store the answer of the user. The parameter can then be tested in a "If...Then" command.
File name Not used
Float Parameter that can contain a decimal value (1.2, 1.12e6, -0.025, 5,-12387...). It is useful to store constant value that will be used in the macro for test condition ( If...then, While) or for other command (Wait, SetParamerValue ).
Integer Parameter that contains an integer value (5, -1024, 6401). Behavior similar to the float parameter, it can be also used in loop commands ( For loop, periodic loop)
String Parameter that contains a string of character. This type of parameter is useful to store constant string and to create string used by NVGate (Measurement name, Report template) or by commands (MessageBox, Trace). Several commands are dedicated to this string parameters ( MakeString, GetCurrentTime...)
  • Value: default value of parameter
  • Edit: Open the "Parameter properties" dialog box, which is used to edit the parameter selected in parameters list. It is possible to change the name, the type, or the default value of the parameter. If the parameter is used by one or more macro commands, the type can’t be edited (the "Type" combo-box is disabled).
  • Remove: Removes the selected parameter. If the parameter is used by one or more macro commands, the parameter is not removed and an error message is generated.

Algorithmic commands

Affectation

Macro affectation.png

Sets a value to a parameter. The new value can be defined by a parameter.

Break

Macro break.png

Used to exit a loop. It can be used inside a "for" loop to stop before the end of the iteration, inside a "while" loop to exit the loop without fulfilling the condition. It is the only way to exit a "Periodic loop".

Call Macro

Calls another macro.

Macro call macro.png

The only parameter is the name of the macro that is called. The body of the command is divided into three steps in order to exchange parameters between the calling macro and the called macro.

Comment

The purpose of this command is to facilitate understanding of the macro. It is used to add a comment line to the body of the macro.

Macro comment.png

The only parameter is the comment.

"For" loop

Macro for loop.png

Runs a set of commands several times. The number of iterations can be defined by an integer value or by an integer parameter.

Get Current Time

This command retrieves the time and stores it in a string parameter. This string may be use to send a trace, to create a measurement name...

Macro current time.png

The "Time format" specifies the way in which the time should be written. "Date", "Time" and "Date and Time" use the regional settings of the host computer while the three other formats are fixed formats.

Get Macro Parameter

Gets the value of a parameter of a called macro. This command must be inserted between the "Exit macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.

Macro get macro parameter.png

"Macro parameter" is the parameter of the calling macro that will receive the value of the parameter of the called macro.

"Parameter name" is the name of the parameter in the called macro.

Reports Tools Ribbons 87.png

In this example, the command gets the value of the parameter nNumberOfLoop of the macro CheckInput and sets this value to the parameter nCount of the calling macro.

Group

The purpose of this command is to facilitate understanding of the macro. It creates a branch that contains a set of instructions. It has no effect during execution, but it helps to organize the macro and facilitates copying and pasting, since all commands are copied at once.

Macro group.png

Reports Tools Ribbons 89.png
If…Then…

Macro if then.png

Runs a set of commands according to a condition. The condition can depend on an event, status value or parameter. The event condition can be "event x occurred" or "event x not occurred".

There are five types of conditions:

  • Event: The event can be "Measurement stopped", meaning that the analyzer went from "Running" to "Stopped" or "Measurement started", meaning the analyzer went from "Stopped" to "Running". This condition is used to wait for the end of a measurement, for instance.
Reports Tools Ribbons 91.png
  • Status: All analyzer statuses can be used for this condition. Depending on the type of status, it is possible to compare its value to a list of possible values or perform a logical test ( ’=’, ’!=’,’<=’,’>=’) with a constant or a parameter.
Reports Tools Ribbons 92.png
Reports Tools Ribbons 93.png
  • Parameter: The macro parameter of can be compared to a constant or to another parameter.
Reports Tools Ribbons 94.png
  • Simple alarm: This condition is available only when at least one alarm on a simple template result has been declared.
Reports Tools Ribbons 95.png
  • Alarm results
Reports Tools Ribbons 96.png
  • Advanced alarm: This condition is available only when at least one alarm on a double template result has been declared.
Reports Tools Ribbons 97.png
  • Advanced Alarm results
Reports Tools Ribbons 98.png
Operator Test Condition value for 1 Condition value for 2 Condition value for 3
= Above max False False False
!= Above max True True True
= Cross max False False True
!= Cross max True True False
= Between min & max False False False
!= Between min & max True True True
= Cross min True False False
!= Cross min False True True
= Below min False False False
!= Below min True True True
= Cross min & max False True False
!= Cross min & max True False True


Reports Tools Ribbons 99.png
Operator Test Condition value for 1 Condition value for 2 Condition value for 3
= Above max False False True
!= Above max True True False
= Cross max False False False
!= Cross max True True True
= Between min & max False True False
!= Between min & max True False True
= Cross min False False False
!= Cross min True True True
= Below min True False False
!= Below min False True True
= Cross min & max False False False
!= Cross min & max True True True


Incrementation

Macro incrementation.png

The increment command is used to increment the value of a macro parameter with a given offset.

The "Value" group-box allows defining the offset. The offset can be defined by a value or by a parameter of the same type as the parameter incremented.

Available if one or more integer or float parameter is defined.

Make String

Command used to create a string.

Macro make string.png

"Macro parameter" is the string that is modified. It can only be a String parameter.

"String to add" is the string that is added to the first parameter. It can be a constant or a parameter

"Add to existing string" is a Boolean parameter that indicates if the second parameter replaces or is added to first one. If the value is false, the command behaves like the Affectation command

Message box

Macro message box.png

Displays a dialog box, which is used to change the value of a Boolean parameter. The box is made up of a message and two buttons ("true" and "false"). It is possible to define the box caption, the message content and the button captions. A click on the "true" button sets the Boolean parameter to "true". A click on the "false" button sets the value to "false".

When the command is executed, the box is displayed. A click on one of the buttons closes the message box and sets the Boolean parameter value.

Periodic loop

Macro periodic loop.png

Runs a set of commands at each interval of time specified in the "Time lap" parameter. The time lap is specified in seconds, the "Break" command must be used to exit the loop.

Set Macro parameter

Sets the parameter value of a called macro. This command must be inserted between the "Open macro" and the "Execute macro" commands, inside the body of the "Call Macro" command.

Macro set parameter.png

"Parameter name" is the name of the parameter in the called macro.

"Parameter value" is the value the parameter must take.

Reports Tools Ribbons 105.png

In this example, the command sets the value of the parameter InputNumber of the macro CheckInput to 4.

Reports Tools Ribbons 106.png

When the macro is running, a dialog box is displayed, which is used to change the value of a parameter.

Macro set parameter dialog.png

The message generated in the top of the dialog box can be defined in the "command properties". A control is used to edit the parameter value. A click on the OK button changes the parameter value, and closes the dialog box. A click on the Cancel button closes the dialog box without changing parameter value.

Set Parameter Value

Macro set parameter value.png

Trace

Command used to send a message in the log window.

Macro trace.png

"Message" is the text that is displayed in the log window.

"Play sound" is used to play a sound when the message is sent. The host computer must have speakers connected.

Wait

Macro wait.png

Waits for a given time. The wait time is specified in seconds.

"While" loop

Macro while.png

Runs a set of commands several times until the condition is false. The condition can depend on an event, status value or parameter. The event condition can be "event x occurred" or "event x not occurred".

There are five types of conditions:

  • Event: The event can be "Measurement stopped", meaning that the analyzer went from "Running" to "Stopped" or "Measurement started", meaning the analyzer went from "Stopped" to "Running". This condition is used to wait for the end of a measurement, for instance.
Reports Tools Ribbons 112.png
  • Status: All analyzer statuses can be used for this condition. Depending on the type of status, it is possible to compare its value to a list of possible values or perform a logical test ( ’=’, ’!=’,’<=’,’>=’) with a constant or a parameter.
Reports Tools Ribbons 113.png
Reports Tools Ribbons 114.png
  • Parameter: The macro parameter of can be compared to a constant or to another parameter.
Reports Tools Ribbons 115.png
  • Simple alarm: This condition is available only when at least one alarm on a simple template result has been declared.
Reports Tools Ribbons 116.png
Reports Tools Ribbons 117.png
  • Advanced alarm: This condition is available only when at least one alarm on a double template result has been declared.
Reports Tools Ribbons 118.png
Reports Tools Ribbons 119.png
Operator Test Condition value for 1 Condition value for 2 Condition value for 3
= Above max False False False
!= Above max True True True
= Cross max False False True
!= Cross max True True False
= Between min & max False False False
!= Between min & max True True True
= Cross min True False False
!= Cross min False True True
= Below min False False False
!= Below min True True True
= Cross min & max False True False
!= Cross min & max True False True
   
Reports Tools Ribbons 120.png
Operator Test Condition value for 1 Condition value for 2 Condition value for 3
= Above max False False True
!= Above max True True False
= Cross max False False False
!= Cross max True True True
= Between min & max False True False
!= Between min & max True False True
= Cross min False False False
!= Cross min True True True
= Below min True False False
!= Below min False True True
= Cross min & max False False False
!= Cross min & max True True True


Editor contextual menu

Setting properties
  • Cut: Removes the command selected and copies it to the clipboard.
  • Copy: Copies the command selected in the clipboard.
  • Paste: Inserts the command stored in the clipboard into the macro. The command will be inserted before the command selected.

If the item selected in the macro tree is an "end of loop" item, the command will be inserted at the end of the loop body.

If the item selected in the macro tree is the "end of macro" item, the command will be inserted at the end of the macro.

  • Delete: Deletes the command selected. Available if the item selected in the macro tree is a command item (not "end of loop" or "end of macro item).
  • Toggle break point
Reports Tools Ribbons 121.png
If a breakpoint is put on the command selected, this command removes it. Otherwise, it sets a breakpoint for this command. Only available if the item selected is a command item.

Breakpoint has been set. This command is not executed.

During macro execution (see Run button), the execution stops on the first command where a toggle break point is placed.

  • Run to: Runs the macro from the current command (indicated by execution pointer) to the selected command, ignoring breakpoints. The selected command is not executed. If the current command is after the selected command, execution goes to the end of the macro, ignoring breakpoints.
  • Jump to: Sets execution pointer to the selected command.
  • Properties
Reports Tools Ribbons 122.png

Edits command properties.