Editing an Action-based Python script

When the selected Python script is an Action-based script (like the example below), the right-hand panel of the Python Script Editor is used to add, customize and delete the Actions for that script.

 

Contents  [Hide]

 

Introduction to Action-based scripts

In GainSeeker versions 8.4 - 8.6.1, each new Python script was designed as a series of Actions - each with its own setup interface.

In GainSeeker version 8.7, code-only scripts were introduced and became the system default. However, the Python Script Editor for GainSeeker versions 8.7 and later can still edit both types of scripts - Action-based and code-only.

For this reason, any existing Action-based scripts are not automatically converted to code-only scripts, and there may be cases where you need to - or want to - work with an Action-based script:

If you prefer to work with code-only scripts, you can manually convert an Action-based script to a code-only script.

Please note that Action-based scripts in Inspections are more difficult to debug than code-only scripts, because breakpoints cannot be used.

Adding and editing Actions

To add an Action to the script, click Add Action and select the type of Action to add.

To edit an Action, click its Edit button. For information on editing each type of Action, click the links below:

Action

Description

Display Form

Display a predefined form. The form can contain other controls such as text fields and web browsers.

Note: The Display Form action is a Beta version that may be subject to change or discontinued in future GainSeeker versions.

Retrieval DMS

Specify the DMS data to retrieve for statistical calculations. This must be set before statistics can be calculated.

Retrieval SPC

Specify the SPC data to retrieve for statistical calculations. This must be set before statistics can be calculated.

Custom Code

Write custom Python code to execute.

SQL Query

Set a SQL query to execute.

Serial Setup

Configure a connection to a serial port.

Condition

Set a condition to execute other actions.

MTConnect Setup

Interface with MTConnect agents.

OPC

Interface with OPC servers.

Changing the order of Actions

Actions are executed in the order listed.

To change the order of Actions, click an Action to select it and then click the Move Down or Move Up button.

Displaying a Description for an Action

To document your Action-based Python script, you can add a Description to each Action:

Action-based Python script

 

The same Actions with Descriptions displayed

To add or edit the Description for an Action, right-click the Action and then click Edit Description. Alternately, when you edit any type of action except Custom Code, the Action Editor window will also display the Description box where you can edit the Description for that Action.

Deleting an Action

To delete an Action, click an Action to select it and then click Delete Action.

Saving or Cancelling changes

You can save your script at any time by pressing Ctrl+S or by clicking the button on the toolbar. If you select another script or close the Python Script Editor before all changes have been saved, you will be prompted with the option to save changes.

To cancel unsaved changes, select another script or close the Python Script Editor and then click No when prompted.

Creating a code-only script from an Action-based script

If you want to create a code-only script from an Action-based script, run the debugger to display the Python code that is generated.

Then copy the Python code and paste it into a new code-only script.