Python Scripting and Python Commands

Python is an accessible scripting language that gives you access to greater functionality in GainSeeker. It allows you to automate customized data entry and analytics in a readable syntax. People who are familiar working with other programming or scripting languages are encouraged to explore the use of Python with GainSeeker.

See the Python website for more information about this scripting language.

 

Contents  [Hide]

 

Using Python in GainSeeker

GainSeeker maintains five separate lists of Python scripts, which you can use for:

This means that a script you create for inspections will not be displayed when you are working with dashboard scripts, for example.

The Python Script Editor is used to edit, debug, and manage your GainSeeker Python scripts. (The exception is customizing statistics, which uses a different editor.)

The majority of your Python code will be standard Python 2.7x, but several specialized GainSeeker Python commands are also available.

GainSeeker Python commands

Command

Description

Command Line arguments

Confirm whether an argument exists, get the value of a command line argument, or view the entire argument string. See Command line argument commands

Corrective Actions

Perform various actions for corrective action values in the database. See Corrective Action commands

Dashboard

Open a dashboard or desktop, or refresh or close the current dashboard. See Dashboard commands

Data DMS

Store DMS data records to the database. See Data DMS commands

Data SPC

Store SPC data records in the database and optionally store them to the monitor table. See Data SPC commands

Display

Place controls on a form to show on the screen. See Display commands

Error

Access a listing of errors that can occur when running commands within GainSeeker's Python library. See Error commands

File

Manipulate Excel, CSV, TAB, and other text file types. See File commands

HSI Date

Access and format date and time information. See HSI Date commands

Inspection

Modify a running inspection. This command only functions while a Formula test is running in a sub-inspection. See Inspection commands

Line chart and Bar chart

Draw a simple line chart or bar chart in a custom dashboard or a Python script in PC Collect. See Line chart and Bar chart commands

Login

Retrieve information specific to the current GainSeeker User. See Login commands

Miscellaneous

Start and stop other processes not listed in another command group. See Miscellaneous commands

MTConnect

Interface with MTConnect agents. See MTConnect commands

OPC

Interface with OPC servers. See OPC commands

Retrieval

Manipulate the SPC and DMS retrieval as part of an executing Python script. Chart external data or create a scripted retrieval for dashboard controls. See Retrieval commands

Serial Port

Pass in functions that gather the data for each cell. See Serial Port commands

Special Variables

There are special Python variables that can be used in specific areas of GainSeeker. See Special Variables

SQL

Access a variety of SQL functions. See SQL commands

Standard DMS

Read and write DMS standards and set various attributes of them. See Standard DMS commands

Standard SPC

Read and write SPC standards and set various attributes of them. See Standard SPC commands

Statistics

View calculated statistics for an SPC or DMS retrieval. See Statistics commands

TCP

Connect to another device using the TCP/IP protocol. See TCP commands

Traceability

Retrieve, edit, update, delete, and insert traceability values in the database. See Traceability commands

Python library files

Over 550 Python library files are installed with GainSeeker in the PyLib folder. These library files can be imported and used as part of any Python script. They may be updated in future GainSeeker releases, therefore, you should not edit any of these files. If you want to add or change functionality, create new library files, which will not be changed in future GainSeeker releases.

Comparing Python commands with Template commands

The installation process copies the file TemplateToPythonCommands.txt to the PyLib folder in the GainSeeker Installation folder. This file contains a list of all the template commands and the corresponding Python command to achieve the same results. This file is useful as templates are converted to Inspections or stand-alone Python scripts. The file is updated with each new version of the GainSeeker Suite.