package leigh.lighting.show;

import leigh.lighting.net.SACNTransmitter;
import leigh.lighting.processor.Processor;

import java.io.IOException;

public class Universe {
    private final byte[] output = new byte[512];
    private final Processor[] procs;
    private final SACNTransmitter tx;

    public Universe(SACNTransmitter tx, Processor[] procs) {
        this.procs = procs;
        this.tx = tx;

        // TODO: Check that the output / proc sizes are reasonable.
    }

    public void process(long clock, byte[] input) throws IOException {
        for (int i = 0; i < procs.length; i++) {
            if (procs[i] == null) continue;
            output[i] = procs[i].process(clock, input);
        }
        tx.send(output);
    }

}