xeden3 / LECPServer

LECPServer(Leanboard Equipment Communication Proxy Server), It is a high-performance industrial connectivity platform developed based on the JLean framework. It solves communications challenges with industrial devices and applications, with streamlined data through a single communications platform
222 stars 45 forks source link

如何读写Int16(Short)等类型? #3

Closed tiaod closed 1 year ago

tiaod commented 3 years ago

根据jlean的文档,它支持读写这些类型: image 但是在LECPServer,却只支持这些: image

xeden3 commented 3 years ago

是的,我们只针对一般用到的类型写在了LECPServer里面,省略了大部分类型,PLC一般不会用到int32和int64这种类型的,如果需要用到,欢迎修改main.js实现,其实也很简单 @tiaod 😄

tiaod commented 3 years ago

原来如此,但我这边公司项目用到了short类型,我添加后提个pr吧😄

xeden3 commented 3 years ago

你好,我建议你可以考虑使用后段程序,将WORD(UINT16) 转为 Short(INT16),就是将无符号整数转为有符号的整数,算法相对很简单,PHP、JS、Python都有现成的算法。

https://stackoverflow.com/questions/872424/unsigned-int-to-signed-in-php https://stackoverflow.com/questions/16452232/how-to-convert-signed-32-bit-int-to-unsigned-32-bit-int

当然看看你具体的需求是什么,还有后台程序使用的是哪个语言。

其实我也考虑将Short和Int32、Int64加入到LECPServer中,但这个不是最优先级的。

当然也欢迎你PR一个,这个实现代码并不难。