BowlerKernel
DigitalOutputChannel.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 // TODO: Auto-generated Javadoc
34  this(((DyIO) DeviceManager.getSpecificDevice(DyIO.class, null)).getChannel(channel));
35  }
36 
44  public DigitalOutputChannel(DyIO dyio,int channel){
45  this(dyio.getChannel(channel));
46  }
47 
48 
56  super(channel,DyIOChannelMode.DIGITAL_OUT,false);
57 
58  if(!setMode()) {
59  throw new DyIOPeripheralException("Could not set channel " + channel + " to digital out mode");
60  }
61  }
62 
70  public boolean setHigh(boolean high) {
71  return setValue(high?1:0);
72  }
73 
79  public boolean isHigh() {
80  return getValue() != 0;
81  }
82 
83  /* (non-Javadoc)
84  * @see com.neuronrobotics.sdk.dyio.peripherals.DyIOAbstractPeripheral#hasAsync()
85  */
86  @Override
87  public boolean hasAsync() {
88  return false;
89  }
90 }
static Object getSpecificDevice(String name, IDeviceProvider provider)
DyIOChannel getChannel(int channel)
Definition: DyIO.java:160