BowlerKernel
GetChannelModeCommand.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;
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.common.Log;
22 
23 // TODO: Auto-generated Javadoc
28 
33  setOpCode("gacm");
35  }
36 
42  public GetChannelModeCommand(int channel) {
43  setOpCode("gchm");
45  getCallingDataStorage().add(channel);
46  }
47 
48  /* (non-Javadoc)
49  * @see com.neuronrobotics.sdk.common.BowlerAbstractCommand#parseResponse(com.neuronrobotics.sdk.common.BowlerDatagram)
50  */
51  @Override
53  super.validate(data);
54 
55  if(!data.getRPC().equals(getOpCode())) {
56  throw new InvalidResponseException("Get Channel Mode did not return with '" + getOpCode() + "'.");
57  }
58 
59  if(!getOpCode().equals("gacm") ) {
60  Log.error("Failed gacm: \r\n"+data);
61  throw new InvalidResponseException("Get All Channel Mode did not return with 24 values."+data);
62  }
63 
64  if(getOpCode().equals("gchm") && data.getData().size() != 1) {
65  //throw new InvalidResponseException("Get Channel Mode did not return with 1 values.");
66  }
67 
68  return data;
69  }
70 }
synchronized boolean add(byte data)
Definition: ByteList.java:149
static void error(String message)
Definition: Log.java:92