Python scripting - Event callbacks

PostProcessAttributes

Previous  Chapter  Next

 

The callback PostProcessAttributes(CENPyOlpEvent_PEOperator) is called when the kernel processes the event attributes.  

 

 

The callback is defined in the %EVENT_NAME%.py file that is located in the scripts folder of the plugin.

 

PostProcessAttributes

 

[Example]

 

def PostProcessAttributes(peOperator):

 

   # retrieve the selectd recipe id

   attribGetter = peOperator.GetAttribGetter()

   attribSetter = peOperator.GetAttribSetter()

   recipeId = attribGetter.GetInteger(RECIPE_ID)

 

   # no valid recipe ID

   if recipeId <= 0:

      pass

 

   # Get the path to the TechTabs folder and CSV file:

   # Do not forget to add "import inspect, os" at the top of the file

   # currentPythonFilePath = os.path.abspath(inspect.getfile(inspect.currentframe()))

   # scriptsDirectoryPath = os.path.dirname(currentPythonFilePath)

   # parentDirectoryPath = os.path.dirname(scriptsDirectoryPath)

   # csvFilePath = str(parentDirectoryPath + "\\TechTabs\\Test.csv")

   # or simply:

   csvFilePath = str(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) + "\\TechTabs\\Test.csv")

 

   # read all recipe data

   recipes = []

   with open(csvFilePath, 'r') as csvfile:

      csv_reader = csv.reader(csvfile, delimiter = ';', quotechar = '"', quoting=csv.QUOTE_NONE, lineterminator = '\r\n')

      next(csv_reader)

      for row in csv_reader:

         recipes.append(row)

 

   # recipe id is out of range

   if recipeId > len(recipes):

       pass

 

   # parameter set of selected recipe

   parameters = recipes[recipeId-1]

 

   # Comment

   attribSetter.SetString(COMMENT, parameters[0])

   

   # Prog Pierce

   attribSetter.SetString(PROG_PIERCE, parameters[1])

   

   # PWR Pierce

   attribSetter.SetString(PWR_PIERCE, parameters[2])

   

   # Prog Contour

   attribSetter.SetString(PROG_CONTOUR, parameters[3])

   

   # PWR Contour

   attribSetter.SetString(PWR_CONTOUR, parameters[4])

   

   # PWR Regulation

   attribSetter.SetString(PWR_REGULATION, parameters[5])

 

   # SV1 - SV10

   attribSetter.SetString(SV1, parameters[6])

   attribSetter.SetString(SV2, parameters[7])

   attribSetter.SetString(SV3, parameters[8])

   attribSetter.SetString(SV4, parameters[9])

   attribSetter.SetString(SV5, parameters[10])

   attribSetter.SetString(SV6, parameters[11])

   attribSetter.SetString(SV7, parameters[12])

   attribSetter.SetString(SV8, parameters[13])

   attribSetter.SetString(SV9, parameters[14])

   attribSetter.SetString(SV10, parameters[15])

   

   # SP1 - SP10

   attribSetter.SetString(SP1, parameters[16])

   attribSetter.SetString(SP2, parameters[17])

   attribSetter.SetString(SP3, parameters[18])

   attribSetter.SetString(SP4, parameters[19])

   attribSetter.SetString(SP5, parameters[20])

   attribSetter.SetString(SP6, parameters[21])

   attribSetter.SetString(SP7, parameters[22])

   attribSetter.SetString(SP8, parameters[23])

   attribSetter.SetString(SP9, parameters[24])

   attribSetter.SetString(SP10, parameters[25])

   

   # NG type

   attribSetter.SetString(NG_TYPE, parameters[26])

   

   # NG press stand-by

   attribSetter.SetString(NG_PRESS_STANDBY, parameters[27])

   

   # NG press pierce

   attribSetter.SetString(NG_PRESS_PIERCE, parameters[28])

   

   # NG press contour

   attribSetter.SetString(NG_PRESS_CONTOUR, parameters[29])

   

   # NZ char

   attribSetter.SetString(NZ_CHAR, parameters[30])

   

   # NZ dis-pierce

   attribSetter.SetString(NZ_DIS_PIERCE, parameters[31])

   

   # NZ dis-contour

   attribSetter.SetString(NZ_DIS_CONTOUR, parameters[32])

   

   # NZ Pos stand-by

   attribSetter.SetString(NZ_POS_STAND_BY, parameters[33])

   

   # NZ Pos contour

   attribSetter.SetString(NZ_POS_CONTOUR, parameters[34])

 


PostProcessAttributes_Ex

 


Previous
Previous page
Chapter
Chapter page
Next
Next page