BowlerKernel
java-bowler
src
main
java
com
neuronrobotics
sdk
dyio
DyIOChannelEvent.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;
16
17
import
com.neuronrobotics.sdk.common.ByteList;
18
19
// TODO: Auto-generated Javadoc
25
public
class
DyIOChannelEvent
{
26
28
private
ByteList
data
;
29
31
private
DyIOChannel
channel
;
32
34
private
Integer
integer
;
35
42
public
DyIOChannelEvent
(
DyIOChannel
channel
,
ByteList
data
) {
43
this.channel =
channel
;
44
this.data =
data
;
45
}
46
53
public
DyIOChannelEvent
(
DyIOChannel
c, Integer
integer
) {
54
// TODO Auto-generated constructor stub
55
this.channel =c;
56
this.integer =
integer
;
57
58
}
59
65
public
DyIOChannel
getChannel
() {
66
return
channel
;
67
}
68
74
public
ByteList
getData
() {
75
return
data
;
76
}
77
83
public
int
getValue
() {
84
if
(
integer
!=
null
)
85
return
integer
;
86
int
value;
87
DyIOChannelMode
mode =
getChannel
().
getCurrentMode
();
88
if
(
channel
.
isStreamChannel
())
89
return
0;
90
switch
(mode){
91
case
COUNT_IN_DIR:
92
case
COUNT_IN_INT:
93
case
COUNT_OUT_DIR:
94
case
COUNT_OUT_INT:
95
value =
getSignedValue
();
96
break
;
97
default
:
98
value =
getUnsignedValue
();
99
break
;
100
}
101
return
value;
102
}
103
109
public
int
getUnsignedValue
() {
110
if
(
integer
!=
null
)
111
return
integer
;
112
return
ByteList
.
convertToInt
(
getData
().getBytes(),
false
);
113
}
114
120
public
int
getSignedValue
() {
121
if
(
integer
!=
null
)
122
return
integer
;
123
int
value =
ByteList
.
convertToInt
(
getData
().getBytes(),
true
);
124
return
value;
125
}
126
}
com.neuronrobotics.sdk.common.ByteList
Definition:
ByteList.java:32
com.neuronrobotics.sdk.common.ByteList.convertToInt
static final int convertToInt(byte[] b)
Definition:
ByteList.java:911
com.neuronrobotics.sdk.dyio.DyIOChannelEvent
Definition:
DyIOChannelEvent.java:25
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.getSignedValue
int getSignedValue()
Definition:
DyIOChannelEvent.java:120
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.DyIOChannelEvent
DyIOChannelEvent(DyIOChannel c, Integer integer)
Definition:
DyIOChannelEvent.java:53
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.getValue
int getValue()
Definition:
DyIOChannelEvent.java:83
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.channel
DyIOChannel channel
Definition:
DyIOChannelEvent.java:31
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.data
ByteList data
Definition:
DyIOChannelEvent.java:28
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.getUnsignedValue
int getUnsignedValue()
Definition:
DyIOChannelEvent.java:109
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.integer
Integer integer
Definition:
DyIOChannelEvent.java:34
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.getData
ByteList getData()
Definition:
DyIOChannelEvent.java:74
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.getChannel
DyIOChannel getChannel()
Definition:
DyIOChannelEvent.java:65
com.neuronrobotics.sdk.dyio.DyIOChannelEvent.DyIOChannelEvent
DyIOChannelEvent(DyIOChannel channel, ByteList data)
Definition:
DyIOChannelEvent.java:42
com.neuronrobotics.sdk.dyio.DyIOChannel
Definition:
DyIOChannel.java:39
com.neuronrobotics.sdk.dyio.DyIOChannel.getCurrentMode
DyIOChannelMode getCurrentMode()
Definition:
DyIOChannel.java:773
com.neuronrobotics.sdk.dyio.DyIOChannel.isStreamChannel
boolean isStreamChannel()
Definition:
DyIOChannel.java:831
com.neuronrobotics.sdk.dyio.DyIOChannelMode
Definition:
DyIOChannelMode.java:29
Generated by
1.9.1