From 03a82275568086f64934d36b06f58e82c5b1b991 Mon Sep 17 00:00:00 2001 From: Benji Arrigo Date: Mon, 18 Oct 2021 00:10:05 -0500 Subject: [PATCH] Nightly commit 10/17/2021 Working on new objects and interfaces. Migrating the old OSC objects to new ones. --- .../main/java/com/strikete/photon/Main.java | 69 +-------- .../main/java/com/strikete/photon/Photon.java | 111 ++++++++++++++ .../com/strikete/photon/PhotonDaemon.java | 5 + .../strikete/photon/objects/DmxAddress.java | 62 -------- .../strikete/photon/objects/DmxUniverse.java | 54 ------- .../com/strikete/photon/osc/OscIncoming.java | 12 ++ .../com/strikete/photon/osc/OscInstance.java | 142 ------------------ .../strikete/photon/osc/OscInterpreter.java | 5 + .../com/strikete/photon/osc/OscListener.java | 72 +++++++++ .../java/com/strikete/photon/osc/OscMap.java | 93 ------------ .../com/strikete/photon/osc/OscOutgoing.java | 52 +++++++ .../com/strikete/photon/osc/OscSender.java | 99 ++---------- .../photon/osc/OscSenderRoutines.java | 81 ++++++++++ 13 files changed, 355 insertions(+), 502 deletions(-) create mode 100644 photon/src/main/java/com/strikete/photon/Photon.java create mode 100644 photon/src/main/java/com/strikete/photon/PhotonDaemon.java delete mode 100644 photon/src/main/java/com/strikete/photon/objects/DmxAddress.java delete mode 100644 photon/src/main/java/com/strikete/photon/objects/DmxUniverse.java create mode 100644 photon/src/main/java/com/strikete/photon/osc/OscIncoming.java delete mode 100644 photon/src/main/java/com/strikete/photon/osc/OscInstance.java create mode 100644 photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java create mode 100644 photon/src/main/java/com/strikete/photon/osc/OscListener.java delete mode 100644 photon/src/main/java/com/strikete/photon/osc/OscMap.java create mode 100644 photon/src/main/java/com/strikete/photon/osc/OscOutgoing.java create mode 100644 photon/src/main/java/com/strikete/photon/osc/OscSenderRoutines.java diff --git a/photon/src/main/java/com/strikete/photon/Main.java b/photon/src/main/java/com/strikete/photon/Main.java index c0a8bd4..19fdb2c 100644 --- a/photon/src/main/java/com/strikete/photon/Main.java +++ b/photon/src/main/java/com/strikete/photon/Main.java @@ -17,39 +17,11 @@ import com.strikete.photon.wtsahtsi.Wtsahtsi; public class Main { - - /* - * VARIABLES - */ - - public static final String version = "SNAPSHOT 0.9.0"; - public static Logger log; /* * NON-MAIN METHODS */ - private static void printWelcomeMessage() { //Only to be called after the logger object has been configured - log.info("Welcome to Photon " + version + " ."); - log.info("Photon is authored by Benji Arrigo in conjunction with Strike Theatre Electronics."); - } - - @Subscribe - public void onChannelUpdateEvent(ChannelUpdateEvent e) { - Channel temp = e.getChannel(); - if(temp.getChannelNum() == 3000) { - System.out.println("Channel: " + temp.getChannelNum()); - DmxAddress tempAddr = temp.getAddress(); - System.out.println("Universe: " + tempAddr.getUniverse().getUniverseNum()); - System.out.println("Address: " + tempAddr.getAddressNumber()); - System.out.println("Label: " + temp.getName()); - System.out.println("Manufactuer: " + temp.getManufacturer()); - System.out.println("Fixture Type: " + temp.getType()); - System.out.println("UID: " + temp.getUID()); - System.out.println("Level: " + temp.getLevel()); - } - } - /* @@ -73,44 +45,5 @@ public static void main(String[] args) throws IOException { osc.getEventHandler().register(main); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - //osc.getOscSender().sendOscMessage(osc.getOscMap().KEY_BLIND); - //osc.getOscSender().selectChannel(1); - - osc.getObjectUpdater().doBasicUpdate(); - - //while(true) { - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - //System.out.println(osc.getOscParser().getChannelSize()); - //Wtsahtsi whut = new Wtsahtsi("/Users/rusettsten/Desktop/KC-ON YOUR FEET.csv",1,osc,1499); - printCueLabels(osc); - - - } - //} - - public static void printCueLabels(OscInstance osc) { - int cueSize = osc.getOscParser().getCuelistFromIndex(0).getCueSize(); - for(int x = 0; x < cueSize; x++) { - if(!osc.getOscParser().getCuelistFromIndex(0).getCue(x).getName().isEmpty() && !osc.getOscParser().getCuelistFromIndex(0).getCue(x).getName().contains("copy")) { - float cueNumber = osc.getOscParser().getCuelistFromIndex(0).getCue(x).getCueNumber(); - String cueName = osc.getOscParser().getCuelistFromIndex(0).getCue(x).getName(); - System.out.println("Q" + cueNumber + ": " + cueName); - } - } } - -} +} \ No newline at end of file diff --git a/photon/src/main/java/com/strikete/photon/Photon.java b/photon/src/main/java/com/strikete/photon/Photon.java new file mode 100644 index 0000000..bb87526 --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/Photon.java @@ -0,0 +1,111 @@ +package com.strikete.photon; + +import java.util.ArrayList; + +import org.apache.log4j.Logger; + +import com.strikete.photon.objects.BeamPalette; +import com.strikete.photon.objects.Channel; +import com.strikete.photon.objects.ColorPalette; +import com.strikete.photon.objects.Cue; +import com.strikete.photon.objects.Cuelist; +import com.strikete.photon.objects.Curve; +import com.strikete.photon.objects.Effect; +import com.strikete.photon.objects.Fixture; +import com.strikete.photon.objects.FocusPalette; +import com.strikete.photon.objects.Group; +import com.strikete.photon.objects.IntensityPalette; +import com.strikete.photon.objects.Macro; +import com.strikete.photon.objects.MagicSheet; +import com.strikete.photon.objects.Pixelmap; +import com.strikete.photon.objects.Preset; +import com.strikete.photon.objects.Snapshot; +import com.strikete.photon.objects.Sub; + +public class Photon { + + /* + * VARIABLES - PROGRAM SPECIFIC + */ + public static Logger log; + public static final String version = "SNAPSHOT 0.9.0"; + + /* + * VARIABLES - OBJECTS + */ + private ArrayList beamPalettes; + private ArrayList channels; + private ArrayList colorPalettes; + private ArrayList cues; + private ArrayList cuelists; + private ArrayList curves; + private ArrayList effects; + private ArrayList fixtures; + private ArrayList focusPalettes; + private ArrayList groups; + private ArrayListintensityPalettes; + private ArrayList macros; + private ArrayList magicSheets; + private ArrayList pixelmaps; + private ArrayList presets; + private ArrayList snapshots; + private ArrayList subs; + + + /* + * METHODS - GETTERS + */ + + + + /* + * METHODS - SETTERS + */ + + + + /* + * METHODS - PROGRAM SPECIFIC + */ + private static void printWelcomeMessage() { //Only to be called after the logger object has been configured + log.info("Welcome to Photon " + version + " ."); + log.info("Photon is authored by Benji Arrigo in conjunction with Strike Theatre Electronics."); + } + + + /* + * METHODS - INITIALIZATION + */ + private void initializeVariables() { + beamPalettes = new ArrayList(); + channels = new ArrayList(); + colorPalettes = new ArrayList(); + cues = new ArrayList(); + cuelists = new ArrayList(); + curves = new ArrayList(); + effects = new ArrayList(); + fixtures = new ArrayList(); + focusPalettes = new ArrayList(); + groups = new ArrayList(); + intensityPalettes = new ArrayList(); + macros = new ArrayList(); + magicSheets = new ArrayList(); + pixelmaps = new ArrayList(); + presets = new ArrayList(); + snapshots = new ArrayList(); + subs = new ArrayList(); + } + + public void initializeOsc() { + + } + + + /* + * CONSTRUCTOR + */ + public Photon() { + initializeVariables(); + + } +} diff --git a/photon/src/main/java/com/strikete/photon/PhotonDaemon.java b/photon/src/main/java/com/strikete/photon/PhotonDaemon.java new file mode 100644 index 0000000..02e0977 --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/PhotonDaemon.java @@ -0,0 +1,5 @@ +package com.strikete.photon; + +public class PhotonDaemon { + +} diff --git a/photon/src/main/java/com/strikete/photon/objects/DmxAddress.java b/photon/src/main/java/com/strikete/photon/objects/DmxAddress.java deleted file mode 100644 index 8bf3bee..0000000 --- a/photon/src/main/java/com/strikete/photon/objects/DmxAddress.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.strikete.photon.objects; - -import com.strikete.photon.objects.DmxUniverse.DmxOutput; - -public class DmxAddress { - - private int addressNum = 0; //Address is an int. Addresses above 512 can be converted into universe/address - private DmxUniverse universe; //Universe is a int based on the sACN and Art-Net protocols - - /* - * METHODS - */ - - private void pushAddress(int addressIn) { //Checks if an address is valid and then pushes it or throws an error - if(addressIn <= 512) { //If the universe is provided, the address must be under 512. And not 0. - this.addressNum = addressIn; - }else { - throw new IllegalArgumentException("DmxAddress Object Error: " - + "Addresses with a provided universe must not exceed 512."); - } - } - - public DmxUniverse getUniverse() { - return this.universe; - } - public int getAddressNumber() { - return this.addressNum; - } - - //No setter methods. Address Objects should be left for garbage collection if you need to change either the universe or the address number. - - /* - * CONSTRUCTORS - */ - public DmxAddress(DmxUniverse universeIn, int addressIn) { - this.universe = universeIn; - pushAddress(addressIn); - } - - public DmxAddress(int universeNum, DmxOutput dmxOutput, int addressIn) { - this.universe = new DmxUniverse(universeNum, dmxOutput); - pushAddress(addressIn); - } - - public DmxAddress(int universeNum, int addressIn) { - this.universe = new DmxUniverse(universeNum); - pushAddress(addressIn); - } - public DmxAddress(int addressIn) { - if(addressIn > 512) { //If the address is over 512 - int universeNum; - for (universeNum = 1; addressIn >= 512;universeNum++) { //Find the universe and address - addressIn = addressIn - 512; - } - this.addressNum = addressIn; - this.universe = new DmxUniverse(universeNum); - }else { //Otherwise just record it as the default - this.universe = new DmxUniverse(1); - this.addressNum = addressIn; - } - } -} diff --git a/photon/src/main/java/com/strikete/photon/objects/DmxUniverse.java b/photon/src/main/java/com/strikete/photon/objects/DmxUniverse.java deleted file mode 100644 index 88e44e0..0000000 --- a/photon/src/main/java/com/strikete/photon/objects/DmxUniverse.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.strikete.photon.objects; - -import com.strikete.photon.Main; - -public class DmxUniverse { - - /* - * VARIABLES - */ - - public enum DmxOutput { - ARTNET_UNICAST,ARTNET_BROADCAST,SACN,RS485,OTHER,NULL - } - - private DmxOutput dmxOutput = DmxOutput.NULL; - private int universeNum = 0; //The universe number is a int based on the sACN and Art-Net protocols. - - /* - * METHODS - */ - - public DmxOutput getDmxOutput() { - return this.dmxOutput; - } - public int getUniverseNum() { - return this.universeNum; - } - - public void setDmxOutput(DmxOutput output) { - this.dmxOutput = output; - } - public void setUniverseNum(int universeNumIn) { - this.universeNum = universeNumIn; - } - - - /* - * CONSTRUCTORS - */ - - public DmxUniverse(int universeNumIn, DmxOutput outputIn) { - this.dmxOutput = outputIn; - this.universeNum = universeNumIn; - } - public DmxUniverse(int universeNumIn) { - this.dmxOutput = DmxOutput.NULL; - this.universeNum = universeNumIn; - } - public DmxUniverse() { - this.dmxOutput = DmxOutput.NULL; - this.universeNum = 1; - Main.log.warn("No args on DmxUniverse Object creation. Defaulting to 1."); - } -} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java b/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java new file mode 100644 index 0000000..9a1d95e --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java @@ -0,0 +1,12 @@ +package com.strikete.photon.osc; + +public class OscIncoming { + + /* + * VARIABLES + */ + public String RETURN_VERSION = "/eos/out/get/version"; + public String RETURN_PATCH_COUNT = "/eos/out/get/patch/count"; + public String RETURN_CUELIST_COUNT = "/eos/out/get/cuelist/count"; + public String RETURN_CUE_COUNT = "/eos/out/get/cuelist/" +} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscInstance.java b/photon/src/main/java/com/strikete/photon/osc/OscInstance.java deleted file mode 100644 index 906b791..0000000 --- a/photon/src/main/java/com/strikete/photon/osc/OscInstance.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.strikete.photon.osc; - -import java.io.InputStream; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -import com.google.common.annotations.Beta; -import com.strikete.photon.events.PhotonEventHandler; -import com.strikete.photon.utils.ObjectUpdater; -import com.strikete.photon.utils.OscParser; - -/** - * - * The OscInstance Class is a user-accessible object used to handle both outgoing and incoming OSC from a particular console. - * - * @author Rusettsten - * - */ -public class OscInstance { - - - /** - * The OscFormat Enum contains four Strings, each defining the types of consoles planned for support. - * - * ETC_EOS : Electronic Theatre Controls EOS Software - * CHAMSYS : Chamsys Consoles, specifically the MQ line - * HOG4 : The Hog 4 Console from High End Systems - */ - public enum OscFormat { - ETC_EOS, CHAMSYS, HOG4, OTHER - } - - public static boolean processingWait; - private OscParser receiver; - private OscSender sender; - private OscMap map; - private PhotonEventHandler eventBus; - private ObjectUpdater updater; - private int incomingPortNum; - private OscFormat format; - - /* - * METHODS - */ - - /** - * Returns OscSender initialized by this OscInstance. - * @return OscSender - */ - public OscSender getOscSender() { - return this.sender; - } - /** - * Returns OscParser initialized by this OscInstance. - * @return OscParser - */ - public OscParser getOscParser() { - return this.receiver; - } - /** - * Returns the OscMap used by this OscInstance and its children. - * @return OscMap - */ - public OscMap getOscMap() { - return this.map; - } - /** - * Returns the PhotonEventHandler used by this OscInstance and its children. - * @return PhotonEventHandler - */ - public PhotonEventHandler getEventHandler() { - return this.eventBus; - } - /** - * Returns the ObjectUpdater created and linked to this OscInstance. - * @return - */ - public ObjectUpdater getObjectUpdater() { - return this.updater; - } - - /** - * Returns a pre-defined OscMap based on the OscFormat enum input. - * @param OscFormat format - * @return OscMap - */ - public OscMap getPredefinedOscMap(OscFormat format) { - Yaml yaml = new Yaml(new Constructor(OscMap.class)); //Create a YAML constructor - - if(format == OscFormat.ETC_EOS) { - InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("etc_eos_revC.yaml"); - OscMap newMap = yaml.load(inputStream); - return(newMap); - }else if(format == OscFormat.CHAMSYS) { - //TODO: define input stream for Chamsys configuration - }else if(format == OscFormat.HOG4) { - //TODO: define input stream for Hog 4 configuration - } - - //If we've reached here, there's an oopsies. - throw new IllegalArgumentException("Please input a valid pre-defined OscFormat."); - } - - /** - * An OscInstance must be initialized by the user after calling the constructor. - */ - public void init() { - this.updater = new ObjectUpdater(this, this.eventBus, this.sender, this.map); - this.receiver = new OscParser(this, this.eventBus, this.updater, this.map, this.format, this.incomingPortNum); - } - - /* - * CONSTRUCTORS - */ - -//TODO: Re-add this constructor - //public OscInstance(OscMap mapIn, String targetIpStringIn, int targetPortNumIn, int incomingPortNumIn) { //The ideal constructor <3 - //this.map = mapIn; - //this.sender = new OscSender(map,targetIpStringIn, targetPortNumIn); - //TODO: Add format in, or itll throw a null pointer exception when called - //} - - /** - * OscInstance constructor using pre-defined LX Console formats. - * @param formatIn Format using a String type from Enum OscFormat contained in this class. - * @param targetIpStringIn Target IPv4 address of the console this object will to talk to. - * @param targetPortNumIn The port on the Remote Device this object will be sending packets to. - * @param incomingPortNumIn The port this object will listen for OSC packets on. - */ - public OscInstance(OscFormat formatIn, String targetIpStringIn, int targetPortNumIn, int incomingPortNumIn) { //Constructor using a predefined format - this.map = getPredefinedOscMap(formatIn); - this.sender = new OscSender(map, targetIpStringIn, targetPortNumIn); - this.format = formatIn; - this.incomingPortNum = incomingPortNumIn; - this.eventBus = new PhotonEventHandler(this); - } - - //TODO: Add constructor for custom OscMappings - -} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java b/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java new file mode 100644 index 0000000..46e33fa --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java @@ -0,0 +1,5 @@ +package com.strikete.photon.osc; + +public class OscInterpreter { + +} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscListener.java b/photon/src/main/java/com/strikete/photon/osc/OscListener.java new file mode 100644 index 0000000..ab161f6 --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/osc/OscListener.java @@ -0,0 +1,72 @@ +package com.strikete.photon.osc; +import java.util.UUID; +import java.util.function.Consumer; +import com.illposed.osc.OSCMessage; + +public class OscListener { + + /* + * VARIABLES + */ + private UUID uuid; + private String addressListener; + private Consumer consumer; + private boolean exactMatch; + private boolean expiration; + private int expirationNum; + + + /* + * METHODS - GETTERS + */ + public UUID getUuid() { + return uuid; + } + public String getUuidString() { + return uuid.toString(); + } + public String getListenerString() { + return addressListener; + } + public Consumer getConsumer() { + return consumer; + } + public boolean getExactMatch() { + return exactMatch; + } + public boolean getExpiration() { + return expiration; + } + public int getExpirationNumber() { + return expirationNum; + } + + + /* + * METHODS - POST TO CONSUMER + */ + public void postToConsumer(OSCMessage message) { + consumer.accept(message); + } + + + /* + * CONSTRUCTOR + */ + public OscListener(String listenerStringIn, Consumer consumerIn, boolean exactMatchIn) { + this.uuid = UUID.randomUUID(); + this.addressListener = listenerStringIn; + this.consumer = consumerIn; + this.exactMatch = exactMatchIn; + this.expiration = false; + this.expirationNum = 0; + } + public OscListener(String listenerStringIn, Consumer consumerIn, boolean exactMatchIn, boolean expirationIn, int expirationNumber) { + this.uuid = UUID.randomUUID(); + this.addressListener = listenerStringIn; + this.consumer = consumerIn; + this.exactMatch = exactMatchIn; + this.expiration = expirationIn; + this.expirationNum = expirationNumber; + } +} \ No newline at end of file diff --git a/photon/src/main/java/com/strikete/photon/osc/OscMap.java b/photon/src/main/java/com/strikete/photon/osc/OscMap.java deleted file mode 100644 index 9ff1ad1..0000000 --- a/photon/src/main/java/com/strikete/photon/osc/OscMap.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.strikete.photon.osc; - -public class OscMap { - - public String GET_VERSION; - - /* - * INFO UPDATE TAGS - */ - - public String GET_PATCH_COUNT; - public String GET_CUELIST_COUNT; - public String GET_GROUP_COUNT; - public String GET_MACRO_COUNT; - public String GET_SUB_COUNT; - public String GET_PRESET_COUNT; - public String GET_INTENSITY_PALETTE_COUNT; - public String GET_FOCUS_PALETTE_COUNT; - public String GET_COLOR_PALETTE_COUNT; - public String GET_BEAM_PALETTE_COUNT; - public String GET_EFFECT_COUNT; - public String GET_CUE_COUNT; - - public String GET_PATCH_INFO; - public String GET_CUELIST_INFO; - //TODO: Add Cue info handler - public String GET_GROUP_INFO; - public String GET_MACRO_INFO; - public String GET_SUB_INFO; - public String GET_PRESET_INFO; - public String GET_INTENSITY_PALETTE_INFO; - public String GET_FOCUS_PALETTE_INFO; - public String GET_COLOR_PALETTE_INFO; - public String GET_BEAM_PALETTE_INFO; - public String GET_EFFECT_INFO; - public String GET_CUE_INFO; - - public String RETURN_VERSION; - public String RETURN_PATCH_COUNT; - public String RETURN_CUELIST_COUNT; - public String RETURN_GROUP_COUNT; - public String RETURN_MACRO_COUNT; - public String RETURN_SUB_COUNT; - public String RETURN_PRESET_COUNT; - public String RETURN_INTENSITY_PALETTE_COUNT; - public String RETURN_FOCUS_PALETTE_COUNT; - public String RETURN_COLOR_PALETTE_COUNT; - public String RETURN_BEAM_PALETTE_COUNT; - public String RETURN_EFFECT_COUNT; - public String RETURN_CUE_COUNT; - - public String RETURN_PATCH_INFO; - public String RETURN_CUELIST_INFO; - //TODO: Add Cue info handler - public String RETURN_GROUP_INFO; - public String RETURN_MACRO_INFO; - public String RETURN_SUB_INFO; - public String RETURN_PRESET_INFO; - public String RETURN_INTENSITY_PALETTE_INFO; - public String RETURN_FOCUS_PALETTE_INFO; - public String RETURN_COLOR_PALETTE_INFO; - public String RETURN_BEAM_PALETTE_INFO; - public String RETURN_EFFECT_INFO; - public String RETURN_CUE_INFO; - - /* - * COMMAND TAGS - */ - public String SELECT_CHANNEL; - public String COMMAND; - - /* - * GENERIC COMMAND OPERATIONS - */ - public String GO_LIVE; - public String GO_BLIND; - - /* - * GENERIC RETURNS - */ - public String RETURN_ACTIVE; - public String RETURN_ACTIVE_CHAN; - - /* - * KEYSTROKE TAGS - */ - public String KEY_ENTER; - public String KEY_CLEAR; - public String KEY_RESET_COMMAND_LINE; - public String KEY_LIVE; - public String KEY_BLIND; - -} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscOutgoing.java b/photon/src/main/java/com/strikete/photon/osc/OscOutgoing.java new file mode 100644 index 0000000..7d81ac4 --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/osc/OscOutgoing.java @@ -0,0 +1,52 @@ +package com.strikete.photon.osc; + +public class OscOutgoing { + + /* + * VARIABLES + */ + public static String GET_VERSION = "/eos/get/version"; + public static String GET_PATCH_COUNT = "/eos/get/patch/count"; + public static String GET_CUELIST_COUNT = "/eos/get/cuelist/count"; + public static String GET_CUE_COUNT = "/eos/get/cue/[parameter1]/count"; + public static String GET_GROUP_COUNT = "/eos/get/group/count"; + public static String GET_MACRO_COUNT = "/eos/get/macro/count"; + public static String GET_SUB_COUNT = "/eos/get/sub/count"; + public static String GET_PRESET_COUNT = "/eos/get/preset/count"; + public static String GET_INTENSITY_PALETTE_COUNT = "/eos/get/ip/count"; + public static String GET_FOCUS_PALETTE_COUNT = "/eos/get/fp/count"; + public static String GET_COLOR_PALETTE_COUNT = "/eos/get/cp/count"; + public static String GET_BEAM_PALETTE_COUNT = "/eos/get/bp/count"; + public static String GET_CURVE_COUNT = "/eos/get/curve/count"; + public static String GET_EFFECT_COUNT = "/eos/get/fx/count"; + public static String GET_SNAPSHOT_COUNT = "/eos/get/snap/count"; + public static String GET_PIXELMAP_COUNT = "/eos/get/pixmap/count"; + public static String GET_MAGIC_SHEET_COUNT = "/eos/get/ms/count"; + + public static String GET_PATCH_INFO = "/eos/get/patch/index/[parameter1]"; + public static String GET_CUELIST_INFO = "/eos/get/cuelist/index/[parameter1]"; + public static String GET_CUE_INFO = "/eos/get/cue/[parameter1]/index/[parameter2]"; + public static String GET_GROUP_INFO = "/eos/get/group/index/[parameter1]"; + public static String GET_MACRO_INFO = "/eos/get/macro/index/[parameter1]"; + public static String GET_SUB_INFO = "/eos/get/sub/index/[parameter1]"; + public static String GET_PRESET_INFO = "/eos/get/preset/index/[parameter1]"; + public static String GET_INTENSITY_PALETTE_INFO = "/eos/get/ip/index/[parameter1]"; + public static String GET_FOCUS_PALETTE_INFO = "/eos/get/fp/index/[parameter1]"; + public static String GET_COLOR_PALETTE_INFO = "/eos/get/cp/index/[parameter1]"; + public static String GET_BEAM_PALETTE_INFO = "/eos/get/bp/index/[parameter1]"; + public static String GET_CURVE_INFO = "/eos/get/curve/index/[parameter1]"; + public static String GET_EFFECT_INFO = "/eos/get/fx/index/[parameter1]"; + public static String GET_SNAPSHOT_INFO = "/eos/get/snap/index/[parameter1]"; + public static String GET_PIXELMAP_INFO = "/eos/get/pixmap/index/[parameter1]"; + public static String GET_MAGIC_SHEET_INFO = "/eos/get/ms/index/[parameter1]"; + + public static String SELECT_CHANNEL = "/eos/chan/"; + public static String COMMAND = "/eos/newevent"; + + public static String KEY_ENTER = "/eos/key/enter"; + public static String KEY_CLEAR = "/eos/key/clear_cmd"; + public static String KEY_RESET_COMMAND_LINE = "/eos/key/clear_cmdline"; + public static String KEY_LIVE = "/eos/key/live"; + public static String KEY_BLIND = "/eos/key/blind"; + +} diff --git a/photon/src/main/java/com/strikete/photon/osc/OscSender.java b/photon/src/main/java/com/strikete/photon/osc/OscSender.java index c157f75..2d61418 100644 --- a/photon/src/main/java/com/strikete/photon/osc/OscSender.java +++ b/photon/src/main/java/com/strikete/photon/osc/OscSender.java @@ -9,77 +9,18 @@ import com.illposed.osc.OSCMessage; import com.illposed.osc.OSCSerializeException; import com.illposed.osc.transport.udp.OSCPortOut; -import com.strikete.photon.Main; -import com.strikete.photon.objects.Channel; +import com.strikete.photon.Photon; public class OscSender { - //Object used to send variable Osc Messages - private OscMap oscmap; + /* + * VARIABLES + */ private OSCPortOut sender; private InetAddress targetIp; private int targetPort; private int messagesSent = 0; - - /* - * METHODS - COMMON TASKS - GET COUNTS - */ - public void getVersion() { - sendOscMessage(oscmap.GET_VERSION); - } - public void getPatchCount() { - sendOscMessage(oscmap.GET_PATCH_COUNT); - } - public void getCuelistCount() { - sendOscMessage(oscmap.GET_CUELIST_COUNT); - } - public void getGroupCount() { - sendOscMessage(oscmap.GET_GROUP_COUNT); - } - public void getMacroCount() { - sendOscMessage(oscmap.GET_MACRO_COUNT); - } - public void getSubCount() { - sendOscMessage(oscmap.GET_SUB_COUNT); - } - public void getPresetCount() { - sendOscMessage(oscmap.GET_PRESET_COUNT); - } - public void getIntensityPaletteCount() { - sendOscMessage(oscmap.GET_INTENSITY_PALETTE_COUNT); - } - public void getFocusPaletteCount() { - sendOscMessage(oscmap.GET_FOCUS_PALETTE_COUNT); - } - public void getColorPaletteCount() { - sendOscMessage(oscmap.GET_COLOR_PALETTE_COUNT); - } - public void getBeamPaletteCount() { - sendOscMessage(oscmap.GET_BEAM_PALETTE_COUNT); - } - public void getEffectcount() { - sendOscMessage(oscmap.GET_EFFECT_COUNT); - } - - /* - * METHODS - COMMON TASKS - GET INFO - */ - public void getPatchInfo(int indexNumber) { - sendOscMessage(oscmap.GET_PATCH_INFO, indexNumber); - } - - /* - * METHODS - COMMON TASKS - UPDATE CHANNEL - */ - public void selectChannel(int channelNum) { - sendOscMessage(oscmap.SELECT_CHANNEL + channelNum); - sendOscMessage(oscmap.KEY_ENTER); - } - public void selectChannel(Channel channelIn) { - sendOscMessage(oscmap.SELECT_CHANNEL + channelIn.getChannelNum()); - sendOscMessage(oscmap.KEY_ENTER); - } - + /* * METHODS - GETTERS @@ -94,34 +35,29 @@ public int getTargetPort() { return this.targetPort; } + /* * METHODS - INITALIZATION */ - private void initalizeOscSender() { try { this.sender = new OSCPortOut(this.targetIp,this.targetPort); } catch (IOException e) { - Main.log.error("OscSender ERROR: IOException on OSCPortOut Object initalization.",e); + Photon.log.error("OscSender ERROR: IOException on OSCPortOut Object initalization.",e); } } + /* * METHODS - LOWER LEVEL OSC MESSAGE SENDING */ - public synchronized void sendOscMessage(OSCMessage message) { try { - if(OscInstance.processingWait) { - Thread.sleep(100); - } this.sender.send(message); } catch (IOException e) { - Main.log.error("OscSender ERROR: IOException encountered on sendOscMessage.",e); + Photon.log.error("OscSender ERROR: IOException encountered on sendOscMessage.",e); } catch (OSCSerializeException e) { - Main.log.error("OscSender ERROR: OSCSerializeException on sendOscMessage.",e); - } catch (InterruptedException e) { - Main.log.error("OscSender ERROR: InterruptedException on sendOscMessage.",e); + Photon.log.error("OscSender ERROR: OSCSerializeException on sendOscMessage.",e); } this.messagesSent++; //Count another message sent } @@ -146,27 +82,24 @@ public void sendOscMessage(String address) { //For sending just an address this.sendOscMessage(message); } + /* * CONSTRUCTORS */ - - public OscSender(OscMap oscmapIn, InetAddress targetIpIn, int targetPortIn) { - this.oscmap = oscmapIn; + public OscSender(InetAddress targetIpIn, int targetPortIn) { this.targetIp = targetIpIn; this.targetPort = targetPortIn; initalizeOscSender(); } - public OscSender(OscMap oscmapIn, String targetIpStringIn, int targetPortIn) { - this.oscmap = oscmapIn; + public OscSender(String targetIpStringIn, int targetPortIn) { this.targetPort = targetPortIn; //Catch block for Unknown Host Exception try { this.targetIp = InetAddress.getByName(targetIpStringIn); } catch (UnknownHostException e) { - Main.log.error("OscSender ERROR: UnknownHostException on object creation. Use a valid IP address.",e); + Photon.log.error("OscSender ERROR: UnknownHostException on object creation. Use a valid IP address.",e); } initalizeOscSender(); - } - -} + } +} \ No newline at end of file diff --git a/photon/src/main/java/com/strikete/photon/osc/OscSenderRoutines.java b/photon/src/main/java/com/strikete/photon/osc/OscSenderRoutines.java new file mode 100644 index 0000000..ba0b53d --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/osc/OscSenderRoutines.java @@ -0,0 +1,81 @@ +package com.strikete.photon.osc; + +import com.strikete.photon.objects.Channel; + +public class OscSenderRoutines { + + /* + * VARIABLES + */ + private OscSender oscSender; + + + /* + * METHODS - COMMON TASKS - GET COUNTS + */ + public void getVersion() { + oscSender.sendOscMessage(OscOutgoing.GET_VERSION); + } + public void getPatchCount() { + oscSender.sendOscMessage(OscOutgoing.GET_PATCH_COUNT); + } + public void getCuelistCount() { + oscSender.sendOscMessage(OscOutgoing.GET_CUELIST_COUNT); + } + public void getGroupCount() { + oscSender.sendOscMessage(OscOutgoing.GET_GROUP_COUNT); + } + public void getMacroCount() { + oscSender.sendOscMessage(OscOutgoing.GET_MACRO_COUNT); + } + public void getSubCount() { + oscSender.sendOscMessage(OscOutgoing.GET_SUB_COUNT); + } + public void getPresetCount() { + oscSender.sendOscMessage(OscOutgoing.GET_PRESET_COUNT); + } + public void getIntensityPaletteCount() { + oscSender.sendOscMessage(OscOutgoing.GET_INTENSITY_PALETTE_COUNT); + } + public void getFocusPaletteCount() { + oscSender.sendOscMessage(OscOutgoing.GET_FOCUS_PALETTE_COUNT); + } + public void getColorPaletteCount() { + oscSender.sendOscMessage(OscOutgoing.GET_COLOR_PALETTE_COUNT); + } + public void getBeamPaletteCount() { + oscSender.sendOscMessage(OscOutgoing.GET_BEAM_PALETTE_COUNT); + } + public void getEffectcount() { + oscSender.sendOscMessage(OscOutgoing.GET_EFFECT_COUNT); + } + + + /* + * METHODS - COMMON TASKS - GET INFO + */ + public void getPatchInfo(int indexNumber) { + oscSender.sendOscMessage(OscOutgoing.GET_PATCH_INFO, indexNumber); + } + + + /* + * METHODS - COMMON TASKS - UPDATE CHANNEL + */ + public void selectChannel(int channelNum) { + oscSender.sendOscMessage(OscOutgoing.SELECT_CHANNEL + channelNum); + oscSender.sendOscMessage(OscOutgoing.KEY_ENTER); + } + public void selectChannel(Channel channelIn) { + oscSender.sendOscMessage(OscOutgoing.SELECT_CHANNEL + channelIn.getChannelNum()); + oscSender.sendOscMessage(OscOutgoing.KEY_ENTER); + } + + + /* + * CONSTRUCTOR + */ + public OscSenderRoutines(OscSender oscSender) { + this.oscSender = oscSender; + } +} \ No newline at end of file