/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simulator.payloads.translators;
import java.util.BitSet;
import simulator.payloads.CanMailbox;
/**
* Translates a single boolean value into a 4-byte payload.
*
* @author Justin Ray
*/
public class BooleanCanPayloadTranslator extends CanPayloadTranslator {
public BooleanCanPayloadTranslator(CanMailbox payload) {
super(payload, 4);
}
// required for reflection
public void set(boolean value) {
setValue(value);
}
public void setValue(boolean value) {
BitSet b = new BitSet(32);
b.set(31, value);
mailbox.setMessagePayload(b, byteSize);
}
public boolean getValue() {
return mailbox.getMessagePayload().get(31);
}
@Override
public String payloadToString() {
return Boolean.toString(getValue());
}
}
|