TIA Openness V16 使用1

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);
            }
        }
    }
}

注意:

  1. 两PLC自身动态链接库导入;
  2. 创建平台为类库,C#,.net FrameWork
  3. 参考资料

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;
            }
        }

    }

}


注意:

  1. 两PLC自身动态链接库导入;

以上
End of document

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值