Macros allow you to run a series of commands. For example, each SConnector uses start, stop, and status macros to control an executable. "CheckParams" is another macro available to SConnectors that allows the user to check all the parameters (startup and forced) being sent to the executable at runtime. Since SConnectors are defined using inheritance, each SConnector has a set of macros inherited from its parent. These macros are used by default, but can be overridden by defining new macros with the same name.

Each macro has a privilege level which specifies what privileges a user must have to run that macro. For example, if the macro privileges are set to "start" and "status", only users which have either "start" or "status" privileges (or both) on a Sensor which uses the SConnector, may run that macro.

When creating or editing a macro script, take note of the parameter system. For any variables bracketed with "~##" and "##~" (without the quotes, such as ~##numSlots##~ or ~##paramList##~), SCInterface will expect these to be supplied to the script at runtime. When running the script from the Macros page, SCInterface will allow the user to specify values for each parameter before executing the macro. SCInterface supplies values for the dynamic parameters automatically for start, stop, and status scripts.


Adding Macros

To add Macros to a SConnector:
  1. Click the Admin tab.
  2. Click the SConnector Admin tab.
  3. You will see a table of SConnectors. Click the name of the SConnector to which you would like to add startup parameters.
  4. Click the Macro tab.
  5. Cick the Add Macros tab.
  6. Enter a name for the macro.
  7. Specify the privileges required for a user to run the macro. The user must have at least one of the privileges chosen--they do not have to have every privilege specified.
  8. Enter a description for the macro in the "Verbose" field.
  9. Enter a script for the macro to run. This must be written in the Expect scripting language.
  10. Click the Add Macro button to save the new macro.
Adding a Macro

In the above screenshot, a macro named High Temp Remediation is being added. It will be available to any user that has start, stop, or status privileges on a Sensor that uses the Temperature Network SConnector. This script is an "Action Candidate", which means that it will be made available for users to run, once the temperature has reached at least 120 degrees. Availability of this macro is managed automatically by SCInterface. It will check the condition requirements against the status values returned by the SConnector status macros, and will also check that a user has the appropriate privileges to run the macro.

Editing Macros

To View & Edit Macros for an SConnector (or its parent):
  1. Click the Admin tab.
  2. Click the SConnector Admin tab.
  3. You will see a table of SConnectors. Click the name of the SConnector to which you would like to edit parameters.
  4. Click the Macros tab.
  5. You will see lists of macros for both the SConnector and its parent, or a message noting that none exist. To view the script and permissions level for a macro, click the "Script/Permissions" checkbox for that macro.
  6. If you have SC-Wide privileges, you will see an edit icon (Edit Icon). Click the edit icon for a macro to edit it.
  7. You may change the name, permissions level, description, and/or the Expect script itself.
  8. Click the Edit Macro button to save any changes.
Editing a Macro

In the above screenshot, the Temperature Network SConnector macro Num Nodes Connected is being edited. Any user with start, stop, or status privileges will see the results of this macro. It will be run whenever the user checks for the status of their Sensor, and it returns an integer.
Note: The "Status Condition to Meet" field is left blank since this macro is not an action candidate. That field is only used when a macro should be made available based on a certain condition.



Deleting Macros

To delete Macros for an SConnector:
  1. Click the Admin tab.
  2. Click the SConnector Admin tab.
  3. You will see a table of SConnectors. Click the name of the SConnector from which you would like to delete startup parameters.
  4. Click the Macros tab.
  5. Click the Delete Macros tab.
  6. You may delete macros from either this SConnector or its parent. To delete a macro, click the Remove icon (remove icon) for that macro. You may also view the contents of the macro script by clicking on the "Script" checkbox for that macro.
Deleting a Macro

In the above screenshot, any of the macros that have the delete icon (remove icon) are possible to delete. Checking the "Script" box allows you to see the contents of that script.




Related Topics: