BowlerKernel
PIDLimitEvent.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.pid;
2 
3 import com.neuronrobotics.sdk.common.BowlerDatagram;
4 import com.neuronrobotics.sdk.common.ByteList;
5 
6 // TODO: Auto-generated Javadoc
10 public class PIDLimitEvent {
11 
13  private int channel;
14 
16  private double ticks;
17 
19  private long timeStamp;
20 
23 
32  public PIDLimitEvent(int chan,double tick,PIDLimitEventType type,long time){
33  setGroup(chan);
34  setLimitType(type);
35  setValue(tick);
36  setTimeStamp(time);
37 
38  }
39 
46  if(!data.getRPC().contains("pidl"))
47  throw new RuntimeException("Datagram is not a PID event");
48  setGroup(data.getData().getByte(0));
50  setValue(ByteList.convertToInt(data.getData().getBytes(2, 4),true));
51  setTimeStamp(ByteList.convertToInt(data.getData().getBytes(6, 4),false));
52 
53  }
54 
60  public void setGroup(int channel) {
61  this.channel = channel;
62  }
63 
69  public int getGroup() {
70  return channel;
71  }
72 
78  public void setValue(double ticks) {
79  this.ticks = ticks;
80  }
81 
87  public double getValue() {
88  return ticks;
89  }
90 
96  public void setTimeStamp(long timeStamp) {
97  this.timeStamp = timeStamp;
98  }
99 
105  public long getTimeStamp() {
106  return timeStamp;
107  }
108 
109  /* (non-Javadoc)
110  * @see java.lang.Object#toString()
111  */
112  @Override
113  public String toString(){
114  return "chan="+channel+", Type="+limitType+", value="+ticks+", time="+timeStamp;
115  }
116 
122  public void setLimitType(PIDLimitEventType limitIndex) {
123  this.limitType = limitIndex;
124  }
125 
132  return limitType;
133  }
134 }
static final int convertToInt(byte[] b)
Definition: ByteList.java:911
PIDLimitEvent(int chan, double tick, PIDLimitEventType type, long time)
void setLimitType(PIDLimitEventType limitIndex)
static PIDLimitEventType get(byte code)