Programmatically access data in FrameworX.
Reference → Code → Extensions API → Connector | EngWrapper API Reference
The EngWrapper API facilitates the automation of engineering solutions, allowing developers to generate outputs directly from .NET programming environments. It supports data ingestion from CSV, XML, and JSON formats, streamlining the integration and processing of varied data sets within engineering applications. This API serves as a bridge between raw data inputs and customized engineering outputs.
| Table of Contents | ||||
|---|---|---|---|---|
|
This API requires the version 9.1.15 or newer. When installing the software, the Eng.Wrapper.dll will be installed inside of the binaries folder (xx-9.1). This is the file containing the EngWrapper API.
You must use a WebServer (TWebServer or IIS) configured to the software. When you create a new object for the Project class from the EngWrapper, it will use the WebServer to connect to the project. It is recommended to close the project before using the EngWrapper API or to open the project as a remote development. If you do not do this, you will see the new project configurations when you close and reopen the project.
Every method that adds configuration to a project adds an event to a queue. This event queue will be treated when the Commit method is called. The only methods that do not do this are the runtime methods and the methods that are related to the displays that start with the IntializeCreateDisplays and end with the FinalizeCreateDisplays methods.
There is a Microsoft Visual Studio solution with an example using this API available. Contact support for more information.
The EngWrapper API allows C# or VB.NET applications to create and edit projects using third party applications.
When the software is installed, it will install the Eng.Wrapper.dll inside the binaries folder (xx-2016.2). This is the file containing the EngWrapper API.
For this feature, you will need to have a C# or VB.NET IDE installed on your computer. We recommend Visual Studio, as there is a sample solution already developed for it.
Through this IDE, you will be able to call one method to create items in the project, without the need to manipulate the project database.
You must use a WebServer (TWebServer or IIS) configured to the software. When creating a new object for the Project class from EngWrapper, it will use the WebServer to connect to the project. It is recommended to close the project before using the EngWrapper API or to open the project as remote development. If you do not do this, you will see the created project configuration when you close and reopen the project.
There are more details on every available method for the EngWrapper API on the documentation that comes with the sample project. Contact support if you do not have the project files.
To initiate the project configuration, you need to connect to a project using the syntax below:
| Code Block |
|---|
public Project( string projectFileName, string version = "xx-8.1", string server = "http://localhost/TProjectServer/", bool enableLogger = false, bool assetLevel = true) // Parameters: // projectFileName: Full filename of the of project file // version = Product version // server = TProjectServer path. Defaults: http://IPAddress:Port/TProjectServer/ // enableLogger = Flag indicating whether log is enabled // assetLevel = Indicates if the assetLevel is created |
For more syntax on the other project objects (Tags, Templates, Devices, etc.), see the EngWrapper documentation.
This section contains examples on API usage in the C# programming language.
Connect to Project:
| Code Block |
|---|
Project project = new Project(@"C:\Projects\Project.tproj","xx-8.1","http://localhost/TProjectServer/",true) |
Add new Tag Name:
| Code Block |
|---|
project.AddTag("Tag1","CommentTag1",Project.eTagType.Double,"V","25","0","800","","#1", tagDescription:"DescTag1");
project.AddTag("TagEnum1","CommentTagEnum1",Project.eTagType.Digital,tagParameters:"Enum=Enum1;", tagDescription:"DescTagEnum1"); |
Add Script Class:
| Code Block |
|---|
string script = "public int Add(int a)"+ Environment.NewLine + "{" + Environment.NewLine +"\t"+
"return a + 1;" + Environment.NewLine +
"}" + Environment.NewLine;
project.AddScriptClass("class1",Project.eScriptCode.CSharp,Project.eDomain.Server,script); |
Add Device Node:
| Code Block |
|---|
project.AddDeviceNode("Node1","Channel1","192.168.10.19;502;1","192.168.10.19;503;1","Node For Channel1",0); |
Add Device Point:
| Code Block |
|---|
project.AddDevicePoint("Tag1","Label for Tag1","Node1", "40001",Project.eDataType.Native,"", "ReadWrite",Project.PrepareScaling(0, 65535, 0, 800)); |
| Anchor | ||||
|---|---|---|---|---|
|
| Code Block |
|---|
public Project( string projectFileName, string version = "xx-9.1", string server = "http://localhost/TProjectServer/", bool enableLogger = false, bool assetLevel = true) |
| Code Block |
|---|
Project project = new Project(@"C:\Projects\Project.tproj", "xx-9.1", "http://localhost/TProjectServer/", true) |
| Code Block |
|---|
public object AddDeviceChannel( string channelName, string channelProtocol, string channelInterface, string channelDescription = "", string channelSettings = "", string channelTimeout = "", eInitialState channelInitialState = eInitialState.Enabled, string channelProtocolOptions = “”) |
| Code Block |
|---|
project.AddDeviceChannel("Channel1", "Modbus", "TCPIP", "Channel1", "Settings", Project.PrepareChannelTimeout(1000, 2000, 3000, 250, 5), Project.eInitialState.Enabled,
"BlockSize=250;Encoding=RTU TCP;SingleWrite=Use single write;SlaveID=2;CoilWriteValue=FF;Offset address=false"); |
| Code Block |
|---|
public object AddDeviceNode( string nodeName, string nodeChannelName, string nodePrimaryConnection, string nodeSecondaryConnection = "", string nodeDescription = "", Int64 nodeCategory = 0, Int32 nodeLevel = 0, string syncSettings = "", string syncStation = "", string syncDate = "") |
| Code Block |
|---|
project.AddDeviceNode("Node1", "Channel1", "192.168.10.19;502;1", "192.168.10.19;503;1", "Node For Channel1", 0); |
| Code Block |
|---|
public object AddUserTemplate( string templateName) |
| Code Block |
|---|
project.AddUserTemplate("PID"); |
| Code Block |
|---|
public object AddMemberName( string templateName, string memberName, string memberComment = "", object memberType = null, string memberUnits = "", string memberStartValue = "", string memberMin = "", string memberMax = "", string memberArray = "", string memberFormat = "", string memberParameters = "", eRetentive memberRetentive = eRetentive.None, eDomain memberDomain = eDomain.Server, eVisibility memberVisibility = eVisibility.Protected, string memberDescription = null) |
| Code Block |
|---|
project.AddMemberName("PID", "sp", memberType: Project.eTagType.Double, memberDescription: "Desc SP"); |
| Code Block |
|---|
public object AddTag( string tagName, string tagComment = "", object tagType = null, string tagUnits = "", string tagStartValue = "", string tagMin = "", string tagMax = "", string tagArray = "", string tagFormat = "", string tagParameters = "", int tagLevel = 1, eRetentive tagRetentive = eRetentive.None, eDomain tagDomain = eDomain.Server, eVisibility tagVisibility = eVisibility.Protected, string tagDescription = null) |
| Code Block |
|---|
project.AddTag("Tag1", "Comments of Tag1", Project.eTagType.Double, "V", "25", "0", "800", "", "#1", tagDescription: "Desc Tag1");
project.AddTag("TagTemplate1", tagType: "PID", tagDescription: "Desc PID");
project.AddTag("TagEnum1", "Comments of TagEnum1", Project.eTagType.Digital, tagParameters:"Enum=Enum1;", tagDescription: "Desc TagEnum1"); |
| Code Block |
|---|
public object AddDevicePoint( string pointName, string pointLabel = "", string pointNode = "", string pointAddress = "", eDataType pointDataType = eDataType.Native, string pointModifiers = "", string accessTypeName = "ReadWrite", string pointScaling = "") |
| Code Block |
|---|
project.AddDevicePoint("Tag1", "Label for Tag1", "Node1", "40001", Project.eDataType.Native, "", "ReadWrite", Project.PrepareScaling(0, 65535, 0, 800)); |
| Code Block |
|---|
public object AddAlarmArea( string alarmArea, string alarmAreaParent = "") |
| Code Block |
|---|
project.AddAlarmArea("Level1");
project.AddAlarmArea("Level2", "Level1"); |
| Code Block |
|---|
string alarmGroupName, eAlarmAck alarmGroupAck = eAlarmAck.Ack, eAlarmSound alarmGroupSound = eAlarmSound.None, int alarmShow = 1, eAlarmLog alarmLog = eAlarmLog.ActiveNormAck, string ackTimeout = "", string autoAckTimeout = "", string alarmGroupActiveTextColor = "", string alarmGroupActiveBackgroundColor = "", string alarmGroupAckedTextColor = "", string alarmGroupAckedBackgroundColor = "", string alarmGroupNormalTextColor = "", string alarmGroupNormalBackgroundColor = "", int activeTimeDeadband = 0) |
| Code Block |
|---|
project.AddAlarmGroup("LogOnly", Project.eAlarmAck.Ack, Project.eAlarmSound.None, 0, Project.eAlarmLog.ActiveNormAck, "10000", "20000"); |
| Code Block |
|---|
public object AddAlarmItem( string alarmName, string alarmGroupName = "", string alarmMessage = "", Int32 alarmPriority = 0, string alarmArea = "", eCondition alarmCondition = eCondition.GreatherEqual, string alarmValue = "1", string alarmAuxValue = "", string alarmSetPoint = "", string alarmSetPointDeadband = "", string alarmComment = "") |
| Code Block |
|---|
project.AddAlarmItem("Tag1", "LogOnly", "Tag1 Failure", 100, "Level2", Project.eCondition.Hi, "650"); |
| Code Block |
|---|
public object AddHistoricalTable( string tableName, int autoCreate = 1, int saveOnChange = 1, int timeDeadBand = 0, int lifeTime = 0, string trigger = "", int saveQuality = 0 ) |
| Code Block |
|---|
project.AddHistoricalTable("Log1", 1, 1, 1000, 10, "Tag1"); |
| Code Block |
|---|
public object AddHistoricalItem( string pointName, string pointHistoricalTable = "", double deadBand = 0, double deviation = 0, double rateOfChange = 0) |
| Code Block |
|---|
project.AddHistoricalItem("Tag1", "Log1", 10); |
| Code Block |
|---|
public object AddExpression( string tagName, string expression, eExecution execution = eExecution.Trigger_OnChange, string disableCondition = "") |
| Code Block |
|---|
project.AddExpression("Tag1", "Tag.Tag1=0", Project.eExecution.Trigger_OnChange); |
| Code Block |
|---|
public object AddScriptClass( string name, eScriptCode codeType, eDomain domain, string code) |
| Code Block |
|---|
string script = "public int Add(int a)" + Environment.NewLine +
"{" + Environment.NewLine +
"\t" + "return a + 1;" + Environment.NewLine +
"}" + Environment.NewLine;
project.AddScriptClass("class1", Project.eScriptCode.CSharp, Project.eDomain.Server, script); |
| Code Block |
|---|
public object AddScriptTask( string name, eScriptCode codeType, string trigger, TimeSpan period, eDomain domain, string code) |
| Code Block |
|---|
script = "@tag2[1] = @Script.Class.Class1.Add(TK.To<int>(@tag2[1]));" + Environment.NewLine + "@tag2[2] = @tag2[2] + 2;" + Environment.NewLine;
project.AddScriptTask("task1", Project.eScriptCode.CSharp, "Server.Second", TimeSpan.Zero, Project.eDomain.Server, script); |
| Code Block |
|---|
public object AddEnumerationSets( string name, string tagValue, string displayValue, string description = "") |
| Code Block |
|---|
project.AddEnumerationSets("Enum1", "0", "Open", "Description-Value0");
project.AddEnumerationSets("Enum1", "1", "Close", "Description-Value1"); |
| Code Block |
|---|
public object Commit() |
| Code Block |
|---|
project.Commit(); |
| Code Block |
|---|
public void IntializeCreateDisplays( System.Windows.Controls.Frame frame) |
| Code Block |
|---|
project.IntializeCreateDisplays(this.frame); |
| Code Block |
|---|
public void InsertDisplay( string displayName, string listCSV) |
| Code Block |
|---|
StringBuilder sb = new StringBuilder();
sb.AppendLine("Symbol,TagName,Top,Left,Labels,Uid");
sb.AppendLine("VerticalTank_Scale,,52,63,LevelValue=Tag3,VerticalTankScale3");
b.AppendLine("CurrentDisplay,,0,0,
Background=#FFFF0000;
Width=600;
Height=600;" +
"Mode=" + Project.eDisplayMode.Popup + ";" +
"CloseButton=1;" +
"Title=New Title;" +
"TitleBackground=#FFFF0000;" +
"Border=" + Project.eDisplayBorder.Thin +";" +
"Placement=" + Project.eDisplayPlacement.BottomLeft + ";" +
"Target=" + Project.eDisplayTarget.Mouse + ";" +
"DialogButtons=" + Project.eDialogButtons.YesNoCancel + ";" +
"Animation=" + Project.eOpenAnimation.Scroll
);
project.InsertDisplay("Page1", sb.ToString()); |
| Note |
|---|
The available display properties are: Background, Width, Height, Mode, CloseButton, Title, TitleBackground, Border, Placement, Target, DialogButtons, and Animation. |
| Code Block |
|---|
public void RemoveAllSymbols( string displayName) |
| Code Block |
|---|
project.RemoveAllSymbols("MainPage"); |
| Code Block |
|---|
public string GetDisplaySymbols( string displayName, char sep = ',') |
| Code Block |
|---|
string str = project.GetDisplaySymbols("MainPage"); |
| Code Block |
|---|
public string[] GetDisplays() |
| Code Block |
|---|
String[] displays = project.GetDisplays(); |
| Code Block |
|---|
public void FinalizeCreateDisplays( System.Windows.Controls.Frame frame) |
| Code Block |
|---|
project.FinalizeCreateDisplays(this.frame); |
| Code Block |
|---|
public void RunStartup( string userName, string password, bool connect, int timeoutSecWaitStarting = 60); |
| Code Block |
|---|
project.RunStartup("Guest", "", true, 60); |
| Code Block |
|---|
public void ShutdownRuntime(); |
| Code Block |
|---|
project.ShutdownRuntime(); |
| Code Block |
|---|
public bool IsRuntimeRunning(); |
| Code Block |
|---|
bool isRunning = project.IsRuntimeRunning(); |
| Code Block |
|---|
public void HotStartup(string userName, string password); |
| Code Block |
|---|
project.HotStartup("Guest", ""); |
| Code Block |
|---|
public void ConnectToRuntime(int timeoutSecWaitStarting = 60); |
| Code Block |
|---|
project.ConnectToRuntime(60); |
| Code Block |
|---|
public void DisconnectFromRuntime(); |
| Code Block |
|---|
project.DisconnectFromRuntime(); |
| Code Block |
|---|
public bool IsConnectedToRuntime(); |
| Code Block |
|---|
bool isConnected = project.IsConnectedToRuntime(); |
| Page Tree | ||
|---|---|---|
|