text:
//
//  LxProtocolLight.java
//  LIFX
//
//  Created by Jarrod Boyes on 24/03/14.
//  Copyright (c) 2014 LIFX Labs. All rights reserved.
//

// Start File: @./LxProtocolLight.java

package lifx.java.android.entities.internal.structle;

/*
    **** GENERATED CODE ****
	Start Of File: LxProtocolLight.java
*/

import android.annotation.SuppressLint;

import java.util.HashMap;

import lifx.java.android.entities.internal.structle.StructleTypes.Bool8;
import lifx.java.android.entities.internal.structle.StructleTypes.Float32;
import lifx.java.android.entities.internal.structle.StructleTypes.Int16;
import lifx.java.android.entities.internal.structle.StructleTypes.Int32;
import lifx.java.android.entities.internal.structle.StructleTypes.Int64;
import lifx.java.android.entities.internal.structle.StructleTypes.LxProtocolTypeBase;
import lifx.java.android.entities.internal.structle.StructleTypes.ProtocolField;
import lifx.java.android.entities.internal.structle.StructleTypes.RoutingField;
import lifx.java.android.entities.internal.structle.StructleTypes.UInt16;
import lifx.java.android.entities.internal.structle.StructleTypes.UInt32;
import lifx.java.android.entities.internal.structle.StructleTypes.UInt64;
import lifx.java.android.entities.internal.structle.StructleTypes.UInt8;
import lifx.java.android.util.LFXLog;

@SuppressLint("UseSparseArrays")
@SuppressWarnings("unused")
public class LxProtocolLight {
    public enum Waveform                                    // Enum Lx::Protocol::Light::Waveform
    {
        LX_PROTOCOL_LIGHT_WAVEFORM_SAW,                // LX_PROTOCOL_LIGHT_WAVEFORM_SAW = 0
        LX_PROTOCOL_LIGHT_WAVEFORM_SINE,                // LX_PROTOCOL_LIGHT_WAVEFORM_SINE = 1
        LX_PROTOCOL_LIGHT_WAVEFORM_HALF_SINE,                // LX_PROTOCOL_LIGHT_WAVEFORM_HALF_SINE = 2
        LX_PROTOCOL_LIGHT_WAVEFORM_TRIANGLE,                // LX_PROTOCOL_LIGHT_WAVEFORM_TRIANGLE = 3
        LX_PROTOCOL_LIGHT_WAVEFORM_PULSE,                // LX_PROTOCOL_LIGHT_WAVEFORM_PULSE = 4
    }

    ;

    public static HashMap<Waveform, Integer> waveformValueMap;
    public static HashMap<Integer, Waveform> waveformMap;

    static {
        waveformValueMap = new HashMap<Waveform, Integer>();
        waveformMap = new HashMap<Integer, Waveform>();
        waveformValueMap.put(Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_SAW, 0);
        waveformMap.put(0, Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_SAW);
        waveformValueMap.put(Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_SINE, 1);
        waveformMap.put(1, Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_SINE);
        waveformValueMap.put(Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_HALF_SINE, 2);
        waveformMap.put(2, Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_HALF_SINE);
        waveformValueMap.put(Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_TRIANGLE, 3);
        waveformMap.put(3, Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_TRIANGLE);
        waveformValueMap.put(Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_PULSE, 4);
        waveformMap.put(4, Waveform.LX_PROTOCOL_LIGHT_WAVEFORM_PULSE);

    }

    ;

    public static class Hsbk extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::Hsbk
    {
        // Fields: hue, saturation, brightness, kelvin;
        private UInt16 hue;            // Field: hue - Structle::Uint16 byte offset: 0
        private UInt16 saturation;            // Field: saturation - Structle::Uint16 byte offset: 2
        private UInt16 brightness;            // Field: brightness - Structle::Uint16 byte offset: 4
        private UInt16 kelvin;            // Field: kelvin - Structle::Uint16 byte offset: 6

        private static final int PAYLOAD_SIZE = 8;

        public Hsbk(byte[] bytes) {
            this(bytes, 0);
        }

        public Hsbk(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[2];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];

            hue = new UInt16(member0Data);

            byte[] member1Data = new byte[2];
            member1Data[0] = bytes[initialOffset + 2];
            member1Data[1] = bytes[initialOffset + 3];

            saturation = new UInt16(member1Data);

            byte[] member2Data = new byte[2];
            member2Data[0] = bytes[initialOffset + 4];
            member2Data[1] = bytes[initialOffset + 5];

            brightness = new UInt16(member2Data);

            byte[] member3Data = new byte[2];
            member3Data[0] = bytes[initialOffset + 6];
            member3Data[1] = bytes[initialOffset + 7];

            kelvin = new UInt16(member3Data);

        }

        public Hsbk(Object padding
                , UInt16 hue
                , UInt16 saturation
                , UInt16 brightness
                , UInt16 kelvin
        ) {
            this.hue = hue;
            this.saturation = saturation;
            this.brightness = brightness;
            this.kelvin = kelvin;
        }

        public UInt16 getHue() {
            return hue;
        }

        public UInt16 getSaturation() {
            return saturation;
        }

        public UInt16 getBrightness() {
            return brightness;
        }

        public UInt16 getKelvin() {
            return kelvin;
        }

