Samples | PLC C# sample:
Creating a method // Look up function block ITcSmTreeItem fb = sysManager.LookupTreeItem(@"TIPC^PLC1^PLC1 Project^POUs^MyFB"); // Create method (SubType 609 — source-verified) // vInfo[0] = method name, vInfo[1] = return type (REQUIRED) object[] vInfoMethod = new object[] { "MyMethod", "BOOL" }; fb.CreateChild("MyMethod", 609, "", vInfoMethod); // Create folder for methods (SubType 601 — available from TC 4024.14) ITcSmTreeItem folder = fb.CreateChild("Folder", 601); ITcSmTreeItem methodInFolder = folder.CreateChild("MyMethod2", 609); Reading and setting the declaration and implementation Reading and setting the declaration and implementation text of a POU is described in a separate article:
Reading and setting the declaration and implementation of a POU [ } 232] . PLC access modifier The following access modifiers are valid: PUBLIC , PRIVATE , PROTECTED , and INTERNAL . Creating a function block using Extends or Implements string[] vInfo; bool bExtends = true; bool bImplements = true; if (bExtends && bImplements) { vInfo = new string[5]; vInfo[0] = language.AsString(); vInfo[1] = "Extends"; vInfo[2] = "ADSRDSTATE"; vInfo[3] = "Implements"; vInfo[4] = "ITcADI"; } else if (bExtends) { vInfo = new string[3]; vInfo[0] = language.AsString(); vInfo[1] = "Extends"; vInfo[2] = "ADSRDSTATE"; } else { vInfo = new string[1]; vInfo[0] = language.AsString(); } TE1000 231 Version:
1.7.0 SubType Tag Item Category vInfo parameter 623 TREEITEMTYPE P _ LCDUTALIAS Alias DUT [0, optional]: Declaration text. 624 TREEITEMTYPE P _ LCEXTDATATYPEC ONT External data type container – – 625 TREEITEMTYPE P _ LCTMCDESCRIPTI ON TMC description file – – 629 – Parameter list PL [0, optional]: Declaration text. 631 – UML Class Diagram POU No vInfo parameter. 654 TREEITEMTYPE P _ LCITFPROPGET Property Get (interface) Interface No vInfo parameter; use null. 655 TREEITEMTYPE P _ LCITFPROPSET Property Set (interface) Interface No vInfo parameter; use null.