Python command: Data SPC

The dataspc commands in Python allow you to store SPC data records in the database and optionally store them to the monitor table. 

 

Contents  [Hide]

 

 

See Python commands for other commands you can use with GainSeeker.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

dataspc.actiontaken

dataspc.actiontaken = "My Action"

Gets/Sets the ActionTaken field. When setting this field, the value must already exist in the Action Taken list as a Long Description or it will be ignored. Defaults to an empty string.

 

dataspc.anchorpoint

dataspc.anchorpoint = True

Gets/Sets if the record is an anchor point. Defaults to False. Possible values are True or False.

 

dataspc.bypass

dataspc.bypass = 1

Set bypass to "Remove from statistics and hide from charts"

Gets/Sets whether data is bypassed from retrievals and charts.

0 = show in retrievals and charts (the default)

>0 = hide from retrievals and charts

 

dataspc.bypassvisible

dataspc.bypass = 0

dataspc.bypassvisible = False

Set bypass to "Include in statistics and show on charts"

 

dataspc.bypass = 0

dataspc.bypassvisible = True

Set bypass to "Remove from statistics but show on charts"

If dataspc.bypass = 0, gets/sets whether data is included in statistics or removed from statistics.

(If dataspc.bypass > 0, this bypassvisible setting is ignored.)

 

False = include in statistics (the default)

True = remove from statistics

 

dataspc.cause

dataspc.cause = "My cause"

Gets/Sets the Cause field. When setting this field, the value must already exist in the Cause list as a Long Description or it will be ignored. Defaults to an empty string.

 

dataspc.clear()

dataspc.clear()

Clears all fields. It does not affect database records that are already stored.

 

dataspc.datetime

dataspc.datetime = "4/10/1991 14:51:05"

dataspc.datetime = hsidate.dbdatetimestr()

Gets/Sets the DateTime (either in GainSeeker database format or international format). Defaults to an empty string. Will be set to the current date and time if left blank.

 

dataspc.eventspc

dataspc.eventspc = "My event"

Gets/Sets the Event field. When setting this field, the value must already exist in the Event list as a Long Description or it will be ignored. Defaults to an empty string.

 

dataspc.getdata(index)

val = dataspc.getdata(1)

Gets the data field. The index must be between 1 and 72.

Returns None if not set, otherwise returns a numeric value.

 

dataspc.gettrace(index)

shift = dataspc.gettrace(2)

Gets the traceability field. The index must be between 1 and 48.

 

dataspc.incrementdt()

dataspc.incrementdt()

Increments the dataspc.datetime by the minimum allowable time difference between records as determined by configuration settings. Used to bulk store records that do not have a pre-determined datetime.

 

dataspc.note

dataspc.note = "My note"

Gets/Sets the note for a record. Defaults to an empty string.

 

dataspc.partno

dataspc.partno = "My part"

Gets/Sets the PartNumber field. Defaults to an empty string.

If you use dataspc.partno to change to a different standard name, and that standard exists, the subgroup size (dataspc.subgroupsize) is set to the subgroup size of the standard.

 

dataspc.partnoexists()

exists = dataspc.partnoexists()

If True, the value of dataspc.partno exists as a standard. Possible values are True or False.

 

dataspc.setdata(index, value)

dataspc.setdata(1, 3.2)

Sets the data field. The index must be between 1 and 72. Data fields are empty by default.

 

dataspc.settrace(index, value)

dataspc.settrace(1, "56348")

Sets the traceability field. Traceability fields are empty by default. The index must be between 1 and 48.

 

dataspc.store()

dataspc.store()

Store the fields as a database record. This fails if the dataspc.partno is not set. Trims any leading and trailing spaces from traceability fields (dataspc.gettrace / dataspc.settrace) before storing. Duplicate date/times are automatically incremented.

Returns True if it is successful. Possible return values are True or False.

Real-time checks are performed based on the properties of the dataspc.rtf commands.

How and whether monitor records are stored is determined by the Write to Monitor tables setting for the SPC standard. If the SPC standard does not exist, monitor records are not stored.

Clears the following fields in preparation for the next record to be built:

  • dataspc.actiontaken

  • dataspc.anchorpoint

  • dataspc.bypass

  • dataspc.bypassvisible

  • dataspc.cause

  • dataspc.eventspc

  • dataspc.getdata / dataspc.setdata

  • dataspc.note / dataspc.rtf.calculatertfnote()

  • dataspc.rtf.value / dataspc.rtf.calculatertfvalue

9.3

dataspc.store(mode)

dataspc.store(2)

Store the fields as a database record, and store a monitor record only if a real-time failure exists.

Store the fields as a database record. This fails if the dataspc.partno is not set. Trims any leading and trailing spaces from traceability fields (dataspc.gettrace / dataspc.settrace) before storing. Duplicate date/times are automatically incremented.

Returns True if it is successful. Possible return values are True or False.

Real-time checks are performed based on the properties of the dataspc.rtf commands.

How and whether monitor records are stored is determined by the mode, which can be 0, 1, 2, or 3.

0: Do not store to the monitor table.

1: Store to the monitor table when RTF is 0 (no real-time failures).

2: Store to the monitor table when RTF is greater than 0 (contains real-time failures).

3: Always store the record to the monitor table.

Clears fields in preparation for the next record to be built - see dataspc.store() for the list.

9.3

dataspc.subgroupsize

dataspc.subgroupsize = 5

Gets/Sets the subgroup size for this data record.

If dataspc.partno is not set or references a standard name that does not exist, this defaults to 1.

If you use dataspc.partno to change to a different standard name, and that standard exists, the subgroup size is automatically set to the subgroup size of the standard.

 

Monitor-specific commands

The dataspc.monitor commands set monitor-specific fields when storing records.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

dataspc.monitor.status

dataspc.monitor.status = "hello"

Gets/Sets the Status monitor field. This defaults to an empty string.

 

Real-time failure-specific commands

The dataspc.rtf commands set specific fields that determine how real-time checks are performed when storing records.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

dataspc.rtf.autocalcrtfs

dataspc.rtf.autocalcrtfs = True

If set to True (the default):

Optionally, you can set this to False and use dataspc.rtf.value to manually set the real-time failure value.

 

dataspc.rtf.calculatertfnote()

noteStr = dataspc.rtf.calculatertfnote()

Returns a string with the combined real-time failures for the current part number and data values.

 

dataspc.rtf.calculatertfvalue()

x = dataspc.rtf.calculatertfvalue() & 1024

if x == 1024:

print "Data above spec"

Prints a message if data for the current SPC standard failed the Upper Spec Limit.

Returns a number representing the combined real-time failures for the current part number and data values.

For a reference of the failures represented by the returned number, see Real-time Failure codes.

 

dataspc.rtf.filter

Filter name example:

dataspc.rtf.filter = "Shift 1"

 

Quick filter example:

dataspc.rtf.filter = "UDL2 = '1'"

Gets/Sets the filter to be applied when retrieving data to calculate real-time failures. This can be set to either a stored filter name or the contents of a quick filter.

The filter name is case sensitive – so if you specify "Shift 1" when the actual filter name is "SHIFT 1", this command won't be able to find the filter.

The default is no filter.

9.3

dataspc.rtf.maxretrievalcount

dataspc.rtf.maxretrievalcount = 25

Gets/Sets the number of data records to use when retrieving data to calculate real-time failures.

The default is set in the configuration of the current user.

 

dataspc.rtf.period

dataspc.rtf.period = '16'

Sets the date period to 'One week ending today'

Gets/Sets the date period to use when retrieving data to calculate real-time failures.

The default (None) is the configuration setting for the current user.

Other valid options include the numbers below, which must be specified as a string:

Today

1

Last n hours ending now

35

One day ending now

36

One week ending today

16

One month ending today

17

One quarter ending today

18

One year ending today

19

Today to default low

32

Current week

4

Current month

5

Current quarter

6

Current year

7

All dates

3

 

dataspc.rtf.requeryaftercount

dataspc.rtf.requeryaftercount = 10

Gets/Sets the number of data records that this script will store before querying the database for new data (that might have been entered by other users).

Set to zero (0) to never requery the database. The default value is zero (0) - disabled.

Each time the script stores a data record, GainSeeker adds that record to the data that was initially queried and re-calculates statistics like control limits and mean - even if you don't re-query the database.

 

dataspc.rtf.value

dataspc.rtf.autocalcrtfs = False

dataspc.rtf.value = 1024

Turns off automatic detection of real-time failures.

For the current SPC data record to be stored, manually sets the real-time failure code to 1024 (X above spec).

 

x = dataspc.rtf.value & 1024

if x == 1024:

print "Data above spec"

Prints a message if data for the current SPC standard failed the Upper Spec Limit.

Gets/Sets the real-time failure value for the current SPC data record to be stored.

For a reference of the failures and their associated code numbers, see Real-time Failure codes.

You can use this to manually set the real-time failure value when dataspc.rtf.autocalcrtfs = False .

 

Optimizing speed

When high-speed data storage is needed, there are several practices that can improve performance in certain situations.

Storing many records that don't have unique date/time stamps

Use dataspc.incrementdt(). This command automatically increments the date/time by the unit specified in your configuration for Show time to (minutes, seconds, or hundredths of seconds). This eliminates the need to perform multiple database calls when storing each record, which is common if the script is storing many records that have the same hour and minute value and don't record a more precise time.

Example:

if previousDate != nextDate:

    dataspc.datetime = nextDate

    previousDate = nextDate

else:

    dataspc.incrementdt()

Limiting real-time failure checks

Many real-time checks - such as checks for data points outside control limits, seven points in a row above or below the mean, etc. - require GainSeeker to retrieve data for the current standard so that the mean and control limits can be calculated. Reducing or eliminating these data retrievals, when appropriate, will improve performance.

Options include: