Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Solenoid Programming Errors (http://www.chiefdelphi.com/forums/showthread.php?t=125204)

[martinskot] 25-01-2014 10:49

Solenoid Programming Errors
 
Hi CD,

This is my first year programming, and 4618's first year using pneumatics. I've programmed according to the WPIlib screensteps and I keep getting an error every time I save and build the program.
Here's what I've done(copied from sections of the program):

DoubleSolenoid *m_leftShifter;

m_leftShifter = new DoubleSolenoid(LEFT_DRIVE_LOW,LEFT_DRIVE_HIGH);

m_leftShifter.set(DoubleSolenoid.Value.kForward);

If someone could tell me what I'm doing wrong or how to fix this it would really be appreciated. If it helps, programming it as a Solenoid instead of DoubleSolenoid and using m_leftShifter.set(true); did not get rid of the problem.

EDIT: I could set a motor value successfully, just not the solenoids.

Thanks

bvisness 25-01-2014 16:54

Re: Solenoid Programming Errors
 
The code in the WPI documentation tends to be for Java, not C++, and it looks like that's what you've written here. (At least on the third line.)

Notice that m_leftShifter is of type DoubleSolenoid*. That means it's a pointer to a DoubleSolenoid object, and so to access methods of that object (like Set()) you need to use the arrow operator (->).

Try this code instead:

Code:

DoubleSolenoid *m_leftShifter;
m_leftShifter = new DoubleSolenoid(LEFT_DRIVE_LOW,LEFT_DRIVE_HIGH);
m_leftShifter->Set(DoubleSolenoid::kForward);


[martinskot] 25-01-2014 21:01

Re: Solenoid Programming Errors
 
That works! Thanks a ton (metric,of course).


All times are GMT -5. The time now is 12:04.

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