*Examples – Execute macro
Configuration Article | CA-20220907-TP-82 VDG Sense | API | References |
The virtual matrix (macros), allows the system to perform some actions based on one or more signals. See virtual matrix in chapter Introduction. One signal, or a combination of signals, triggers a macro. This macro executes one or more actions.
The command executeAction has one action viewer.executeMacro which allows the client to execute a specific viewer macro on a specific viewer station.
Get the list with viewer macros.
First we need to get the list with defined macros. Only viewer macros are returned.
Command url:
http://<server>/?command=getMacroList |
Result:
<result errorcode="0">
<macros count="10">
<macro>
<macroid>8</macroid>
<name>Events.Panel2</name>
<type>viewer</type>
</macro>
<macro>
<macroid>9</macroid>
<name>Operator</name>
<type>viewer</type>
</macro>
<macro>
<macroid>10</macroid>
<name>Events Bookmark.Panel2</name>
<type>viewer</type>
</macro>
<macro>
<macroid>11</macroid>
<name>Events Bookmark.Panel14</name>
<type>viewer</type>
</macro>
<macro>
<macroid>12</macroid>
<name>Layout Events bookm</name>
<type>viewer</type>
</macro>
<macro>
<macroid>13</macroid>
<name>Layout empty</name>
<type>viewer</type>
</macro>
<macro>
<macroid>16</macroid>
<name>Layout 1.toLayout2</name>
<type>viewer</type>
</macro>
<macro>
<macroid>17</macroid>
<name>Layout 2.toLayout1</name>
<type>viewer</type>
</macro>
<macro>
<macroid>18</macroid>
<name>Switch Layout Layout1</name>
<type>viewer</type>
</macro>
<macro>
<macroid>19</macroid>
<name>Switch Layout Layout2</name>
<type>viewer</type>
</macro>
</macros>
</result> |
Executing a macro.
getMacroList in this example, we see the last two macros are used to switch to Layout 1 and Layout 2 respectively.
In this example we are going to execute the macro to switch the Layout to “Layout1” on the viewer with id 1237718987111238112.
This is only an example of course. Switching a layout could also be done with the command selectLayout. See the example “Select a camera on a server” for an example of this command.”>To execute a macro we must know the name of the macro to be executed. From the results of the getMacroList command we might be able to guess what that macro will do.
In real life situations it is best to give meaningful names to the macros. These names can be given by a defined convention. This allows the system and/or user to determine what a macro will do based on the name of the macro. These conventions should be made before configuring the system.
For example the convention used here is that a macro name that starts with “Switch Layout” is used to switch the layout of the server. The macro name ends with the name of the layout. In the results ofgetMacroList in this example, we see the last two macros are used to switch to Layout 1 and Layout 2 respectively.
This is only an example of course. Switching a layout could also be done with the command selectLayout. See the example “Select a camera on a server” for an example of this command.
Command url:
http://<server>/command?command=executeAction |
Post data:
Result: