BowlerKernel
SetChannelModeCommand.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.commands.bcs.io.setmode;
16 
17 import com.neuronrobotics.sdk.common.BowlerAbstractCommand;
18 import com.neuronrobotics.sdk.common.BowlerDatagram;
19 import com.neuronrobotics.sdk.common.BowlerMethod;
20 import com.neuronrobotics.sdk.common.InvalidResponseException;
21 import com.neuronrobotics.sdk.dyio.DyIOChannelMode;
22 
23 // TODO: Auto-generated Javadoc
28 
29 
36  public SetChannelModeCommand(int channel, DyIOChannelMode mode) {
37  setOpCode("schm");
39  getCallingDataStorage().add(channel);
40  getCallingDataStorage().add(mode);
42  }
43 
51  public SetChannelModeCommand(int channel, DyIOChannelMode mode,boolean isAsync) {
52  setOpCode("schm");
54  getCallingDataStorage().add(channel);
55  getCallingDataStorage().add(mode);
56  getCallingDataStorage().add((isAsync?1:0));
57  }
58 
59  /* (non-Javadoc)
60  * @see com.neuronrobotics.sdk.common.BowlerAbstractCommand#parseResponse(com.neuronrobotics.sdk.common.BowlerDatagram)
61  */
62  @Override
64  super.validate(data);
65  if(!(data.getRPC().equals("_rdy") || data.getRPC().equals("schm")||data.getRPC().equals("gacm"))) {
66  throw new InvalidResponseException("Set Channel Mode did not return '_rdy' or 'schm'.");
67  }
68 
69  return data;
70  }
71 }
SetChannelModeCommand(int channel, DyIOChannelMode mode, boolean isAsync)
synchronized boolean add(byte data)
Definition: ByteList.java:149