View Single Post
  #1   Spotlight this post!  
Unread 26-06-2015, 15:37
Jonathan L. Jonathan L. is offline
Registered User
FRC #1094
 
Join Date: Jan 2013
Location: St. Louis MO
Posts: 60
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:	42
Size:	209.0 KB
ID:	19170  Click image for larger version

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

Name:	Screenshot (96).png
Views:	32
Size:	241.2 KB
ID:	19172  
Reply With Quote