Go to Post My calculations indicate that the game will involve pouring large areas of concrete and waiting for it to dry. Field reset should be interesting. - DampRobot [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-06-2015, 15:37
Jonathan L. Jonathan L. is offline
Programmer alumnus, mentor, and CSA
FRC #1094 (Channel Cats)
 
Join Date: Jan 2013
Rookie Year: 2011
Location: St. Louis MO
Posts: 78
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
E-num text not being sent to Dashboard when Compiled

Earlier this year during build season my team was putting together a number of automodes and we needed a way of selecting a specific mode from a drop-down menu on the Dashboard program. Below is a description of what we tried to do; I will then explain the problem. I have also included some screen shots. We had some communication issues between the Dashboard and the Robot but that is not what I'm asking about in this post.


In the Robot Project make an E-num control and add each of the automode names to it and make it a Type Def. Put this E-num in the Autonomous VI and wire it to a case structure. The code for each mode can be added to each case of the case structure. We'll come back here before we're done. Next add a copy of the E-num to the Periodic Tasks VI as a Control. Then right-click on the new control and select Create -> Property Node -> Strings[]. This reads the text from all the items in the E-num control. Then send that to the Dashboard Program via a SD Write String Array. We should be able to put this code in the Begin VI but for the purpose of Debugging we'll put it in a While Loop in Periodic Tasks and add a 5000ms Wait function.

In the Dashboard Project add a Ring Control (not an E-num) to the Dashboard Main VI. As before right-click the control and create a Property Node except this time we want to write to it. Read the Smart Dashboard variable and write it's data to the Property Node. We also need to send the selected mode back to the robot and we can do this with the SD Write Number VI. Note this is not sending the data back in an E-num, it is only sending the integer value of the E-num selection.

Back in the Autonomous VI remove the wire connecting the E-num to the case structure. Read the Smart Dashboard variable that tells us which mode is selected. Since the representation of the number we are reading is "double" and we are about to use the Type Cast function to convert it we need first to explicitly convert it to an unsigned 16 bit integer, then use Type Cast to convert it to an E-num with our automode names. The output of Type Cast is wired to the case structure and we are done.

This way all we need to do to add a new mode is to edit the Type Def. and add a case to the case structure. The drop-down menu on the Dashboard will automatically update when the robot connects to the Dashboard.


When we tested this by clicking the run arrow in Robot Main, it worked. But when we compiled the robot code and deployed it to the robot permanently, the drop-down menu would not populate on the Dashboard and we would get error 1055 "Object reference is invalid" from the property node in Periodic Tasks. My guess is that the text items in the E-num are being removed from it when the code is compiled but I don't know how to correct this. Since this didn't work we replaced the property node in Periodic Tasks with a constant and removed the Type Cast from the Autonomous VI.

Any help would be appreciated. Feel free to use this idea in your code.
Attached Thumbnails
Click image for larger version

Name:	Screenshot (94).png
Views:	43
Size:	209.0 KB
ID:	19170  Click image for larger version

Name:	Screenshot (95).png
Views:	35
Size:	189.4 KB
ID:	19171  Click image for larger version

Name:	Screenshot (96).png
Views:	33
Size:	241.2 KB
ID:	19172  
Reply With Quote
  #2   Spotlight this post!  
Unread 27-06-2015, 08:18
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: E-num text not being sent to Dashboard when Compiled

When you are using a property node, you are talking directly to the front panel control such as the enum. But the default when building an RT application is to remove all panels. So that is why the EXE doesn't work the way you expect. If you were to debug further, you'd get an error from the property node, hopefully it is in the log file and messages window, telling you that the control doesn't exist.

There are a couple ways to make this work in an EXE. At least on the desktop, you can change the build to leave the panel in the app. That is accomplished by opening up the Build Specification and going to the Source File Settings where you will select your Autonomous VI, or whichever VI has the enum on its panel. In the right middle of the dialog are checkboxes for deciding whether the diagram and panel are removed and how they default. If you change this setting for this single VI, I suspect that will work.

The other way, and the way to do this enum introspection is to use the Format into String node. This will also turn enums into strings, but one at a time. So this is how the test mode and other framework elements tend to get extra name info to send back and forth between the dashboard and the code.

Good job figuring out how to get this to automatically update.
Greg McKaskle
Reply With Quote
  #3   Spotlight this post!  
Unread 27-06-2015, 09:32
Jonathan L. Jonathan L. is offline
Programmer alumnus, mentor, and CSA
FRC #1094 (Channel Cats)
 
Join Date: Jan 2013
Rookie Year: 2011
Location: St. Louis MO
Posts: 78
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
Re: E-num text not being sent to Dashboard when Compiled

I'm not sure, but I think I tried keeping the front panel in the build before with no success but I'll try it again. I have done this with some other applications (not FRC) where I need to programmatically open a subVI's front panel.

The Format into String method looks like it will work well. I have been looking for a function that will do this for a long time.

I will try both ways on the robot. Thanks!
Reply With Quote
  #4   Spotlight this post!  
Unread 19-07-2015, 20:47
Jonathan L. Jonathan L. is offline
Programmer alumnus, mentor, and CSA
FRC #1094 (Channel Cats)
 
Join Date: Jan 2013
Rookie Year: 2011
Location: St. Louis MO
Posts: 78
Jonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the roughJonathan L. is a jewel in the rough
Re: E-num text not being sent to Dashboard when Compiled

I tested both methods on a robot.

Method 1. I kept the Front Panel (and block Diagram just to be sure) in the build. Once the code was deployed the drop-down menu did not populate and I still got an error about the property node.

Method 2. I put together some code similar to that attached and put it in the Periodic Tasks VI with a While Loop around it and a 5 second delay. It worked. I then moved the code to the Begin VI without the While Loop with success.

Thanks
Attached Thumbnails
Click image for larger version

Name:	E-num to Array of Strings.png
Views:	24
Size:	24.0 KB
ID:	19222  
Reply With Quote
  #5   Spotlight this post!  
Unread 19-07-2015, 22:37
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: E-num text not being sent to Dashboard when Compiled

Method 1 would work on a desktop, but generally, RT will not execute UI-centric code. It does graphing and other controls and indicators, but not properties or events.

Greg McKaskle
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 21:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi