Before Sample Update Event

Sepasoft MES Module Suite

Before a new sample is added or an existing sample is updated to the database, any script in this event is run. This includes samples that have been scheduled with no measurement data. It is provided to allow for the addition of more information, performing other actions or preventing the saving of the sample. 

Event Methods

 

getSample()


Description

Returns the new or updated sample. (See Sample section for more information).


Syntax

getSample()

 

  • Parameters

None

  • Returns

Sample sample - The new or updated sample.



setCancelUpdate(cancelUpdate)


Description

Used to prevent the sample from being added or updated.


Syntax

setCancelUpdate(cancelUpdate)

 

  • Parameters

boolean cancelUpdate - The default is false, meaning the sample will be added or updated. It is provided to override the default adding or updating of samples and should be used with caution.

  • Returns

Nothing
 



isCancelUpdate(cancelUpdate)


Description

Returns the current state of the cancel update flag. 


Syntax

isCancelUpdate()

 

  • Parameters

None

  • Returns

boolean cancelUpdate - True, if the current state of the cancel update flag is true and False otherwise.


 

 

Code Example

Code
#Add 1 to an unrelated SQLTag value
val = system.tag.getTagValue('[Default]Quality\Test\Before Sample Updated')
val = val + 1
system.tag.writeToTag('[Default]Quality\Test\Before Sample Updated', val, 1)


#Get the sample from the event
sample = event.getSample()


#Access the additional factors from the sample
addlFactors = sample.getAllAddlFactors()
if len(addlFactors) > 0:
 print "%d additional factors exist." % (len(addlFactors))


 print "val = %d, sampleUUID = %s" % (val, sample.getSampleUUID())



 

 

 

Sepasoft MES Module Suite