LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to combine 2 strings into 1

It seems like you have created 3 messages, one on reply to each of the earlier messages.  But we don't know which reply is in response to whom.  You would need to quote the original reply so we would know.  All you need to do is create 1 message reply and address each person as needed.  You can copy and paste some of the original message if needed.

 

Queues and notifiers are related, but not that similar.  Queues are a list of all the things going to them.  So if you send 3 items in a row before dequeueing anything thing, 3 items are in the queue and can be dequeued at any time (thus reducing the number of elements remaining in the queue.)  Notifiers are kind of like a 1 element queue.  If you send 3 items in a row before reading the notifier, only the last item is read, the first two are lost.

 

When you were talking about concatenating, I thought you were going to do that in the consumer loop where I thought you were processing the data and trying to combine the like messages.  But I see you are doing in the producer loop, and I don't know why.  Your code doesn't show anything of what you are trying to do in the consumer loop since it is just a notifier and nothing else.

 

The STOP function in your code is bad LabVIEW form also.  It is the equivalent to hitting the Abort button on the tool bar and essentially crashing your LabVIEW code right then and there without doing anything to clean up the code like Closing the UDP connection and ending the other loops gracefully.

0 Kudos
Message 11 of 18
(1,309 Views)

OK let me answer your questions from the last to the first.

 

The Stop function in the producer loop is necessary while in the consumer loop I

 

just put it like a stop condition, since I wrote before this is not my original code, just

 

to make an example.

 

For concatenating messages I need to do it in the producer loop, to make my notifier sends one

 

element every time to the consumer loop because the cycles of the consumer loop should corrispond

 

perfectly to the generation of the message in producer loop, and now it's necessary that when producer

 

loop generates 2 $ES messages one after another, one notifier is sent to the consumer loop. For queue

 

function, could you explain how could I reach this goal?

 

For your first question I don't queit understand. Through port 5123 my device generates tens of UDP messages

 

with different titles, and the case loop shows that I only want '$ES' ones. And now I have 2 devices and they

 

generate '$ES' messages together!

 

Thank you. 

0 Kudos
Message 12 of 18
(1,288 Views)

Thanks for the suggestion! But since this code I put here is a very simplified one of my real code.

 

The stop function here is not an issue. Anyway thanks.

0 Kudos
Message 13 of 18
(1,287 Views)

jcraffael wrote:For queue function, could you explain how could I reach this goal?

Just enqueue each message you want the consumer to process.  Since a queue is a FIFO, you can just let the consumer process as fast as it can and it will process every message.  It should be able to catch up easily enough assuming your consumer runs faster than your producer.  If you don't have a timeout for the Dequeue Element, the consumer will just sit there waiting for data to come in if there is nothing in the queue.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 14 of 18
(1,272 Views)

thanks for the explanation! After some study I got the idea of enqueue and dequeue function.

 

However, it seems impossible to solve my problem, which is every time enqueue 2 elements

 

together (they arrive almost at the same time) and in the consumer loop dequeue these 2

 

elements together, which makes the consumer loop run one cycle instead of 2!

 

If you have any idea about this please let me know, thank you!

0 Kudos
Message 15 of 18
(1,268 Views)

Why do you care?  Do you have to process the messages differently if two of the same messages come in a row?  I don't see why you should.  Just let the consumer process each message separately.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 18
(1,265 Views)

Because that is the idea of my program! OK if it's impossible to implement, for sure I can change the way of thinking.

 

My second idea is to concatenate every 2 UDP messages with '$ES' title together, which arrive almost at the same time

 

but in 2 cycles in the producer loop! I have to process these 2 messages from 2 devices exactly at the same time.

 

if for the concatenate way you got any idea, please let me know as well!

0 Kudos
Message 17 of 18
(1,262 Views)

@jcraffael wrote:

Because that is the idea of my program! OK if it's impossible to implement, for sure I can change the way of thinking.

 

My second idea is to concatenate every 2 UDP messages with '$ES' title together, which arrive almost at the same time

 

but in 2 cycles in the producer loop! I have to process these 2 messages from 2 devices exactly at the same time.

 

if for the concatenate way you got any idea, please let me know as well!


The two while loops are independent of each other, so you don't try to sync them.  That defeats the whole idea of the producer-consumer architecture.  Instead, for each spin of the consumer loop, decide what to do depending on where the message came from.  Realistically, you have to account for a condition where the two devices get out of sync and you have to deal with two messages in a row from one device anyway...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 18 of 18
(1,249 Views)