TIA Openness V16 使用1
1、初识 Openness
个人理解:Openness 就是一个方便使用高级编程环境中高级语言打开博途软件并进行自动编程的工具,或者说窗口。
2. 使用前注意事项
优先将Openness 添加到用户组中;
注意:添加后需要重启电脑,否则后续程序会报错。显示权限不足。
具体操作过程参考:https://www.cnblogs.com/hwlib/p/14440447.html
具体操作过程链接
3. 高级编程环境中初操作
在高级语言编程环境中,有个连个动态链接库需要引用,Siemens.Engineering.dll和Siemens.Engineering.Hmi.dll
位置比较刁钻
参考:C:\Program Files\Siemens\Automation\Portal V16\PublicAPI\V16
地址关键字:PublicAPI
4. c#启动类动态链接库文件生成
using Siemens.Engineering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace P075_Csharp库封装
{
public class TIA_V16
{
public static TiaPortal instTIA;
/// <summary>
/// Open a new instance of TIA Portal V16 with/without user interface
/// </summary>
/// <param name="guiTIA"></param>
public void CreatTIAinstance(bool guiTIA)
{
// Open new TIA instance with user interface
if (guiTIA)
{
instTIA = new TiaPortal(TiaPortalMode.WithUserInterface);
}
// Open TIA instance withour user interface
else
{
instTIA = new TiaPortal(TiaPortalMode.WithoutUserInterface);
}
}
}
}
注意:
- 两PLC自身动态链接库导入;
- 创建平台为类库,C#,.net FrameWork
- 参考资料
5. 类库生成
生成类库文件,为下一步使用做准备。
6. TIA Portal 打开
调用C#程序:
using P075_Csharp库封装;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace F070_OPENTIA
{
internal class Program
{
static void Main(string[] args)
{
try
{
TIA_V16 newTIA = new TIA_V16();
newTIA.CreatTIAinstance(true);
Console.ReadLine();
}
catch (Exception ex)
{
throw;
}
}
}
}
注意:
- 两PLC自身动态链接库导入;
以上
End of document