V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
noritanu
V2EX  ›  问与答

plc4j 的 s7 driver 不支持写入 real 吗?

  •  
  •   noritanu · Dec 15, 2020 via Android · 1560 views
    This topic created in 1962 days ago, the information mentioned may be changed or developed.
    在用 plc4x+java 做 pc 读写 plc 的项目,需要读写 bool,word 和 real 三种类型。读测试过了都行,写 bool 也行,就是 word 和 real 一写入就 no such method exception 。翻源码处理输入的方法里发现是用了反射,把一个数组 castedValues 传给了构造器,但是 plcValue 就没有接受数组的构造器。

    fieldType.getDeclaredConstructor(valueType).newInstance(castedValues);

    fieldType 是 plcValue 的子类,plcFloat 类构造器可以接受 Float 或 float,但是没有 Float[],所以每次都在这里报 no such method

    文档没写,搜过发现没人问这个,看 plc4x 的 issues 页面甚至发现没有测试写的功能。到这我就不知道怎么办了。
    1 replies    2021-05-28 15:51:44 +08:00
    tululala
        1
    tululala  
       May 28, 2021
    老哥,我也在学习 PLC4X 做 PLC 读写,可以留个联系方式交流下吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2713 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 64ms · UTC 03:00 · PVG 11:00 · LAX 20:00 · JFK 23:00
    ♥ Do have faith in what you're doing.