BowlerKernel
AsyncThreshholdEdgeType.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.commands.bcs.io;
2 
3 import java.util.EnumSet;
4 import java.util.HashMap;
5 import java.util.Map;
6 
7 import com.neuronrobotics.sdk.common.ISendable;
8 
9 // TODO: Auto-generated Javadoc
13 public enum AsyncThreshholdEdgeType implements ISendable{
14 
17  BOTH(0x00),
18 
20  RISING(0x01),
21 
23  FALLING(0x02);
24 
25  /* (non-Javadoc)
26  * @see java.lang.Enum#toString()
27  */
28  public String toString(){
29  String s="NOT VALID";
30  switch (value){
31  case 0x00:
32  return "ASYN_BOTH";
33  case 0x01:
34  return "ASYN_RISING ";
35  case 0x02:
36  return "ASYN_FALLING";
37  }
38  return s;
39  }
40 
42  private static final Map<Byte,AsyncThreshholdEdgeType> lookup = new HashMap<Byte,AsyncThreshholdEdgeType>();
43 
44  static {
45  for(AsyncThreshholdEdgeType cm : EnumSet.allOf(AsyncThreshholdEdgeType.class)) {
46  lookup.put(cm.getValue(), cm);
47  }
48  }
49 
51  private byte value;
52 
58  private AsyncThreshholdEdgeType(int val) {
59  value = (byte) val;
60  }
61 
67  public byte getValue() {
68  return value;
69  }
70 
77  public static AsyncThreshholdEdgeType get(byte code) {
78  return lookup.get(code);
79  }
80 
81  /* (non-Javadoc)
82  * @see com.neuronrobotics.sdk.common.ISendable#getBytes()
83  */
84  public byte[] getBytes() {
85  byte [] b = {getValue()};
86  return b;
87  }
88 
89 
90 }