        public void printMessageData() {
            hue.printValue("hue");            // Field: hue - Structle::Uint16 byte offset: 8
            saturation.printValue("saturation");            // Field: saturation - Structle::Uint16 byte offset: 8
            brightness.printValue("brightness");            // Field: brightness - Structle::Uint16 byte offset: 8
            kelvin.printValue("kelvin");            // Field: kelvin - Structle::Uint16 byte offset: 8
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , UInt16 hue
                , UInt16 saturation
                , UInt16 brightness
                , UInt16 kelvin
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = hue.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = saturation.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = kelvin.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , UInt16 hue
                , UInt16 saturation
                , UInt16 brightness
                , UInt16 kelvin
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , hue
                    , saturation
                    , brightness
                    , kelvin
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = hue.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = saturation.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = kelvin.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class Get extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::Get
    {

        private static final int PAYLOAD_SIZE = 0;

        public Get(byte[] bytes) {
            this(bytes, 0);
        }

        public Get(byte[] bytes, int initialOffset) {
        }

        public Get(Object padding
        ) {
        }

        public void printMessageData() {
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
        ) {
            byte[] memberData;        // = name.getBytes();

        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class Set extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::Set
    {
        // Fields: stream, color, duration;
        private UInt8 stream;            // Field: stream - Structle::Uint8 byte offset: 0
        private Hsbk color;        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 1
        private UInt32 duration;            // Field: duration - Structle::Uint32 byte offset: 9

        private static final int PAYLOAD_SIZE = 13;

        public Set(byte[] bytes) {
            this(bytes, 0);
        }

        public Set(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[1];
            member0Data[0] = bytes[initialOffset + 0];

            stream = new UInt8(member0Data);

            byte[] member1Data = new byte[8];
            member1Data[0] = bytes[initialOffset + 1];
            member1Data[1] = bytes[initialOffset + 2];
            member1Data[2] = bytes[initialOffset + 3];
            member1Data[3] = bytes[initialOffset + 4];
            member1Data[4] = bytes[initialOffset + 5];
            member1Data[5] = bytes[initialOffset + 6];
            member1Data[6] = bytes[initialOffset + 7];
            member1Data[7] = bytes[initialOffset + 8];

            color = new Hsbk(member1Data);        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 1

            byte[] member2Data = new byte[4];
            member2Data[0] = bytes[initialOffset + 9];
            member2Data[1] = bytes[initialOffset + 10];
            member2Data[2] = bytes[initialOffset + 11];
            member2Data[3] = bytes[initialOffset + 12];

            duration = new UInt32(member2Data);

        }

        public Set(Object padding
                , UInt8 stream
                , Hsbk color
                , UInt32 duration
        ) {
            this.stream = stream;
            this.color = color;
            this.duration = duration;
        }

        public UInt8 getStream() {
            return stream;
        }

        public Hsbk getColor() {
            return color;
        }

        ;

        public UInt32 getDuration() {
            return duration;
        }

        public void printMessageData() {
            stream.printValue("stream");            // Field: stream - Structle::Uint8 byte offset: 13
            color.printMessageData();        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 13
            duration.printValue("duration");            // Field: duration - Structle::Uint32 byte offset: 13
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , UInt8 stream
                , Hsbk color
                , UInt32 duration
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = stream.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , UInt8 stream
                , Hsbk color
                , UInt32 duration
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , stream
                    , color
                    , duration
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = stream.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class SetWaveform extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::SetWaveform
    {
        // Fields: stream, transient, color, period, cycles, duty_cycle, waveform;
        private UInt8 stream;            // Field: stream - Structle::Uint8 byte offset: 0
        private Bool8 transienttype;            // Field: transienttype - Structle::Bool byte offset: 1
        private Hsbk color;        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 2
        private UInt32 period;            // Field: period - Structle::Uint32 byte offset: 10
        private Float32 cycles;                // Field: cycles - Structle::Float byte offset: 14
        private Int16 duty_cycle;                // Field: duty_cycle - Structle::Int16 byte offset: 18
        private UInt8 waveform;            // Field: waveform - Structle::Uint8 byte offset: 20

        private static final int PAYLOAD_SIZE = 21;

        public SetWaveform(byte[] bytes) {
            this(bytes, 0);
        }

        public SetWaveform(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[1];
            member0Data[0] = bytes[initialOffset + 0];

            stream = new UInt8(member0Data);

            byte[] member1Data = new byte[1];
            member1Data[0] = bytes[initialOffset + 1];

            transienttype = new Bool8(member1Data);

            byte[] member2Data = new byte[8];
            member2Data[0] = bytes[initialOffset + 2];
            member2Data[1] = bytes[initialOffset + 3];
            member2Data[2] = bytes[initialOffset + 4];
            member2Data[3] = bytes[initialOffset + 5];
            member2Data[4] = bytes[initialOffset + 6];
            member2Data[5] = bytes[initialOffset + 7];
            member2Data[6] = bytes[initialOffset + 8];
            member2Data[7] = bytes[initialOffset + 9];

            color = new Hsbk(member2Data);        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 2

            byte[] member3Data = new byte[4];
            member3Data[0] = bytes[initialOffset + 10];
            member3Data[1] = bytes[initialOffset + 11];
            member3Data[2] = bytes[initialOffset + 12];
            member3Data[3] = bytes[initialOffset + 13];

            period = new UInt32(member3Data);

            byte[] member4Data = new byte[4];
            member4Data[0] = bytes[initialOffset + 14];
            member4Data[1] = bytes[initialOffset + 15];
            member4Data[2] = bytes[initialOffset + 16];
            member4Data[3] = bytes[initialOffset + 17];

            cycles = new Float32(member4Data);

            byte[] member5Data = new byte[2];
            member5Data[0] = bytes[initialOffset + 18];
            member5Data[1] = bytes[initialOffset + 19];

            duty_cycle = new Int16(member5Data);

            byte[] member6Data = new byte[1];
            member6Data[0] = bytes[initialOffset + 20];

            waveform = new UInt8(member6Data);

        }

        public SetWaveform(Object padding
                , UInt8 stream
                , Bool8 transienttype
                , Hsbk color
                , UInt32 period
                , Float32 cycles
                , Int16 duty_cycle
                , UInt8 waveform
        ) {
            this.stream = stream;
            this.transienttype = transienttype;
            this.color = color;
            this.period = period;
            this.cycles = cycles;
            this.duty_cycle = duty_cycle;
            this.waveform = waveform;
        }

        public UInt8 getStream() {
            return stream;
        }

        public Bool8 getTransienttype() {
            return transienttype;
        }

        public Hsbk getColor() {
            return color;
        }

        ;

        public UInt32 getPeriod() {
            return period;
        }

        public Float32 getCycles() {
            return cycles;
        }

        public Int16 getDuty_cycle() {
            return duty_cycle;
        }

        public UInt8 getWaveform() {
            return waveform;
        }

        public void printMessageData() {
            stream.printValue("stream");            // Field: stream - Structle::Uint8 byte offset: 21
            transienttype.printValue("transienttype");            // Field: transienttype - Structle::Bool byte offset: 21
            color.printMessageData();        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 21
            period.printValue("period");            // Field: period - Structle::Uint32 byte offset: 21
            cycles.printValue("cycles");                // Field: cycles - Structle::Float byte offset: 21
            duty_cycle.printValue("duty_cycle");                // Field: duty_cycle - Structle::Int16 byte offset: 21
            waveform.printValue("waveform");            // Field: waveform - Structle::Uint8 byte offset: 21
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , UInt8 stream
                , Bool8 transienttype
                , Hsbk color
                , UInt32 period
                , Float32 cycles
                , Int16 duty_cycle
                , UInt8 waveform
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = stream.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = transienttype.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = period.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = cycles.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = duty_cycle.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = waveform.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , UInt8 stream
                , Bool8 transienttype
                , Hsbk color
                , UInt32 period
                , Float32 cycles
                , Int16 duty_cycle
                , UInt8 waveform
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , stream
                    , transienttype
                    , color
                    , period
                    , cycles
                    , duty_cycle
                    , waveform
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = stream.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = transienttype.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = period.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = cycles.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = duty_cycle.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = waveform.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class SetDimAbsolute extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::SetDimAbsolute
    {
        // Fields: brightness, duration;
        private Int16 brightness;                // Field: brightness - Structle::Int16 byte offset: 0
        private UInt32 duration;            // Field: duration - Structle::Uint32 byte offset: 2

        private static final int PAYLOAD_SIZE = 6;

        public SetDimAbsolute(byte[] bytes) {
            this(bytes, 0);
        }

        public SetDimAbsolute(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[2];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];

            brightness = new Int16(member0Data);

            byte[] member1Data = new byte[4];
            member1Data[0] = bytes[initialOffset + 2];
            member1Data[1] = bytes[initialOffset + 3];
            member1Data[2] = bytes[initialOffset + 4];
            member1Data[3] = bytes[initialOffset + 5];

            duration = new UInt32(member1Data);

        }

        public SetDimAbsolute(Object padding
                , Int16 brightness
                , UInt32 duration
        ) {
            this.brightness = brightness;
            this.duration = duration;
        }

        public Int16 getBrightness() {
            return brightness;
        }

        public UInt32 getDuration() {
            return duration;
        }

        public void printMessageData() {
            brightness.printValue("brightness");                // Field: brightness - Structle::Int16 byte offset: 6
            duration.printValue("duration");            // Field: duration - Structle::Uint32 byte offset: 6
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Int16 brightness
                , UInt32 duration
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Int16 brightness
                , UInt32 duration
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , brightness
                    , duration
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class SetDimRelative extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::SetDimRelative
    {
        // Fields: brightness, duration;
        private Int32 brightness;                // Field: brightness - Structle::Int32 byte offset: 0
        private UInt32 duration;            // Field: duration - Structle::Uint32 byte offset: 4

        private static final int PAYLOAD_SIZE = 8;

        public SetDimRelative(byte[] bytes) {
            this(bytes, 0);
        }

        public SetDimRelative(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[4];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];

            brightness = new Int32(member0Data);

            byte[] member1Data = new byte[4];
            member1Data[0] = bytes[initialOffset + 4];
            member1Data[1] = bytes[initialOffset + 5];
            member1Data[2] = bytes[initialOffset + 6];
            member1Data[3] = bytes[initialOffset + 7];

            duration = new UInt32(member1Data);

        }

        public SetDimRelative(Object padding
                , Int32 brightness
                , UInt32 duration
        ) {
            this.brightness = brightness;
            this.duration = duration;
        }

        public Int32 getBrightness() {
            return brightness;
        }

        public UInt32 getDuration() {
            return duration;
        }

        public void printMessageData() {
            brightness.printValue("brightness");                // Field: brightness - Structle::Int32 byte offset: 8
            duration.printValue("duration");            // Field: duration - Structle::Uint32 byte offset: 8
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Int32 brightness
                , UInt32 duration
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Int32 brightness
                , UInt32 duration
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , brightness
                    , duration
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = brightness.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = duration.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class Rgbw extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::Rgbw
    {
        // Fields: red, green, blue, white;
        private UInt16 red;            // Field: red - Structle::Uint16 byte offset: 0
        private UInt16 green;            // Field: green - Structle::Uint16 byte offset: 2
        private UInt16 blue;            // Field: blue - Structle::Uint16 byte offset: 4
        private UInt16 white;            // Field: white - Structle::Uint16 byte offset: 6

        private static final int PAYLOAD_SIZE = 8;

        public Rgbw(byte[] bytes) {
            this(bytes, 0);
        }

        public Rgbw(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[2];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];

            red = new UInt16(member0Data);

            byte[] member1Data = new byte[2];
            member1Data[0] = bytes[initialOffset + 2];
            member1Data[1] = bytes[initialOffset + 3];

            green = new UInt16(member1Data);

            byte[] member2Data = new byte[2];
            member2Data[0] = bytes[initialOffset + 4];
            member2Data[1] = bytes[initialOffset + 5];

            blue = new UInt16(member2Data);

            byte[] member3Data = new byte[2];
            member3Data[0] = bytes[initialOffset + 6];
            member3Data[1] = bytes[initialOffset + 7];

            white = new UInt16(member3Data);

        }

        public Rgbw(Object padding
                , UInt16 red
                , UInt16 green
                , UInt16 blue
                , UInt16 white
        ) {
            this.red = red;
            this.green = green;
            this.blue = blue;
            this.white = white;
        }

        public UInt16 getRed() {
            return red;
        }

        public UInt16 getGreen() {
            return green;
        }

        public UInt16 getBlue() {
            return blue;
        }

        public UInt16 getWhite() {
            return white;
        }

        public void printMessageData() {
            red.printValue("red");            // Field: red - Structle::Uint16 byte offset: 8
            green.printValue("green");            // Field: green - Structle::Uint16 byte offset: 8
            blue.printValue("blue");            // Field: blue - Structle::Uint16 byte offset: 8
            white.printValue("white");            // Field: white - Structle::Uint16 byte offset: 8
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , UInt16 red
                , UInt16 green
                , UInt16 blue
                , UInt16 white
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = red.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = green.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = blue.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = white.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , UInt16 red
                , UInt16 green
                , UInt16 blue
                , UInt16 white
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , red
                    , green
                    , blue
                    , white
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = red.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = green.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = blue.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = white.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class SetRgbw extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::SetRgbw
    {
        // Fields: color;
        private Rgbw color;        // Field: color - Lx::Protocol::Light::Rgbw byte offset: 0

        private static final int PAYLOAD_SIZE = 8;

        public SetRgbw(byte[] bytes) {
            this(bytes, 0);
        }

        public SetRgbw(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[8];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];
            member0Data[4] = bytes[initialOffset + 4];
            member0Data[5] = bytes[initialOffset + 5];
            member0Data[6] = bytes[initialOffset + 6];
            member0Data[7] = bytes[initialOffset + 7];

            color = new Rgbw(member0Data);        // Field: color - Lx::Protocol::Light::Rgbw byte offset: 0

        }

        public SetRgbw(Object padding
                , Rgbw color
        ) {
            this.color = color;
        }

        public Rgbw getColor() {
            return color;
        }

        ;

        public void printMessageData() {
            color.printMessageData();        // Field: color - Lx::Protocol::Light::Rgbw byte offset: 8
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Rgbw color
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Rgbw color
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , color
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class State extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::State
    {
        private static final String TAG = State.class.getSimpleName();

        // Fields: color, dim, power, label, tags;
        private Hsbk color;        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 0
        private Int16 dim;                // Field: dim - Structle::Int16 byte offset: 8
        private UInt16 power;            // Field: power - Structle::Uint16 byte offset: 10
        private String label;            // Field: label - Structle::String byte offset: 12
        private UInt64 tags;            // Field: tags - Structle::Uint64 byte offset: 44

        private static final int PAYLOAD_SIZE = 52;

        public State(byte[] bytes) {
            this(bytes, 0);
        }

        public State(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[8];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];
            member0Data[4] = bytes[initialOffset + 4];
            member0Data[5] = bytes[initialOffset + 5];
            member0Data[6] = bytes[initialOffset + 6];
            member0Data[7] = bytes[initialOffset + 7];

            color = new Hsbk(member0Data);        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 0

            byte[] member1Data = new byte[2];
            member1Data[0] = bytes[initialOffset + 8];
            member1Data[1] = bytes[initialOffset + 9];

            dim = new Int16(member1Data);

            byte[] member2Data = new byte[2];
            member2Data[0] = bytes[initialOffset + 10];
            member2Data[1] = bytes[initialOffset + 11];

            power = new UInt16(member2Data);

            byte[] member3Data = new byte[32];
            member3Data[0] = bytes[initialOffset + 12];
            member3Data[1] = bytes[initialOffset + 13];
            member3Data[2] = bytes[initialOffset + 14];
            member3Data[3] = bytes[initialOffset + 15];
            member3Data[4] = bytes[initialOffset + 16];
            member3Data[5] = bytes[initialOffset + 17];
            member3Data[6] = bytes[initialOffset + 18];
            member3Data[7] = bytes[initialOffset + 19];
            member3Data[8] = bytes[initialOffset + 20];
            member3Data[9] = bytes[initialOffset + 21];
            member3Data[10] = bytes[initialOffset + 22];
            member3Data[11] = bytes[initialOffset + 23];
            member3Data[12] = bytes[initialOffset + 24];
            member3Data[13] = bytes[initialOffset + 25];
            member3Data[14] = bytes[initialOffset + 26];
            member3Data[15] = bytes[initialOffset + 27];
            member3Data[16] = bytes[initialOffset + 28];
            member3Data[17] = bytes[initialOffset + 29];
            member3Data[18] = bytes[initialOffset + 30];
            member3Data[19] = bytes[initialOffset + 31];
            member3Data[20] = bytes[initialOffset + 32];
            member3Data[21] = bytes[initialOffset + 33];
            member3Data[22] = bytes[initialOffset + 34];
            member3Data[23] = bytes[initialOffset + 35];
            member3Data[24] = bytes[initialOffset + 36];
            member3Data[25] = bytes[initialOffset + 37];
            member3Data[26] = bytes[initialOffset + 38];
            member3Data[27] = bytes[initialOffset + 39];
            member3Data[28] = bytes[initialOffset + 40];
            member3Data[29] = bytes[initialOffset + 41];
            member3Data[30] = bytes[initialOffset + 42];
            member3Data[31] = bytes[initialOffset + 43];

            int endOfStringIndex;
            byte[] subString;

            endOfStringIndex = member3Data.length;

            for (int i = 0; i < member3Data.length; i++) {
                if (member3Data[i] == 0x00) {
                    endOfStringIndex = i;
                    break;
                }
            }

            subString = new byte[endOfStringIndex];
            for (int i = 0; i < endOfStringIndex; i++) {
                subString[i] = member3Data[i];
            }

            label = new String(subString);

            byte[] member4Data = new byte[8];
            member4Data[0] = bytes[initialOffset + 44];
            member4Data[1] = bytes[initialOffset + 45];
            member4Data[2] = bytes[initialOffset + 46];
            member4Data[3] = bytes[initialOffset + 47];
            member4Data[4] = bytes[initialOffset + 48];
            member4Data[5] = bytes[initialOffset + 49];
            member4Data[6] = bytes[initialOffset + 50];
            member4Data[7] = bytes[initialOffset + 51];

            tags = new UInt64(member4Data);

        }

        public State(Object padding
                , Hsbk color
                , Int16 dim
                , UInt16 power
                , String label
                , UInt64 tags
        ) {
            this.color = color;
            this.dim = dim;
            this.power = power;
            this.label = label;
            this.tags = tags;
        }

        public Hsbk getColor() {
            return color;
        }

        ;

        public Int16 getDim() {
            return dim;
        }

        public UInt16 getPower() {
            return power;
        }

        public String getLabel() {
            return label;
        }

        public UInt64 getTags() {
            return tags;
        }

        public void printMessageData() {
            color.printMessageData();        // Field: color - Lx::Protocol::Light::Hsbk byte offset: 52
            dim.printValue("dim");                // Field: dim - Structle::Int16 byte offset: 52
            power.printValue("power");            // Field: power - Structle::Uint16 byte offset: 52
            LFXLog.d(TAG, label);            // Field: label - Structle::String byte offset: 52
            tags.printValue("tags");            // Field: tags - Structle::Uint64 byte offset: 52
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Hsbk color
                , Int16 dim
                , UInt16 power
                , String label
                , UInt64 tags
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = dim.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = power.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            char[] labelchars = label.toCharArray();
            //byte[] labelBytes = new byte[labelchars.length];
            byte[] labelBytes = new byte[32];

            for (int i = 0; i < 32; i++) {
                labelBytes[i] = 0x00;
            }

            for (int i = 0; i < labelchars.length; i++) {
                labelBytes[i] = (byte) labelchars[i];
            }

            memberData = labelBytes;

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = tags.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Hsbk color
                , Int16 dim
                , UInt16 power
                , String label
                , UInt64 tags
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , color
                    , dim
                    , power
                    , label
                    , tags
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = color.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = dim.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = power.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            char[] labelchars = label.toCharArray();
            //byte[] labelBytes = new byte[labelchars.length];
            byte[] labelBytes = new byte[32];

            for (int i = 0; i < 32; i++) {
                labelBytes[i] = 0x00;
            }

            for (int i = 0; i < labelchars.length; i++) {
                labelBytes[i] = (byte) labelchars[i];
            }

            memberData = labelBytes;

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = tags.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class GetRailVoltage extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::GetRailVoltage
    {

        private static final int PAYLOAD_SIZE = 0;

        public GetRailVoltage(byte[] bytes) {
            this(bytes, 0);
        }

        public GetRailVoltage(byte[] bytes, int initialOffset) {
        }

        public GetRailVoltage(Object padding
        ) {
        }

        public void printMessageData() {
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
        ) {
            byte[] memberData;        // = name.getBytes();

        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class StateRailVoltage extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::StateRailVoltage
    {
        // Fields: voltage;
        private UInt32 voltage;            // Field: voltage - Structle::Uint32 byte offset: 0

        private static final int PAYLOAD_SIZE = 4;

        public StateRailVoltage(byte[] bytes) {
            this(bytes, 0);
        }

        public StateRailVoltage(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[4];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];

            voltage = new UInt32(member0Data);

        }

        public StateRailVoltage(Object padding
                , UInt32 voltage
        ) {
            this.voltage = voltage;
        }

        public UInt32 getVoltage() {
            return voltage;
        }

        public void printMessageData() {
            voltage.printValue("voltage");            // Field: voltage - Structle::Uint32 byte offset: 4
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , UInt32 voltage
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = voltage.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , UInt32 voltage
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , voltage
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = voltage.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class GetTemperature extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::GetTemperature
    {

        private static final int PAYLOAD_SIZE = 0;

        public GetTemperature(byte[] bytes) {
            this(bytes, 0);
        }

        public GetTemperature(byte[] bytes, int initialOffset) {
        }

        public GetTemperature(Object padding
        ) {
        }

        public void printMessageData() {
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
        ) {
            byte[] memberData;        // = name.getBytes();

        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class StateTemperature extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::StateTemperature
    {
        // Fields: temperature;
        private Int16 temperature;                // Field: temperature - Structle::Int16 byte offset: 0

        private static final int PAYLOAD_SIZE = 2;

        public StateTemperature(byte[] bytes) {
            this(bytes, 0);
        }

        public StateTemperature(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[2];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];

            temperature = new Int16(member0Data);

        }

        public StateTemperature(Object padding
                , Int16 temperature
        ) {
            this.temperature = temperature;
        }

        public Int16 getTemperature() {
            return temperature;
        }

        public void printMessageData() {
            temperature.printValue("temperature");                // Field: temperature - Structle::Int16 byte offset: 2
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Int16 temperature
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = temperature.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Int16 temperature
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , temperature
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = temperature.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class Xyz extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::Xyz
    {
        // Fields: x, y, z;
        private Float32 x;                // Field: x - Structle::Float byte offset: 0
        private Float32 y;                // Field: y - Structle::Float byte offset: 4
        private Float32 z;                // Field: z - Structle::Float byte offset: 8

        private static final int PAYLOAD_SIZE = 12;

        public Xyz(byte[] bytes) {
            this(bytes, 0);
        }

        public Xyz(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[4];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];

            x = new Float32(member0Data);

            byte[] member1Data = new byte[4];
            member1Data[0] = bytes[initialOffset + 4];
            member1Data[1] = bytes[initialOffset + 5];
            member1Data[2] = bytes[initialOffset + 6];
            member1Data[3] = bytes[initialOffset + 7];

            y = new Float32(member1Data);

            byte[] member2Data = new byte[4];
            member2Data[0] = bytes[initialOffset + 8];
            member2Data[1] = bytes[initialOffset + 9];
            member2Data[2] = bytes[initialOffset + 10];
            member2Data[3] = bytes[initialOffset + 11];

            z = new Float32(member2Data);

        }

        public Xyz(Object padding
                , Float32 x
                , Float32 y
                , Float32 z
        ) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Float32 getX() {
            return x;
        }

        public Float32 getY() {
            return y;
        }

        public Float32 getZ() {
            return z;
        }

        public void printMessageData() {
            x.printValue("x");                // Field: x - Structle::Float byte offset: 12
            y.printValue("y");                // Field: y - Structle::Float byte offset: 12
            z.printValue("z");                // Field: z - Structle::Float byte offset: 12
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Float32 x
                , Float32 y
                , Float32 z
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = x.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = y.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = z.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Float32 x
                , Float32 y
                , Float32 z
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , x
                    , y
                    , z
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = x.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = y.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = z.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

    public static class SetCalibrationCoefficients extends LxProtocolTypeBase        // Struct: Lx::Protocol::Light::SetCalibrationCoefficients
    {
        // Fields: r, g, b, w;
        private Xyz r;        // Field: r - Lx::Protocol::Light::Xyz byte offset: 0
        private Xyz g;        // Field: g - Lx::Protocol::Light::Xyz byte offset: 12
        private Xyz b;        // Field: b - Lx::Protocol::Light::Xyz byte offset: 24
        private Xyz w;        // Field: w - Lx::Protocol::Light::Xyz byte offset: 36

        private static final int PAYLOAD_SIZE = 48;

        public SetCalibrationCoefficients(byte[] bytes) {
            this(bytes, 0);
        }

        public SetCalibrationCoefficients(byte[] bytes, int initialOffset) {
            byte[] member0Data = new byte[12];
            member0Data[0] = bytes[initialOffset + 0];
            member0Data[1] = bytes[initialOffset + 1];
            member0Data[2] = bytes[initialOffset + 2];
            member0Data[3] = bytes[initialOffset + 3];
            member0Data[4] = bytes[initialOffset + 4];
            member0Data[5] = bytes[initialOffset + 5];
            member0Data[6] = bytes[initialOffset + 6];
            member0Data[7] = bytes[initialOffset + 7];
            member0Data[8] = bytes[initialOffset + 8];
            member0Data[9] = bytes[initialOffset + 9];
            member0Data[10] = bytes[initialOffset + 10];
            member0Data[11] = bytes[initialOffset + 11];

            r = new Xyz(member0Data);        // Field: r - Lx::Protocol::Light::Xyz byte offset: 0

            byte[] member1Data = new byte[12];
            member1Data[0] = bytes[initialOffset + 12];
            member1Data[1] = bytes[initialOffset + 13];
            member1Data[2] = bytes[initialOffset + 14];
            member1Data[3] = bytes[initialOffset + 15];
            member1Data[4] = bytes[initialOffset + 16];
            member1Data[5] = bytes[initialOffset + 17];
            member1Data[6] = bytes[initialOffset + 18];
            member1Data[7] = bytes[initialOffset + 19];
            member1Data[8] = bytes[initialOffset + 20];
            member1Data[9] = bytes[initialOffset + 21];
            member1Data[10] = bytes[initialOffset + 22];
            member1Data[11] = bytes[initialOffset + 23];

            g = new Xyz(member1Data);        // Field: g - Lx::Protocol::Light::Xyz byte offset: 12

            byte[] member2Data = new byte[12];
            member2Data[0] = bytes[initialOffset + 24];
            member2Data[1] = bytes[initialOffset + 25];
            member2Data[2] = bytes[initialOffset + 26];
            member2Data[3] = bytes[initialOffset + 27];
            member2Data[4] = bytes[initialOffset + 28];
            member2Data[5] = bytes[initialOffset + 29];
            member2Data[6] = bytes[initialOffset + 30];
            member2Data[7] = bytes[initialOffset + 31];
            member2Data[8] = bytes[initialOffset + 32];
            member2Data[9] = bytes[initialOffset + 33];
            member2Data[10] = bytes[initialOffset + 34];
            member2Data[11] = bytes[initialOffset + 35];

            b = new Xyz(member2Data);        // Field: b - Lx::Protocol::Light::Xyz byte offset: 24

            byte[] member3Data = new byte[12];
            member3Data[0] = bytes[initialOffset + 36];
            member3Data[1] = bytes[initialOffset + 37];
            member3Data[2] = bytes[initialOffset + 38];
            member3Data[3] = bytes[initialOffset + 39];
            member3Data[4] = bytes[initialOffset + 40];
            member3Data[5] = bytes[initialOffset + 41];
            member3Data[6] = bytes[initialOffset + 42];
            member3Data[7] = bytes[initialOffset + 43];
            member3Data[8] = bytes[initialOffset + 44];
            member3Data[9] = bytes[initialOffset + 45];
            member3Data[10] = bytes[initialOffset + 46];
            member3Data[11] = bytes[initialOffset + 47];

            w = new Xyz(member3Data);        // Field: w - Lx::Protocol::Light::Xyz byte offset: 36

        }

        public SetCalibrationCoefficients(Object padding
                , Xyz r
                , Xyz g
                , Xyz b
                , Xyz w
        ) {
            this.r = r;
            this.g = g;
            this.b = b;
            this.w = w;
        }

        public Xyz getR() {
            return r;
        }

        ;

        public Xyz getG() {
            return g;
        }

        ;

        public Xyz getB() {
            return b;
        }

        ;

        public Xyz getW() {
            return w;
        }

        ;

        public void printMessageData() {
            r.printMessageData();        // Field: r - Lx::Protocol::Light::Xyz byte offset: 48
            g.printMessageData();        // Field: g - Lx::Protocol::Light::Xyz byte offset: 48
            b.printMessageData();        // Field: b - Lx::Protocol::Light::Xyz byte offset: 48
            w.printMessageData();        // Field: w - Lx::Protocol::Light::Xyz byte offset: 48
        }

        public static void loadMessageDataWithPayloadAtOffset(byte[] messageData, int offset
                , Xyz r
                , Xyz g
                , Xyz b
                , Xyz w
        ) {
            byte[] memberData;        // = name.getBytes();

            memberData = r.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = g.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = b.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            memberData = w.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                messageData[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
        }

        public static void loadMessageDataWithPayloadAtDefaultOffset(byte[] messageData
                , Xyz r
                , Xyz g
                , Xyz b
                , Xyz w
        ) {
            int offset = PAYLOAD_OFFSET;

            loadMessageDataWithPayloadAtOffset(messageData, offset
                    , r
                    , g
                    , b
                    , w
            );
        }

        public byte[] getBytes() {
            int offset = 0;

            byte[] bytes = new byte[getPayloadSize()];

            byte[] memberData;

            // = name.getBytes();
            memberData = r.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = g.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = b.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;
            // = name.getBytes();
            memberData = w.getBytes();

            for (int i = 0; i < (memberData.length); i++) {
                bytes[(offset + i)] = memberData[i];
            }

            offset += memberData.length;

            return bytes;
        }

        public static int getPayloadSize() {
            return PAYLOAD_SIZE;
        }
    }

}

/*
	End Of File: LxProtocolLight.java
*/


text:
struct Job
{
	JobFunction* function;
	Job* parent;
	std::atomic_int32_t unfinishedJobs;
	char padding[44]; // 64 - 8 - 8 - 4
	void* data;
};

struct WorkStealingQueue {
	Job* Steal();
	Job* Pop();
	void Push(Job*);
};

#define JOB_FUNCTION(name) void name(Job*, const void*)
typedef JOB_FUNCTION(JobFunction);

static Job** g_jobsToDelete;
static WorkStealingQueue** g_jobQueues;
static uint32_t g_workerThreadCount = std::thread::hardware_concurrency();
static std::atomic_int32_t g_jobToDeleteCount;

// Define the empty job
JOB_FUNCTION(empty_job) {}

Job* GetJob(void)
{
	WorkStealingQueue* queue = GetWorkerThreadQueue();

	Job* job = queue->Pop();
	if (job->function == &empty_job)
	{
		// this is not a valid job because our own queue is empty, so try stealing from some other queue
		unsigned int randomIndex = GenerateRandomNumber(0, g_workerThreadCount + 1);
		WorkStealingQueue* stealQueue = g_jobQueues[randomIndex];
		if (stealQueue == queue)
		{
			// don't try to steal from ourselves
			std::this_thread::yield();
			return nullptr;
		}

		Job* stolenJob = stealQueue->Steal();
		if (stolenJob->function == &empty_job)
		{
			// we couldn't steal a job from the other queue either, so we just yield our time slice for now
			std::this_thread::yield();
			return nullptr;
		}

		return stolenJob;
	}

	return job;
}

void Execute(Job* job)
{
	(job->function)(job, job->data);
	Finish(job);
}

Job* CreateJob(JobFunction* function)
{
	Job* job = new Job;
	job->function = function;
	job->parent = nullptr;
	job->unfinishedJobs = 1;

	return job;
}

Job* CreateJobAsChild(Job* parent, JobFunction* function)
{
	++parent->unfinishedJobs;

	Job* job = new Job;
	job->function = function;
	job->parent = parent;
	job->unfinishedJobs = 1;

	return job;
}

void Run(Job* job)
{
	WorkStealingQueue* queue = GetWorkerThreadQueue();
	queue->Push(job);
}

void Wait(const Job* job)
{
	// wait until the job has completed. in the meantime, work on any other job.
	while (!HasJobCompleted(job))
	{
		Job* nextJob = GetJob();
		if (nextJob)
		{
			Execute(nextJob);
		}
	}
}

void Finish(Job* job)
{
	const int32_t unfinishedJobs = --job->unfinishedJobs;
	if (unfinishedJobs == 0)
	{
		const int32_t index = ++g_jobToDeleteCount;
		g_jobsToDelete[index - 1] = job;

		if (job->parent)
		{
			Finish(job->parent);
		}

		--job->unfinishedJobs;
	}
}

void WorkerThread() {
	while (true)
	{
		Job* job = GetJob();
		if (job)
		{
			Execute(job);
		}
	}
}

void Test() {
	Job* root = CreateJob(&empty_job);
	for (unsigned int i = 0; i < g_workerThreadCount; ++i)
	{
		Job* job = CreateJobAsChild(root, &empty_job);
		Run(job);
	}
	Run(root);
	Wait(root);
}
#endif

redpajama_set_name: RedPajamaGithub


text:
@font-face {
			font-family: "FregatRegular";
			src: url("../fonts/FregatRegular/FregatRegular.eot");
			src: url("../fonts/FregatRegular/FregatRegular.eot?#iefix")format("embedded-opentype"),
			url("../fonts/FregatRegular/FregatRegular.woff") format("woff"),
			url("../fonts/FregatRegular/FregatRegular.ttf") format("truetype");
			font-style: normal;
			font-weight: normal;
	}

	@font-face {
			font-family: "FregatRegular"; /*font-family: "FregatBold";*/
			src: url("../fonts/FregatBold/FregatBold.eot");
			src: url("../fonts/FregatBold/FregatBold.eot?#iefix")format("embedded-opentype"),
			url("../fonts/FregatBold/FregatBold.woff") format("woff"),
			url("../fonts/FregatBold/FregatBold.ttf") format("truetype");
			font-style: normal;
			font-weight: 700;
	}

	@font-face {
			font-family: "FregatRegular";  /*font-family: "FregatItalic";*/
			src: url("../fonts/FregatItalic/FregatItalic.eot");
			src: url("../fonts/FregatItalic/FregatItalic.eot?#iefix")format("embedded-opentype"),
			url("../fonts/FregatItalic/FregatItalic.woff") format("woff"),
			url("../fonts/FregatItalic/FregatItalic.ttf") format("truetype");
			font-style: italic;
			font-weight: normal;
	}

	@font-face {
			font-family: "FregatRegular";/*font-family: "FregatBoldItalic";*/
			src: url("../fonts/FregatBoldItalic/FregatBoldItalic.eot");
			src: url("../fonts/FregatBoldItalic/FregatBoldItalic.eot?#iefix")format("embedded-opentype"),
			url("../fonts/FregatBoldItalic/FregatBoldItalic.woff") format("woff"),
			url("../fonts/FregatBoldItalic/FregatBoldItalic.ttf") format("truetype");
			font-style: italic;
			font-weight: 700;
	}

	@font-face {
		font-family: "untitled-font-1";
		src:url("../fonts/untitled-font-1.eot");
		src:url("../fonts/untitled-font-1.eot?#iefix") format("embedded-opentype"),
		url("../fonts/untitled-font-1.woff") format("woff"),
		url("../fonts/untitled-font-1.ttf") format("truetype"),
		url("../fonts/untitled-font-1.svg#untitled-font-1") format("svg");
		font-weight: normal;
		font-style: normal;
	}

	@font-face {
		font-family: "untitled-font-11";
		src:url("../fonts/untitled-font-11.eot");
		src:url("../fonts/untitled-font-11.eot?#iefix") format("embedded-opentype"),
		url("../fonts/untitled-font-11.woff") format("woff"),
		url("../fonts/untitled-font-11.ttf") format("truetype"),
		url("../fonts/untitled-font-11.svg#untitled-font-11") format("svg");
		font-weight: normal;
		font-style: normal;
	}

	@font-face {
		font-family: "untitled-font-14";
		src:url("../fonts/untitled-font-14.eot");
		src:url("../fonts/untitled-font-14.eot?#iefix") format("embedded-opentype"),
		url("../fonts/untitled-font-14.woff") format("woff"),
		url("../fonts/untitled-font-14.ttf") format("truetype"),
		url("../fonts/untitled-font-14.svg#untitled-font-14") format("svg");
		font-weight: normal;
		font-style: normal;

	}


text:
<?php

declare(strict_types=1);

namespace AdminPanel\Component\Metadata\Driver;

use Doctrine\Common\Persistence\Mapping\Driver\FileLocator;
use AdminPanel\Component\Metadata\ClassMetadataInterface;

abstract class AbstractFileDriver implements DriverInterface
{
    /**
     * FileLocator used to locate file containing class metadata
     *
     * @var \Doctrine\Common\Persistence\Mapping\Driver\FileLocator
     */
    private $locator;

    /**
     * Set file locator that will be used to locate class metadata file
     *
     * @param \Doctrine\Common\Persistence\Mapping\Driver\FileLocator $locator
     * @return \AdminPanel\Component\Metadata\Driver\DriverInterface
     */
    public function setFileLocator(FileLocator $locator)
    {
        $this->locator = $locator;
        return $this;
    }

    /**
     * Return previously set file locator or throws an exception
     *
     * @throws \RuntimeException
     * @return \Doctrine\Common\Persistence\Mapping\Driver\FileLocator
     */
    public function getFileLocator()
    {
        if (!isset($this->locator)) {
            throw new \RuntimeException('Required file locator has not been set on the file driver.');
        }
        return $this->locator;
    }

    /**
     * Returns path of the file containing class matadata.
     *
     * This method shout be used in loadClassMetadata to reach metadata file.
     *
     * @param \AdminPanel\Component\Metadata\ClassMetadataInterface $metadata
     * @return \Doctrine\Common\Persistence\Mapping\Driver\FileLocator
     */
    protected function findMappingFile(ClassMetadataInterface $metadata)
    {
        return $this->getFileLocator()->findMappingFile($metadata->getClassName());
    }
}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>MIPT.HUNT - user page</title>

    <link href="{% static 'hunt/css/bootstrap.min.css' %}" rel="stylesheet">

    <link href="{% static 'hunt/css/freelancer.css' %}" rel="stylesheet">

    <link href="{% static 'hunt/font-awesome/css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                Toggle navigation

            </button>
            Главная

                    Портфолио

                    Обо мне

                    Контакты

Мой профиль

Регистрация

Логин

Выйти

Название проекта

                        Описание проекта

Вакансии

                Описание
                Подробнее
                Необходимые скиллы

                1
                1
                1

                3
                3
                3

            <input type="text" name="new_job_name" id="new_job_name" class="form-control input-sm" placeholder="Название вакансии">

            <input type="submit" value="Добавить" class="btn btn-info  col-lg-8 col-lg-offset-2" id="new_job_add">

            <textarea rows="5" class="form-control" placeholder="Описание проекта" id="new_job_description" required data-validation-required-message="Описание вакансии"></textarea>

                            <input type="checkbox"> Senior Developer

                            <input type="checkbox"> Good Knowlage in Math

                            <input type="checkbox"> Senior Developer

                            <input type="checkbox"> Good Knowlage in Math

Юридическое лицо

МФТИ
Красная боталка

В социальных сетях

О сайте

Самый клёвый сайт

                    Copyright © MIPT.HUNTER 2015

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>

Project Title

Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!

Client:
                                Start Bootstrap

Date:
                                April 2014

Service:
                                Web Development

                        <button type="button" class="btn btn-default" data-dismiss="modal"> Close</button>


text:
This repository is no longer in use. The Google Earth Engine scripts for the
Trends.Earth project are now located within the [Trends.Earth
repository](http://github.com/ConservationInternational/trends.earth).


text:
<#
    creates new azurermadapplication for use with logging in to azurerm using password or cert
    to enable script execution, you may need to Set-ExecutionPolicy Bypass -Force

    # can be used with scripts for example
    # connect-azurermaccount -ServicePrincipal -CertificateThumbprint $cert.Thumbprint -ApplicationId $app.ApplicationId -TenantId $tenantId
    # requires free AAD base subscription
    # https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authenticate-service-principal#provide-credentials-through-automated-powershell-script

    example command:
    iwr https://tinyurl.com/create-azure-client-id -UseBasicParsing| iex

    example command to save and/or pass arguments:
    invoke-webRequest "https://raw.githubusercontent.com/jagilber/powershellScripts/master/azure-rm-create-aad-application-spn.ps1" -outFile "$(get-location)\azure-rm-create-aad-application-spn.ps1";
    then:
    .\azure-rm-create-aad-application-spn.ps1 -aadDisplayName azure-rm-rest-logon -logontype certthumb
    or
    .\azure-rm-create-aad-application-spn.ps1

    # 190209
#>
param(
    [pscredential]$credentials,
    [string]$aadDisplayName = "azure-rm-rest-logon/$($env:Computername)",
    [string]$certStore = "cert:\CurrentUser\My",
    [string]$uri,
    [switch]$list,
    [string]$pfxPath = "$($env:temp)\$($aadDisplayName).pfx",
    [string]$logonType = 'certthumb'
)

# ----------------------------------------------------------------------------------------------------------------
function main()
{
    $retryCount = 10
    $cert = $null
    $keyCredential = $null
    $thumbprint = $null
    $ClientSecret = $null
    $keyvalue = $Null
    $error.Clear()
    $app = $null

    write-host "checking for admin"

    if(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    {
        write-warning "script requires powershell admin sesion. restart as admin. exiting"
        return
    }

    # authenticate
    try
    {
        get-command connect-azurermaccount | Out-Null
    }
    catch [management.automation.commandNotFoundException]
    {
        if ((read-host "azurerm not installed but is required for this script. is it ok to install?[y|n]") -imatch "y")
        {
            write-host "installing minimum required azurerm modules..."
            install-module azurerm.profile
            install-module azurerm.resources
            import-module azurerm.profile
            import-module azurerm.resources
        }
        else
        {
            return 1
        }
    }

    if (!(Get-AzureRmResourceGroup))
    {
        connect-azurermaccount

        if (!(Get-AzureRmResourceGroup))
        {
            Write-Warning "unable to authenticate to azurerm. returning..."
            return 1
        }
    }

    if (!$uri)
    {
        $uri = "https://$($aadDisplayName)"
    }

    $tenantId = (Get-AzureRmContext).Tenant.Id

    if ((Get-AzureRmADApplication -DisplayNameStartWith $aadDisplayName -ErrorAction SilentlyContinue))
    {
        $app = Get-AzureRmADApplication -DisplayNameStartWith $aadDisplayName

        if ((read-host "AAD application exists: $($aadDisplayName). Do you want to delete?[y|n]") -imatch "y")
        {
            remove-AzureRmADApplication -objectId $app.objectId -Force
            $app = $null
            $id = Get-AzureRmADServicePrincipal -SearchString $aadDisplayName

            if (@($id).Count -eq 1)
            {
                Remove-AzureRmADServicePrincipal -ObjectId $id
            }
        }
    }

    $certs = @(Get-ChildItem $certStore | Where-Object {$_.Subject -imatch "$($aadDisplayName)" -and $_.NotAfter -gt (get-date)})

    if($certs.Count -ge 1)
    {
        $count = 1

        foreach($certItem in $certs)
        {
            "$($count). $($certItem.Subject) $($certItem.NotAfter) $($certItem.Thumbprint)"
            $count++
        }

        if(($result = read-host "enter line number of existing cert to use or 0 to create new. normally an existing cert from list should be used.") -gt 0)
        {
            $cert = $certs[$result]
        }

    }

    if (!$list)
    {
        if ($logontype -ieq 'cert')
        {
            Write-Warning "this does not work for rest authentication, but does work for ps auth"

            if(!$cert)
            {
                $cert = New-SelfSignedCertificate -CertStoreLocation $certStore `
                    -Subject "CN=$($aadDisplayName)" `
                    -KeyExportPolicy Exportable `
                    -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
            }

            if (!$credentials)
            {
                $credentials = (get-credential)
            }

            $securePassword = ConvertTo-SecureString -String $credentials.Password -Force -AsPlainText

            if([io.file]::Exists($pfxPath))
            {
                [io.file]::Delete($pfxPath)
            }

            Export-PfxCertificate -cert "cert:\currentuser\my\$($cert.thumbprint)" -FilePath $pfxPath -Password $securePassword
            $cert509 = New-Object System.Security.Cryptography.X509Certificates.X509Certificate($pfxPath, $securePassword)
            $thumbprint = $cert509.thumbprint
            $keyValue = [System.Convert]::ToBase64String($cert509.GetCertHash())
            write-host "New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -CertValue $keyValue -EndDate $cert.NotAfter -StartDate $cert.NotBefore"

            if($oldAdApp = Get-AzureRmADApplication -DisplayNameStartWith $aadDisplayName)
            {
                remove-AzureRmADApplication -ObjectId $oldAdApp.objectId
            }

            $DebugPreference = "Continue"

            if(!$app)
            {
                write-host "New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -CertValue $keyValue -EndDate $($cert.NotAfter) -StartDate $($cert.NotBefore) -verbose"
                $app = New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -CertValue ($cert.GetRawCertData()) -EndDate ($cert.NotAfter) -StartDate ($cert.NotBefore) -verbose #-Debug
            }

            $app
            #$DebugPreference = "SilentlyContinue"
            $app = New-AzureRmADAppCredential -applicationId ($app.ApplicationId) -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -KeyCredentials $KeyCredential -Verbose

        }
        elseif ($logontype -ieq 'certthumb')
        {
            if(!$cert)
            {
                $cert = New-SelfSignedCertificate -CertStoreLocation $certStore `
                    -Subject "$($aadDisplayName)" `
                    -KeyExportPolicy Exportable `
                    -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
            }

            $keyValue = [System.Convert]::ToBase64String($cert.GetCertHash())
            $thumbprint = $cert.Thumbprint
            $ClientSecret = [System.Convert]::ToBase64String($cert.GetCertHash())
            $securePassword = ConvertTo-SecureString -String $ClientSecret -Force -AsPlainText
            write-host "New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -Password $securePassword -EndDate $($cert.NotAfter)"

            if(!$app)
            {
                $app = New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -Password $securePassword -EndDate ($cert.NotAfter)
            }
        }
        elseif ($logontype -ieq 'key')
        {
            $bytes = New-Object Byte[] 32
            $rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
            $rand.GetBytes($bytes)

            $ClientSecret = [System.Convert]::ToBase64String($bytes)
            $securePassword = ConvertTo-SecureString -String $ClientSecret -Force -AsPlainText
            $endDate = [System.DateTime]::Now.AddYears(2)

            if(!$app)
            {
                $app = New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $URI -IdentifierUris $URI -Password $securePassword -EndDate $endDate
            }

            write-host "client secret: $($ClientSecret)" -ForegroundColor Yellow

        }
        else
        {
            write-warning "credentials need to be psadcredentials to work"
            if (!$credentials)
            {
                write-warning "no credentials, exiting"
                exit 1
            }
            # to use password
            if(!$app)
            {
                $app = New-AzureRmADApplication -DisplayName $aadDisplayName -HomePage $uri -IdentifierUris $uri -PasswordCredentials $credentials
            }
        }

        $app
        $count = 0

        while ($count -lt $retryCount)
        {
            #todo check if principal exists
            $error.clear()
            start-sleep -Seconds 10
            write-host "attempt $count New-AzureRmADServicePrincipal -ApplicationId $($app.ApplicationId)" # -DisplayName $aadDisplayName"
            New-AzureRmADServicePrincipal -ApplicationId ($app.ApplicationId) #-DisplayName $aadDisplayName
            if(!$error)
            {
                break
            }
            $count++
        }

        if($error)
        {
            write-error "unable to add new principal, exiting"
            return 1
        }

        $count = 0

        while ($count -lt $retryCount)
        {
            try
            {
                write-host "$($count) -- sleeping 10 seconds while new service principal is created."
                start-sleep -Seconds 10
                write-host "attempt $($count) to add role assignments read and contribute"
                New-AzureRmRoleAssignment -RoleDefinitionName Reader -ServicePrincipalName ($app.ApplicationId)

                if (!$error)
                {
                    write-host "role assignments read added" -ForegroundColor green
                    write-host "to remove 'read' permissions, run: Remove-AzureRmRoleAssignment -RoleDefinitionName Reader -ServicePrincipalName $($app.ApplicationId)"
                }

                if (!$error)
                {
                    New-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName ($app.ApplicationId)
                    write-host "role assignments contribute added" -ForegroundColor green
                    write-host "to remove 'contributor' permissions, run: Remove-AzureRmRoleAssignment -RoleDefinitionName Contributor -ServicePrincipalName $($app.ApplicationId)"
                    break
                }
            }
            catch
            {
                if($error -imatch "401")
                {
                    write-error ($error | out-string)
                    write-warning "unable to add role assignments read and or contribute due to permissions."
                    break
                }
            }

            write-verbose ($error | out-string)
            $error.Clear()
            $count++
        }

        if ($logontype -ieq 'cert' -or $logontype -ieq 'certthumb')
        {
            write-host "for use in script: connect-azurermaccount -ServicePrincipal -CertificateThumbprint $($cert.Thumbprint) -ApplicationId $($app.ApplicationId) -TenantId $($tenantId)"
            write-host "certificate thumbprint: $($cert.Thumbprint)"

        }
    }

    $app
    write-host "application id: $($app.ApplicationId)" -ForegroundColor Cyan
    write-host "tenant id: $($tenantId)" -ForegroundColor Cyan
    write-host "application identifier Uri: $($uri)" -ForegroundColor Cyan
    write-host "keyValue: $($keyValue)" -ForegroundColor Cyan
    write-host "clientsecret: $($clientsecret)" -ForegroundColor Cyan
    write-host "clientsecret BASE64:$([convert]::ToBase64String([text.encoding]::Unicode.GetBytes($clientsecret)))"
    write-host "thumbprint: $($thumbprint)" -ForegroundColor Cyan
    write-host "pfx path: $($pfxPath)" -ForegroundColor Cyan
    $global:thumbprint = $thumbprint
    $global:applicationId = $app.Applicationid
    $global:tenantId = $tenantId
    $global:clientSecret = $ClientSecret
    $global:keyValue = $keyValue
    write-host "clientid / applicationid saved in `$global:applicationId" -ForegroundColor Yellow
    write-host "clientsecret / base64 thumb saved in `$global:clientSecret" -ForegroundColor Yellow

}
# ----------------------------------------------------------------------------------------------------------------

main


text:
Namespace Extensions

    Public Module DevComponents_DotNetBar_SuperGrid_SuperGridControl

        <System.Runtime.CompilerServices.Extension()> Public Function GetSelectedDataItem(Of T)(s As DevComponents.DotNetBar.SuperGrid.SuperGridControl) As T
            If s Is Nothing Then
                Return Nothing
            End If
            If s.PrimaryGrid Is Nothing Then
                Return Nothing
            End If
            If s.PrimaryGrid.SelectedRowCount <= 0 Then
                Return Nothing
            End If

            For Each Row As DevComponents.DotNetBar.SuperGrid.GridRow In s.PrimaryGrid.SelectedRows
                Return DirectCast(Row.DataItem, T)
            Next

            Return Nothing
        End Function

        <System.Runtime.CompilerServices.Extension()> Public Function GetSelectedDataItems(Of T)(s As DevComponents.DotNetBar.SuperGrid.SuperGridControl) As List(Of T)
            If s Is Nothing Then
                Return New List(Of T)
            End If
            If s.PrimaryGrid Is Nothing Then
                Return New List(Of T)
            End If
            If s.PrimaryGrid.SelectedRowCount <= 0 Then
                Return New List(Of T)
            End If

            Dim Results As New List(Of T)

            For Each Row As DevComponents.DotNetBar.SuperGrid.GridRow In s.PrimaryGrid.SelectedRows
                Results.Add(DirectCast(Row.DataItem, T))
            Next

            Return Results
        End Function

        <System.Runtime.CompilerServices.Extension()> Public Sub ClearFilter(s As DevComponents.DotNetBar.SuperGrid.SuperGridControl)
            If s Is Nothing Then
                Return
            End If
            If s.PrimaryGrid Is Nothing Then
                Return
            End If

            s.PrimaryGrid.FilterExpr = Nothing
            For Each Column As DevComponents.DotNetBar.SuperGrid.GridColumn In s.PrimaryGrid.Columns
                Column.FilterExpr = Nothing
            Next
        End Sub

        <System.Runtime.CompilerServices.Extension()> Public Sub SetFilter(s As DevComponents.DotNetBar.SuperGrid.SuperGridControl, filter As String)
            If s Is Nothing Then
                Return
            End If
            If s.PrimaryGrid Is Nothing Then
                Return
            End If

            s.PrimaryGrid.FilterExpr = filter
        End Sub

        <System.Runtime.CompilerServices.Extension()> Public Sub SetFilter(s As DevComponents.DotNetBar.SuperGrid.SuperGridControl, dataPropertyName As String, filter As String)
            If s Is Nothing Then
                Return
            End If
            If s.PrimaryGrid Is Nothing Then
                Return
            End If

            For Each Column As DevComponents.DotNetBar.SuperGrid.GridColumn In s.PrimaryGrid.Columns
                If Column.DataPropertyName.IsEqualTo(dataPropertyName) Then
                    Column.FilterExpr = filter
                End If
            Next
        End Sub

    End Module

End Namespace