Go to Post we need a diverse team, and until we can welcome someone that's not a nerd, I don't think we're really successful in our recruiting. - JBotAlan [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 11-01-2012, 00:21
frasnow's Avatar
frasnow frasnow is offline
Software
no team
Team Role: Mentor
 
Join Date: Jun 2010
Rookie Year: 2010
Location: Oregon
Posts: 83
frasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to beholdfrasnow is a splendid one to behold
Re: Java Help

I compared the source code for WPILib 2011 & 2012 and the developers changed the constructors for all the I/O to use
Code:
ConstructorName(int moduleNumber, int channel)
instead of the old
Code:
ConstructorName(int slot, int Channel)
The module number is not the same as the slot (OK it is for the first Analog module). The first digital I/O module located in slot 2 of the cRIO is actually module 1. In an 8 slot cRIO digital I/O module 2 should be placed in slot 6. Considering that the signatures of the old constructors and the new ones are the same, I can see lots of veteran teams making this mistake. Even if it is documented somewhere (I haven’t checked). The exceptions being thrown by WPILib don’t have the most helpful error messages in this regard.

Team 997 was also seeing the exception “Solenoid channel 1 on module 3 is already allocated", which makes it sound like our code had allocated solenoid channel 1 twice. We made it work by using the simple constructor where only the channel is specified. A better error message could have saved us time. The error really should say something about 3 being an invalid module number and suggest using 1 or 2 (The solenoid module in slot 3 is module 1). In fact the incorrect exception message actually appears to be masking an only slightly more useful exception CheckedAllocationException("Index " + index + " out of range");. Hiding an exception with one that gives false information is a bad programming practice.

Another way to fix this problem in WPILib would be to deprecate the old constructor and add a new one with a different signature. You can only have one of each module type, so a Boolean value would work for the module number.
Code:
ConstructorName(boolean isModuleOne, int Channel)
Reply With Quote
 


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 11:30.

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