无法使用openness的“上传 PLC 设备”功能

已锁定

yucheng.zhan

  • 帖子

    2
  • 精华

    0
  • 被关注

    0

论坛等级:新手

注册时间:2023-11-03

普通 普通 如何晋级?

无法使用openness的“上传 PLC 设备”功能

2174

4

2025-07-29 18:33:53

Hello 各位大佬,

我在使用openness的“上传 PLC 设备”功能为什么会显示:

未经处理的异常:  Siemens.Engineering.EngineeringTargetInvocationException: Error when calling method 'StationUpload' of type 'Siemens.Engineering.Upload.StationUploadProvider'.


Online connection to PLC_1 [192.168.0.100] failed.


但是我在手动使用TIA Portal 的转至在线,和上载都是没有问题的?

环境:WIN11
TIA Portal V20

用的是VirtualBox虚拟机+S7-PLCSIM V19

仿真环境和TIA Portal V20手动可以正常下载上传程序,只有使用openness的上传 PLC 设备不行



以下是源程序

public static bool UploadPLC(Project myProject)

{

    // 1. 获取上传服务

    StationUploadProvider uploadProvider = myProject.GetService<StationUploadProvider>();


    // 2. 配置上传地址

    ConnectionConfiguration configuration = uploadProvider.Configuration;


    // 使用 PN/IE 模式(常用的 S7 通讯)

    ConfigurationMode mode = configuration.Modes.Find("PN/IE");

    if (mode == null) throw new Exception("未找到通信模式 PN/IE");


    // 找到本机网卡(名称请根据实际调整)

    ConfigurationPcInterface pcInterface = mode.PcInterfaces.Find("Intel(R) Wi-Fi 6E AX211 160MHz",1);

    if (pcInterface == null) throw new Exception("未找到匹配的本地网卡");


    // 配置 PLC 的 IP 地址

    ConfigurationAddress address = pcInterface.Addresses.Create("192.168.0.100"); // PLC IP


    // 3. 上传配置前委托

    UploadConfigurationDelegate preUploadDelegate = PreConfigureUpload;


    // 4. 执行上传

    UploadResult result = uploadProvider.StationUpload(address, preUploadDelegate);


    // 5. 打印上传结果

    Console.WriteLine($"上传结果:{result.State}, 错误数:{result.ErrorCount}, 警告数:{result.WarningCount}");


    PrintAllMessages(result.Messages, 0);


    // 6. 获取上传设备对象

    Device uploadedStation = result.UploadedStation;


    return uploadedStation != null;

}


无法使用openness的“上传 PLC 设备”功能 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-1500系列

共有11207条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。