Project Inheritance
Project Inheritance
Watch the videoProject Inheritance allows one project to inherit resources from another project. If you have project resources that you want other projects to use such as views, windows, scripts, templates, or pipelines, you can create an inheritable project allowing other projects to inherit those resources. The project inheriting the resources can also overwrite the resources and let you re-define them specifically for that project.
Project inheritance is extremely flexible in that it allows inherited projects to also be configured as 'inheritable' and become a parent project itself. This allows for complex hierarchies of re-usable resources to be designed. Within each project, inherited resources may be used by other, βlocalβ resources. For example, an inherited Vision template could be embedded in a window, or an inherited script could be executed by a button.
This page demonstrates how project inheritance allows you to share resources across multiple projects as you deem fit by pointing one project to another project, and overriding resources to re-redefine resources specifically for the project you're working on.
Configuring Project Inheritanceβ
In order to make a project inheritable, you need to enable project inheritance on the project containing the resources that you want to share. In a similar way, these parent projects need to be assigned to the child projects that will be inheriting the resources to populate those resources. The following example demonstrates how to configure project inheritance for existing projects, but if you know a project needs to be inheritable or inherit a parent project's resources before creating, you can configure inheritance settings upon creation. This is available in the Gateway after selecting Create new project on the Config > System > Projects page and choosing the settings called out below, or in the Designer.
In this example, we have two projects: one project called 'global' which contains some project resources, and another project that is not yet inheriting any resources called 'Project_X.' Since we will be sharing the resources from the 'global' project with Project_X, let's first configure the 'global' project to be inheritable.
Configuring Parent Projectβ
Go to the Config tab on the Gateway Webpage, and select Systems > Projects. This brings up a list of all your projects. You'll notice that for each project listed, you'll see at a glance if a project is Inheritable, and if so, the name of the Parent Project will be displayed.
Find the project you want to make inheritable, and click the Edit next to the project name (i.e., global) to open the Project Settings window.
Enable the Inheritable property, and click Save.
Allow OverridesWhen you make a project inheritable, the Allow Overrides function is set by default on all project resources in the inheritable project. This allows all project resources to be propagated to all inherited projects
Cannot Launch Inheritable ProjectsWhen you have a project that's flagged as inheritable, you can not launch it as a stand-alone project (i.e., Perspective Session or Vision Client). You will get a 'Project Not Runnable" error message. If you have an inheritable project that you want to launch, you must have another project to inherit from it.
Configuring Child Projectβ
Now that we have an inheritable project, let's setup an existing project (i.e., Project_X) so it inherits resources from the 'global' project.
Under the Config tab select System > Projects page
Find your project and click the Edit button.
Select the inheritable project from the Parent Project dropdown list (i.e. global), and click Save.
Using Inherited Resourcesβ
You can treat an inheritable project as a library of resources for use in other projects. When project resources are changed in the original project, these changes will get passed down to the inherited projects. The same thing is true if new resources are added to the inheritable project. By using inheritable projects, you can create a resource library that will help designers build their projects more quickly, ensure consistency and reusability across all their projects.
To view your inherited resources, go to the Designer and open your child project (i.e., Project_X). Expand the folders that contain resources, and you'll notice that the inherited project resources are grayed out, including the Perspective Views and Vision Windows folders. Grayed out resources mean that those resources are inherited, and can only be edited from their parent project.
The Inherited Resource icon is displayed when the resource is grayed out and indicates the resource is inherited and unchanged from the parent project resource. The Inherited Resource Overridden icon indicates the resource has been overridden and is now editable. Anytime a new resource is added or an existing resource is changed in the parent project, it will propagate down to the inherited project and will appear grayed out with an Inherited Resource icon.
Inheritance and "Runnable" Resourcesβ
Some resources in a project "run" or execute in every leaf project (that is, a project that is not inherited by any other project) in the inheritance chain. Thus, if multiple projects inherit from the same parent project, then each leaf project will contain runnable resources, potentially resulting in duplicate executions.
The diagram below represents an inheritance hierarchy on a single gateway. A "Root" project contains a Gateway Tag Change script. Two projects inherit from the Root, so they'll inherit the script. In both cases, the inheritance chain leads to leaf projects. In this single gateway, two running instances of the same tag change script exist, meaning there will be duplicate script executions.
In the case of resources that "run", it is highly advised that they exist in a leaf project, or a standalone project (a project that does not participate in inheritance at all). In regards to the diagram above, we could prevent duplicate execution of our Tag Change Script easily by moving the Tag Change Script to a separate, standalone project:
"Runnable" Resourcesβ
The following resources are considered "runnable":
Overriding Inherited Resourcesβ
To edit a resource in an inherited project, you need to override the resource by right-clicking the resource and selecting Override Resource. By overriding the inherited resource, the resource is recreated in the inherited project, and any future changes made to the original project resource will not propagate down to the inherited resource.
If new resources are added in the parent project, they will automatically propagate down to inherited projects. New resources that are added in the inherited project will initially display grayed out. You will need to override each new resource to edit it.
Discarding Inherited Resource Overridesβ
Changes made to inherited resources that have been overridden can be discarded. Selecting Discard Overrides removes the override placed on the inherited resource. The inherited project resource will return to its original state inherited from the parent project (without your edits), and the resource becomes grayed out in the Project Browser with the Inherited Resource icon. To discard the override on an inherited resource, right-click on the resource and select Discard Overrides. A dialog box will pop up confirming you want to discard the resource.
Renaming an Inherited Resourceβ
You can easily rename an inherited resource, but beware that when you rename a resource, the inheritable project will propagate the original resource to the inherited project. For example, say you have an inheritable project resource named 'Map_Transform' and you renamed it to 'CA _Map_Transform.' Ignition knows that the original project resource is no longer there, and because the project is flagged as inheritable, it will propagate that original resource to the inherited project. Now you have both the renamed 'CA_Map_Transform' and the original inheritable resource 'Map_Transform.'
Opening Read-only Named Queriesβ
This option is still available (and will allow you to edit the Named Query), but you can now select the Open read-only option from the Named Query right-click menu to view the Named Query Settings, Authoring, and Testing tabs. Since the read-only option does not allow changes, you'll notice the Inherited Resource icon remains next to the selected Named Query.
Inheritable Project Examplesβ
There are many ways how you might want to configure and organize your inheritable projects. It's whatever works best for your organization and design projects. Here are a couple of common ways to organize your shareable resources.
- You can create one inheritable project that contains many project different resources: scripts, pipelines, views, templates, windows, SFCs, etc. This is one inheritable project containing all your inheritable project resources.
- Another option is to create several inheritable projects. You can have one inheritable project dedicated for each type of resource: one for scripts, one for views, one for templates, one for pipelines, etc.
Project Exportβ
When a project is exported from the Designer you can choose to export strictly local resources or all resources (including those inherited). Exporting inherited resources is a great way to create a "flattened" project export, containing all resources used by the project regardless of which project the original resources are located in.
Note that exporting a project from the Gateway's UI will only export a project's local resources, and not contain inherited resources.