取消
显示结果 
搜索替代 
您的意思是: 

Send double type using ZeroMQ

已解决!
转到解答

Dear all,

I would like to ask about the ZeroMQ library. I am currently using it to transfer numbers as a "string" type but I can't find how to send it as integer or double. Since there is a huge amount of data in my application, using double data type would speed it up rapidly.

 

I could find only the solution for c++ here but no examples for LabVIEW.

 

 

0 项奖励
1 条消息(共 5 条)
5,800 次查看
解答
已被主题作者 Thomas444 接受

There are many ways to transfer numbers as strings, the most obvious would be to flatten or typecast DBLs or arrays of DBLs to a string and reverse on the other end. This is the most efficient, because there is no loss in bits and everything gets transferred verbatim, 8 bytes/DBL.

 

You would only get a slowdown if you would do silly things, such as formatting the DBLs into human readable strings and scanning them back later on the other end. This is lossy and inefficient.

 

(As you can see, we need to guess because you are not showing us any code explaining what you currently do and what you think is inefficient.)

2 条消息(共 5 条)
5,799 次查看

That function was a custom method added to that users socket class - I don't believe the protocol supports sending other data types - you would need to translate your DBL to a string somehow. Are you writing the code for both applications? Note if you aren't talking to another LabVIEW application, the way numbers are represented as strings will not be the same.

 

3 条消息(共 5 条)
5,771 次查看

Thank you guys for your answers,

 

so I was sending the numbers as a human-readable string (brunch B) before, what I consider to be inefficient. After that I flattened the numbers into the string according to your advice (brunch A). First, I tested this Request-Reply communication on my computer locally. There was no problem reading it on the Request side and volume of the data was reduced. There are both files in the attachment.

ZMQ replyZMQ reply

After testing it locally, I was able to communicate also with PHP Request application. Critical is to set 'prepend array or string size?' to False and synchronize the endians of both applications.

 

I would accept your solutions, if I understood your advice well.

0 项奖励
4 条消息(共 5 条)
5,752 次查看

@Thomas444 wrote:

Critical is to set 'prepend array or string size?' to False and synchronize the endians of both applications.

 


If you want big endian and prepend=false, you could just use typecast.

0 项奖励
5 条消息(共 5 条)
5,706 次查看