- Getting started
- Creating projects
- OPC UA
- Graphic objects
- Predefined graphic objects
- Object and variable references
- Extending projects
- NetLogic
- Tutorials
- Dynamic links tutorial
- Graphic objects tutorial
- NetLogic tutorial
- OPC UA tutorial
Create an object with custom behavior
Create an object type with a simple NetLogic that sums two integers.
Prerequisites
Set the default external code editor. See Set the default code editor.
- To create an object type with custom behavior
- InProject view, right-clickModeland select .UnderModel,Object1appears.
- Hover-overObject1, selectand enterMyObject.
- Right-clickMyObjectand select .MyObjectchanges intoMyObject (type).
- Right-clickMyObject (type)and selectAdd custom behavior.
- Right-clickMyObject (type)and selectEdit with .NET code editor (external).The external code editor opens.
- In the external code editor, makethe following edits:#region Using directives using System; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.UI; using FTOptix.HMIProject; using FTOptix.NativeUI; using FTOptix.Retentivity; using FTOptix.CoreBase; using FTOptix.Core; using FTOptix.NetLogic; #endregion [CustomBehavior] public class ObjectBehavior : BaseNetBehavior { public override void Start() { // Insert code to be executed when the user-defined behavior is started } public override void Stop() { // Insert code to be executed when the user-defined behavior is stopped }[ExportMethod] public void sumNumbers(int a, int b, out int c){ c=a+b;} #region Auto-generated code, do not edit! protected new Object Node => (Object)base.Node; #endregion }
- Save the NetLogic code and close the external editor.
- InFactoryTalk Optix Studio, right-clickModeland select .
MyObject1
appears under Model
.Provide Feedback