This blog explains an approach that Cimetrix CIMControlFrameworkTM (CCF) developers can use to dynamically generate ECVs (EquipmentConstant Variables) in source code as a convenient, effective alternative to including them in the default configuration file.
When implementing the GEM interface for equipment, it is often necessary to define EquipmentConstant Variables (ECVs). If the GEM interface is part of a CCF-based equipment control system, you would normally define the ECVs in the Equipment.epj file. However, registering the ECVs with this approach can take a lot of effort in a number of situations. Among them:
- When you need to register hundreds or even thousands of ECVs;
- When you need to dynamically register ECVs based on the specific configuration of an instance of the equipment;
- When you want to register ECVs without changing the EPJ file.
In these cases, dynamically generating the ECVs from the source code easily addresses these challenges.
The rest of this posting briefly shows you how to accomplish this, and how to change and monitor the values of ECVs.
How to generate ECVs programmatically
After calling ecs.Start() inside Supervisor's Run(), the code sample below generates an ECV.
What you need to be most careful about here is that the ecid and ECV’s name should not be duplicated with other VIDs.
Then you can see the newly generated ECV in the Equipment Constants screen of the OperatorInterface.
How to change the value of an ECV
The ECV’s value can be updated through FactoryAutomationServer using the code below.
You can then see a message that the ECV’s value has been changed.
How to detect the ECV’s value change
If you want to detect changes to the ECV’s value, you can receive a callback by registering ValueChangedHandler as shown in the code sample below.
To Summarize:
- You can dynamically generate an ECV by calling CreateVariable of CIMConnect;
- You can change the value of an ECV by calling SetEquipmentConstants of FactoryAutomationServer;
- You can detect changes in the value of the ECV by calling RegisterValueChangeHandler of CIMConnect.
All are helpful solutions for CCF developers who need to generate ECVs dynamically.
To learn more about this solution and other CCF programming best practices, please schedule a time to talk with a Cimetrix representative.