LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to move key focus onto newly added cluster in array

Solved!
Go to solution

Hi everyone,

 

I have been trying to develop a COM port serial number vi for batch tests. I want this interface to continually scan for new COM ports, and when it finds a new one, add it to the array on the front panel and move key focus to the Serial Number member in the cluster. This way the tester can plug in a COM port and then scan the board serial number with a barcode scanner to automatically fill out the Serial Number (without having to click the Serial number box).

I have the first part mostly working, but I am unable to set keyfocus onto the Serial number of the last cluster in the array. I have tried resizing the array to 1, setting the index to the last member and then setting the Keyfocus, but the keyfocus is lost when I resize the array back to what it was before.

Does anybody have any advice on how I can do this?

Download All
0 Kudos
Message 1 of 9
(3,153 Views)

In the registry, you could monitor

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\FTDIBUS\Enum

and read the value of Count.  That will tell you the number of COM port devices detected currently on the system.  To determine the actual port number, you would need to read in the numeric values up to (Count-1) for their location information.  This information uses the base location within the registry of:

 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS

then append the Count information less the first directory.  (Shortcut, otherwise we would go to the actual interface to get redirected back to FTDIBUS)  Now go down another level to the Count for that interface and select the FriendlyName.  The COM port is listed within the parenthesis.  (Most of today's device use the FTDIBUS - however, there may be some older devices that may need to be accounted for in your code)

 

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 2 of 9
(3,120 Views)

Thanks Minions, I'll change my COM port scan code using your suggestions. However, the main problem I am having is setting the Key Focus onto the Serial Number box in the array in MultipleCOMSandSerials.vi when a new COM port is found and added to the array. Any thoughts?

0 Kudos
Message 3 of 9
(3,117 Views)

You could add a U8 variable to your main vi called COMs and when this value changes from the received scan of the ports, either you can inform the user that a change has occurred with a Boolean or reset the multicolumn selector to request user input due to configuration changes.  Make sure that the port scanner vi runs independently from the event structure.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 4 of 9
(3,110 Views)

I'm already doing this in MultipleCOMsandSerials.vi

I think you're misunderstanding the problem... My problem is that I can't move key focus to the "Serial Number" box in the Array within MultipleCOMsandSerials.vi. It works for the first COM port, but if I plug in another, it doesn't focus. 

For example: 

Selected.jpg

COM12 is the first device plugged in. Immediately after it is plugged in, the cursor is focused on the "Serial Number" box next to it. This is the first element in the array of COM Port/SerialNumber clusters. The user can then scan a barcode and fill out this box without having to click in the Serial Number box (it is already selected).

 

 

Selected2.jpg

Now I plug in another device, COM14. The cursor is not focused on the Serial Number box next to COM14. This is my problem. I can't figure out a way to set the key focus to this second element's Serial Number.

0 Kudos
Message 5 of 9
(3,106 Views)

Couple of questions:

Why not use something like the following for finding COM ports? Does it not work for your COM ports?snip.png

 

 As far as changing you key focus you have do something like the followingsnip2.png

 

 

 

mcduff

 

 

 

 

 

0 Kudos
Message 6 of 9
(3,084 Views)

Hi mcduff,

Your COM port scan works, but it requires a bit more work. I will be constantly calling this VI as the tester plugs in the devices. The VISA Open and Close commands seem a bit unnecessary when I can just scan the registry for changes.

I tried implementing your code, but you only have NumRows set to 1. I have always been able to get it to Key Focus on the Serial Number member of the first row, but my problem is that I can't focus it on any other row. In my picture above, I can plug in one device and it will focus. When I plug in a second one, I can focus it, but then when I resize my array (change NumRows back to 2), the Key Focus is lost and I cannot type.

I honestly don't think that there is any way to get it to work. It's pretty ridiculous that you can't select the index of the array in the property node. Do you have any other ideas?

0 Kudos
Message 7 of 9
(3,037 Views)
Solution
Accepted by topic author tkappenm

If the key focus stays locked on the first element, then why not insert the new element into the beginning of the array rather than appending to the end?  Alternatively, continue to append to the array then invert it.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 8 of 9
(3,035 Views)

Hah, yeah I guess that that works! Thanks for the suggestion!

0 Kudos
Message 9 of 9
(3,027 Views)