Scripting functions
The PS scripting library enables you to work with scheduling data that is encoded in the input_data
variable, provided by the ION scripting environment. The library provides classes and functions to work with batches, resources, products, and other entities.
You must import this script to access the scripting library and import functions, classes, and objects:
from ps_scripting import *
You must import the library into the Python script, convert the input_data
variable into a Model instance, and initialize the model to use the library. This process is completed by calling the Model class, with the input_data
as a parameter, and assigning the result to a variable by using this logic:
from ps_scripting import *
model = Model(input_data)
Once the model is initialized, you can use the functions and classes of the library through the model instance.
This table lists the available functions in the library:
Function used for | Function | Description |
---|---|---|
Global | get_global() → Global |
Returns global properties (work area, horizon) of the model. |
Batch | get_selected_batches() → List[Batch] |
Returns all selected batches in the model. |
get_batch(batch_code: str) → Batch |
Returns a specific batch based on the specified code. | |
get_batches(batch_codes: List[str]) → List[Batch] |
Returns a list of batches based on the specified code. | |
Resource | get_all_resources() → List[Resource] |
Returns a list of all the resources in the model. Note: This includes all resources to which the selected batches are allocated. |
get_resource(resource_code: str) → Resource |
Returns the resource based on the specified code. | |
get_resources(resource_codes: List[str]) → List[Resource] |
Returns a list of resources based on the specified code. | |
Resource group | get_all_resource_groups() → List[ResourceGroup] |
Returns a list of all the resource groups in the model. Note: This includes all resource groups to which the selected batches are allocated. |
get_resource_group(resource_group_code: str) → ResourceGroup |
Returns the resource group based on the specified code. | |
get_resource_groups(resource_group_codes: List[ResourceGroup]) → List[ResourceGroup] |
Returns a list of resource groups based on the specified code. | |
Product | get_products(product_codes: List[str]) → List[Product] |
Returns a list of all products of the batches in the model based on the specified code. |
Enabling claim | get_all_enabling_claims() → Dict[str, List[EnablingClaim]] |
Returns a dictionary containing all the enabling claim of the batches in the model. For each entry in the dictionary, the key is the batch code, and the value is the list of enabling claims of that batch. |
get_batch_enabling_claim(batch_code: str) → List[EnablingClaim] |
Returns the list of claims for a specific batch based on the specified code. | |
get_batch_list_enabling_claim(batch_codes: List[str]) → Dict[str, List[EnablingClaim]] |
Returns a dictionary containing the enabling claim of the batches based on the specified code. | |
Status attribute | is_batch_status_attribute_set(batch_code: str, attribute_name: AttributeName) → bool |
Set to True, if the specified attribute is set for the batch. Else, set to False. |
filter_batches_with_status_attribute(batch_list: List[Batch], attribute_name: AttributeName, is_attribute_set: bool) → List[Batch] |
Returns a list containing all batches from the provided list based on the attribute status. | |
User field | get_batch_user_field(batch_code: str, index: int) → UserFieldValue |
Retrieve or update user-defined fields for various entities in the model. |
get_resource_user_field(resource_code: str, index: int) → UserFieldValue |
||
get_resource_group_user_field(resource_group_code: str, index: int) → UserFieldValue |
||
get_product_user_field(product_code: str, index: int) → UserFieldValue |
||
get_process_step_user_field(process_step_code: str, index: int) → UserFieldValue |
Note: These functions consider two parameters (code and index) and returns a UserFieldValue instance, which contains the text, number, and datetime values for that user field at the specified index. | |
Transition | get_setup_duration(batch_code: str, resource_code: str) → int |
Returns setup duration (min) for a batch on the resource based on the specified code. |
get_changeover_duration(batch_code: str, resource_code: str) → int |
Returns the changeover duration (min) for the batch on the resource based on the specified code. |