LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I display Rx and Tx data in two different colours..

Hello all

 

I have a VI which sends packets of data to a device and receives data. This is done using the serial port. I timestamp each packet and display it in a string control. I would like to be able to differentiate between sent and received packets by changing their colour / background / anything. I have investigated using a string control, a table, a list box and a richtextbox, but I am struggling to come up with a good solution. In the past in VB/C#.NET, I have created a log control using a richtextbox which can display formatted text, but I am keen to use a Labview control because I assume their is an overhead with the .NET richtextbox.

 

Any help or suggestions would be appreciated,

 

Thanks

 

Ray

0 Kudos
Message 1 of 12
(4,741 Views)

The first control I tried to use, a Listbox, worked OK.  I found the "trick" was to set the following properties together.

Active Row >> Active Row Number

Active Row >> Cell Font >> Color

 

2013-09-24 09_48_49-Untitled 1 Front Panel _.png

0 Kudos
Message 2 of 12
(4,733 Views)

Thanks Don, but I think I have not explained myself properly. 

 

I would like the items to be added to the control in real time and to be colour coded in real time - I don't want to go back and apply the colours afterwards as there could be a few thousand packets of data. Here's a mock up:

 

 Clipboard01.jpg

 

I would add new packets to the top and everything moves down, retaining the colours.

 

I have had a go with the listbox as you suggest and can't get this functionality - although this may just be my limited knowledge of listboxes...

 

Thanks, 


Ray

 

0 Kudos
Message 3 of 12
(4,706 Views)

Here's a bit more information.. My current string control looks like this:

 

Clipboard02.jpg

 

and it would be much more intuitive if it looked like this (without the "SENT:" prefix):

 

Clipboard02.jpg

0 Kudos
Message 4 of 12
(4,700 Views)

Something like this?

fp.jpgbd.jpg

I used a listbox with selection mode 0 (0 or 1 items selected) and Disabled, so that the user cannot click and highlight on any item.

The string to be displayed is to be given to ItemNames property. The cell background can be set as per your need. I have just set alternate cells to different colours.

Message 5 of 12
(4,673 Views)

Hi btanmay

 

Thanks for the reply and the demo VI. I can apply the colour coding to a completed string, but I would like to do it as the messages arrive. So my string / display control retains the colour coding information and I just add another entry with the correct colouring which is then retained. I would like the control to be able to hold a few thousand lines and I don't want to parse the control and re-apply the colour code every time I add a new entry.

0 Kudos
Message 6 of 12
(4,670 Views)

@Tarsel wrote:

I would like the control to be able to hold a few thousand lines and I don't want to parse the control and re-apply the colour code every time I add a new entry.


The messages themselves could be stored in a shift register array and wired to the Item Names property so updating the entire list shouldn't be problematic.  You could even have the array backwards (so new messages are added to the end) and then reverse the array just prior to wiring to the control.  This reduces memory usage for updating the array compared to inserting at the start of an array.

 

Unfortunately, the color settings are for an individual cell/row of a listbox can not be simply updated with an array of color values.  These would have to be updated for each individual row (since you plan to add new messages to the front, all cell colors are subject to change at each update).

 

0 Kudos
Message 7 of 12
(4,656 Views)

Hi pjr1121

 

Your last sentence is the issue I have found with a listbox - I would need to keep an array of colour information alongside my listbox!

 

As I mentioned, I have succeeded with the coloured log list previously in .NET using a richtextbox, but I have struggled with the control in Labview.

0 Kudos
Message 8 of 12
(4,648 Views)

That is correct.

 

You will have to build a cluster with {TheString,TheColor} store this in an extra array that gets updated. You delete old, add new and so on.

When ever needed you rewrite the array to the list.

 

Be sure to use "defer panel updates" while you are writing.

 

Gabi

 

7.1 -- 2013
CLA
0 Kudos
Message 9 of 12
(4,630 Views)

Attach your VI, I bet it won't be all that hard to color code the way you want, but I'd like to see just what you have to work with.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 10 of 12
(4,625 Views)