BowlerKernel
DCMotorOutputChannel.java
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright 2010 Neuron Robotics, LLC
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  ******************************************************************************/
15 package com.neuronrobotics.sdk.dyio.peripherals;
16 
17 import com.neuronrobotics.sdk.dyio.DyIO;
18 import com.neuronrobotics.sdk.dyio.DyIOChannel;
19 import com.neuronrobotics.sdk.dyio.DyIOChannelMode;
20 import com.neuronrobotics.sdk.common.DeviceManager;
21 
22 
23 // TODO: Auto-generated Javadoc
28 
36  this(((DyIO) DeviceManager.getSpecificDevice(DyIO.class, null)).getChannel(channel));
37  }
38 
46  public DCMotorOutputChannel(DyIO dyio,int channel){
47  this(dyio.getChannel(channel));
48  }
49 
50 
59 
60  if(!setMode()) {
61  throw new DyIOPeripheralException("Could not set channel " + channel + " to DC motor output mode");
62  }
63  }
64 
71  public void SetVelocity(float velocity){
72 
73  if (velocity > 100) {
74  velocity = 100;
75  }
76 
77  if (velocity<-100) {
78  velocity=-100;
79  }
80 
81  setValue((int)((velocity / 100) * 128)+128);
82  }
83 
84  /* (non-Javadoc)
85  * @see com.neuronrobotics.sdk.dyio.peripherals.DyIOAbstractPeripheral#hasAsync()
86  */
87  @Override
88  public boolean hasAsync() {
89  return false;
90  }
91 }
static Object getSpecificDevice(String name, IDeviceProvider provider)
DyIOChannel getChannel(int channel)
Definition: DyIO.java:160