// Path: src/main/java/nu/nethome/coders/RollerTrolG.java
// public class RollerTrolG {
//     public static final String ROLLER_TROL_G_PROTOCOL_NAME = "RollerTrolG";
//     public static final int PROTOCOL_BIT_LENGTH = 40;
//     public static final ProtocolInfo ROLLERTROL_PROTOCOL_INFO = new ProtocolInfo(ROLLER_TROL_G_PROTOCOL_NAME, "Mark Length", "RollerTrol", PROTOCOL_BIT_LENGTH, 1);
// 
//     public static final int COMMAND_STOP = 0x55;
//     public static final int COMMAND_UP = 0x11;
//     public static final int COMMAND_UP_END = 0x1E;
//     public static final int COMMAND_DOWN = 0x33;
//     public static final int COMMAND_DOWN_END = 0x3C;
//     public static final int COMMAND_LEARN = 0xCC;
// 
//     public static final PulseLength LONG_PREAMBLE_MARK =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_MARK", 5170, 4000, 5900);
//     public static final PulseLength LONG_PREAMBLE_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_SPACE", 1665, 1000, 2000);
//     public static final PulseLength SHORT =
//             new PulseLength(RollerTrolGDecoder.class, "SHORT", 360, 200, 500);
//     public static final PulseLength LONG =
//             new PulseLength(RollerTrolGDecoder.class, "LONG", 770, 600, 900);
//     public static final PulseLength REPEAT_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "REPEAT_SPACE", 7400, 7000, 11000);
// 
//     public static final BitString.Field COMMAND = new BitString.Field(0, 8);
//     public static final BitString.Field CHANNEL = new BitString.Field(8, 4);
//     public static final BitString.Field ADDRESS = new BitString.Field(12, 28);
//     public static final String COMMAND_NAME = "Command";
//     public static final String CHANNEL_NAME = "Channel";
//     public static final String ADDRESS_NAME = "Address";
// }
// 
// Path: src/main/java/nu/nethome/coders/RollerTrolG.java
// public class RollerTrolG {
//     public static final String ROLLER_TROL_G_PROTOCOL_NAME = "RollerTrolG";
//     public static final int PROTOCOL_BIT_LENGTH = 40;
//     public static final ProtocolInfo ROLLERTROL_PROTOCOL_INFO = new ProtocolInfo(ROLLER_TROL_G_PROTOCOL_NAME, "Mark Length", "RollerTrol", PROTOCOL_BIT_LENGTH, 1);
// 
//     public static final int COMMAND_STOP = 0x55;
//     public static final int COMMAND_UP = 0x11;
//     public static final int COMMAND_UP_END = 0x1E;
//     public static final int COMMAND_DOWN = 0x33;
//     public static final int COMMAND_DOWN_END = 0x3C;
//     public static final int COMMAND_LEARN = 0xCC;
// 
//     public static final PulseLength LONG_PREAMBLE_MARK =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_MARK", 5170, 4000, 5900);
//     public static final PulseLength LONG_PREAMBLE_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_SPACE", 1665, 1000, 2000);
//     public static final PulseLength SHORT =
//             new PulseLength(RollerTrolGDecoder.class, "SHORT", 360, 200, 500);
//     public static final PulseLength LONG =
//             new PulseLength(RollerTrolGDecoder.class, "LONG", 770, 600, 900);
//     public static final PulseLength REPEAT_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "REPEAT_SPACE", 7400, 7000, 11000);
// 
//     public static final BitString.Field COMMAND = new BitString.Field(0, 8);
//     public static final BitString.Field CHANNEL = new BitString.Field(8, 4);
//     public static final BitString.Field ADDRESS = new BitString.Field(12, 28);
//     public static final String COMMAND_NAME = "Command";
//     public static final String CHANNEL_NAME = "Channel";
//     public static final String ADDRESS_NAME = "Address";
// }


import nu.nethome.coders.RollerTrolG;
import nu.nethome.util.ps.*;
import static nu.nethome.coders.RollerTrolG.*;
package nu.nethome.coders.encoders;



/**
 *
 */
public class RollerTrolGEncoder implements ProtocolEncoder {

    public static final int PREAMBLE_LENGTH = 2;
    public static final int CONSTANT_FIELD_VALUE = 1;

    @Override
    public ProtocolInfo getInfo() {
        return ROLLERTROL_PROTOCOL_INFO;
    }

    @Override
    public int[] encode(Message message, Phase phase) throws BadMessageException {
        int address = 0;
        int channel = 0;
        int command = 0;
        for (FieldValue f : message.getFields()) {
// Path: src/main/java/nu/nethome/coders/RollerTrolG.java
// public class RollerTrolG {
//     public static final String ROLLER_TROL_G_PROTOCOL_NAME = "RollerTrolG";
//     public static final int PROTOCOL_BIT_LENGTH = 40;
//     public static final ProtocolInfo ROLLERTROL_PROTOCOL_INFO = new ProtocolInfo(ROLLER_TROL_G_PROTOCOL_NAME, "Mark Length", "RollerTrol", PROTOCOL_BIT_LENGTH, 1);
// 
//     public static final int COMMAND_STOP = 0x55;
//     public static final int COMMAND_UP = 0x11;
//     public static final int COMMAND_UP_END = 0x1E;
//     public static final int COMMAND_DOWN = 0x33;
//     public static final int COMMAND_DOWN_END = 0x3C;
//     public static final int COMMAND_LEARN = 0xCC;
// 
//     public static final PulseLength LONG_PREAMBLE_MARK =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_MARK", 5170, 4000, 5900);
//     public static final PulseLength LONG_PREAMBLE_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_SPACE", 1665, 1000, 2000);
//     public static final PulseLength SHORT =
//             new PulseLength(RollerTrolGDecoder.class, "SHORT", 360, 200, 500);
//     public static final PulseLength LONG =
//             new PulseLength(RollerTrolGDecoder.class, "LONG", 770, 600, 900);
//     public static final PulseLength REPEAT_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "REPEAT_SPACE", 7400, 7000, 11000);
// 
//     public static final BitString.Field COMMAND = new BitString.Field(0, 8);
//     public static final BitString.Field CHANNEL = new BitString.Field(8, 4);
//     public static final BitString.Field ADDRESS = new BitString.Field(12, 28);
//     public static final String COMMAND_NAME = "Command";
//     public static final String CHANNEL_NAME = "Channel";
//     public static final String ADDRESS_NAME = "Address";
// }
// 
// Path: src/main/java/nu/nethome/coders/RollerTrolG.java
// public class RollerTrolG {
//     public static final String ROLLER_TROL_G_PROTOCOL_NAME = "RollerTrolG";
//     public static final int PROTOCOL_BIT_LENGTH = 40;
//     public static final ProtocolInfo ROLLERTROL_PROTOCOL_INFO = new ProtocolInfo(ROLLER_TROL_G_PROTOCOL_NAME, "Mark Length", "RollerTrol", PROTOCOL_BIT_LENGTH, 1);
// 
//     public static final int COMMAND_STOP = 0x55;
//     public static final int COMMAND_UP = 0x11;
//     public static final int COMMAND_UP_END = 0x1E;
//     public static final int COMMAND_DOWN = 0x33;
//     public static final int COMMAND_DOWN_END = 0x3C;
//     public static final int COMMAND_LEARN = 0xCC;
// 
//     public static final PulseLength LONG_PREAMBLE_MARK =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_MARK", 5170, 4000, 5900);
//     public static final PulseLength LONG_PREAMBLE_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "LONG_PREAMBLE_SPACE", 1665, 1000, 2000);
//     public static final PulseLength SHORT =
//             new PulseLength(RollerTrolGDecoder.class, "SHORT", 360, 200, 500);
//     public static final PulseLength LONG =
//             new PulseLength(RollerTrolGDecoder.class, "LONG", 770, 600, 900);
//     public static final PulseLength REPEAT_SPACE =
//             new PulseLength(RollerTrolGDecoder.class, "REPEAT_SPACE", 7400, 7000, 11000);
// 
//     public static final BitString.Field COMMAND = new BitString.Field(0, 8);
//     public static final BitString.Field CHANNEL = new BitString.Field(8, 4);
//     public static final BitString.Field ADDRESS = new BitString.Field(12, 28);
//     public static final String COMMAND_NAME = "Command";
//     public static final String CHANNEL_NAME = "Channel";
//     public static final String ADDRESS_NAME = "Address";
// }


// Path: src/main/java/nu/nethome/coders/encoders/RollerTrolGEncoder.java
import nu.nethome.coders.RollerTrolG;
import nu.nethome.util.ps.*;
import static nu.nethome.coders.RollerTrolG.*;

package nu.nethome.coders.encoders;



/**
 *
 */
public class RollerTrolGEncoder implements ProtocolEncoder {

    public static final int PREAMBLE_LENGTH = 2;
    public static final int CONSTANT_FIELD_VALUE = 1;

    @Override
    public ProtocolInfo getInfo() {
        return ROLLERTROL_PROTOCOL_INFO;
    }

    @Override
    public int[] encode(Message message, Phase phase) throws BadMessageException {
        int address = 0;
        int channel = 0;
        int command = 0;
        for (FieldValue f : message.getFields()) {
            if (RollerTrolG.ADDRESS_NAME.equals(f.getName())) {