diff --git a/photon/src/main/java/com/strikete/photon/Photon.java b/photon/src/main/java/com/strikete/photon/Photon.java index 6e01b60..80b4d61 100644 --- a/photon/src/main/java/com/strikete/photon/Photon.java +++ b/photon/src/main/java/com/strikete/photon/Photon.java @@ -37,34 +37,35 @@ public class Photon { public static final String version = "SNAPSHOT 0.9.0"; public OscSender sender; public OscInterpreter interpreter; + public PhotonDataUtilities dataUtility; /* * VARIABLES - EOS SPECIFIC */ - private String eosVersion; + public String eosVersion; /* * 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; + public ArrayList beamPalettes; + public ArrayList channels; + public ArrayList colorPalettes; + public ArrayList cues; + public ArrayList cuelists; + public ArrayList curves; + public ArrayList effects; + public ArrayList fixtures; + public ArrayList focusPalettes; + public ArrayList groups; + public ArrayListintensityPalettes; + public ArrayList macros; + public ArrayList magicSheets; + public ArrayList pixelmaps; + public ArrayList presets; + public ArrayList snapshots; + public ArrayList subs; /* @@ -145,6 +146,6 @@ public Photon() { log = Logger.getLogger(Photon.class); BasicConfigurator.configure(); initializeVariables(); - + this.dataUtility = new PhotonDataUtilities(this); } } diff --git a/photon/src/main/java/com/strikete/photon/PhotonDataUtilities.java b/photon/src/main/java/com/strikete/photon/PhotonDataUtilities.java new file mode 100644 index 0000000..4255169 --- /dev/null +++ b/photon/src/main/java/com/strikete/photon/PhotonDataUtilities.java @@ -0,0 +1,151 @@ +package com.strikete.photon; + +public class PhotonDataUtilities { + + /* + * VARIABLES + */ + private Photon photon; + + + /* + * METHODS - CHECK EXISTING ARRAY BY EOS-UID + */ + public boolean doesBeamPaletteExist(String uid) { + for(int x = 0; x < photon.beamPalettes.size(); x++) { + if(photon.beamPalettes.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesChannelExist(String uid) { + for(int x = 0; x < photon.channels.size(); x++) { + if(photon.channels.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesColorPaletteExist(String uid) { + for(int x = 0; x < photon.colorPalettes.size(); x++) { + if(photon.colorPalettes.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesCueExist(String uid) { + for(int x = 0; x < photon.cues.size(); x++) { + if(photon.cues.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesCuelistExist(String uid) { + for(int x = 0; x < photon.cuelists.size(); x++) { + if(photon.cuelists.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesCurveExist(String uid) { + for(int x = 0; x < photon.curves.size(); x++) { + if(photon.curves.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesEffectExist(String uid) { + for(int x = 0; x < photon.effects.size(); x++) { + if(photon.effects.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + //FIXTURES DO NOT HAVE A UID + public boolean doesFocusPaletteExist(String uid) { + for(int x = 0; x < photon.focusPalettes.size(); x++) { + if(photon.focusPalettes.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesGroupExist(String uid) { + for(int x = 0; x < photon.groups.size(); x++) { + if(photon.groups.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesIntensityPaletteExist(String uid) { + for(int x = 0; x < photon.intensityPalettes.size(); x++) { + if(photon.intensityPalettes.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesMacroExist(String uid) { + for(int x = 0; x < photon.macros.size(); x++) { + if(photon.macros.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesMagicSheetExist(String uid) { + for(int x = 0; x < photon.magicSheets.size(); x++) { + if(photon.magicSheets.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesPixelmapExist(String uid) { + for(int x = 0; x < photon.pixelmaps.size(); x++) { + if(photon.pixelmaps.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesPresetExist(String uid) { + for(int x = 0; x < photon.presets.size(); x++) { + if(photon.presets.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesSnapshotExist(String uid) { + for(int x = 0; x < photon.snapshots.size(); x++) { + if(photon.snapshots.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + public boolean doesSubExist(String uid) { + for(int x = 0; x < photon.subs.size(); x++) { + if(photon.subs.get(0).getUid().equals(uid)) { + return true; + } + } + return false; + } + + + /* + * CONSTRUCTOR + */ + public PhotonDataUtilities(Photon photonIn) { + this.photon = photonIn; + } +} \ No newline at end of file diff --git a/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java b/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java index 9110270..bd5fe83 100644 --- a/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java +++ b/photon/src/main/java/com/strikete/photon/osc/OscIncoming.java @@ -31,6 +31,33 @@ public class OscIncoming { public static String RETURN_CUE_EFFECTS = "/eos/out/get/cue/[int]/[float]/[int]/fx/list/[int]/[int]"; public static String RETURN_CUE_LINKS = "/eos/out/get/cue/[int]/[float]/[int]/links/list/[int]/[int]"; public static String RETURN_CUE_ACTIONS = "/eos/out/get/cue/[int]/[float]/[int]/actions/list/[int]/[int]"; - + public static String RETURN_GROUP = "/eos/out/get/group/[float]/list/[int]/[int]"; + public static String RETURN_GROUP_CHANNELS = "/eos/out/get/group/[float]/channels/list/[int]/[int]"; + public static String RETURN_MACRO = "/eos/out/get/macro/[int]/list/[int]/[int]"; + public static String RETURN_MACRO_COMMAND = "/eos/out/get/macro/[int]/text/list/[int]/[int]"; + public static String RETURN_SUB = "/eos/out/get/sub/[int]/list/[int]/[int]"; + public static String RETURN_SUB_EFFECTS = "/eos/out/get/sub/[int]/fx/list/[int]/[int]"; + public static String RETURN_PRESET = "/eos/out/get/preset/[float]/list/[int]/[int]"; + public static String RETURN_PRESET_CHANNELS = "/eos/out/get/preset/[float]/channels/list/[int]/[int]"; + public static String RETURN_PRESET_CHANNELS_BY_TYPE = "/eos/out/get/preset/[float]/byType/list/[int]/[int]"; + public static String RETURN_PRESET_EFFECTS = "/eos/out/get/preset/[float]/fx/list/[int]/[int]"; + public static String RETURN_INTENSITY_PALETTE = "/eos/out/get/ip/[float]/list/[int]/[int]"; + public static String RETURN_INTENSITY_PALETTE_CHANNELS = "/eos/out/get/ip/[float]/channels/list/[int]/[int]"; + public static String RETURN_INTENSITY_PALETTE_CHANNELS_BY_TYPE = "/eos/out/get/ip/[float]/byType/list/[int]/[int]"; + public static String RETURN_FOCUS_PALETTE = "/eos/out/get/fp/[float]/list/[int]/[int]"; + public static String RETURN_FOCUS_PALETTE_CHANNELS = "/eos/out/get/fp/[float]/channels/list/[int]/[int]"; + public static String RETURN_FOCUS_PALETTE_CHANNELS_BY_TYPE = "/eos/out/get/fp/[float]/byType/list/[int]/[int]"; + public static String RETURN_COLOR_PALETTE = "/eos/out/get/cp/[float]/list/[int]/[int]"; + public static String RETURN_COLOR_PALETTE_CHANNELS = "/eos/out/get/cp/[float]/channels/list/[int]/[int]"; + public static String RETURN_COLOR_PALETTE_CHANNELS_BY_TYPE = "/eos/out/get/cp/[float]/byType/list/[int]/[int]"; + public static String RETURN_BEAM_PALETTE = "/eos/out/get/bp/[float]/list/[int]/[int]"; + public static String RETURN_BEAM_PALETTE_CHANNELS = "/eos/out/get/bp/[float]/channels/list/[int]/[int]"; + public static String RETURN_BEAM_PALETTE_CHANNELS_BY_TYPE = "/eos/out/get/bp/[float]/byType/list/[int]/[int]"; + public static String RETURN_CURVE = "/eos/out/get/curve/[int]/list/[int]/[int]"; + public static String RETURN_EFFECT = "/eos/out/get/fx/[float]/list/[int]/[int]"; + public static String RETURN_SNAPSHOT = "/eos/out/get/snap/[int]/list/[int]/[int]"; + public static String RETURN_PIXELMAP = "/eos/out/get/pixmap/[int]/list/[int]/[int]"; + public static String RETURN_PIXELMAP_CHANNELS = "/eos/out/get/pixmap/[int]/channels/list/[int]/[int]"; + public static String RETURN_MAGIC_SHEET = "/eos/out/get/ms/[int]/list/[int]/[int]"; } diff --git a/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java b/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java index 0c50c43..f750260 100644 --- a/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java +++ b/photon/src/main/java/com/strikete/photon/osc/OscInterpreter.java @@ -95,7 +95,7 @@ public void acceptMessage(OSCMessageEvent event) { if(doArraysMatch(messageAddressArray, listenerAddressArray)) { //Compare the two arrays oscListeners.get(a).postToConsumer(event.getMessage(), photon); } - }else { //NON-EXACT MATCHES + }else { //TODO:NON-EXACT MATCHES } } diff --git a/photon/src/main/java/com/strikete/photon/photonosc/PhotonOscRoutines.java b/photon/src/main/java/com/strikete/photon/photonosc/PhotonOscRoutines.java index 78c0f07..ccb087a 100644 --- a/photon/src/main/java/com/strikete/photon/photonosc/PhotonOscRoutines.java +++ b/photon/src/main/java/com/strikete/photon/photonosc/PhotonOscRoutines.java @@ -31,9 +31,41 @@ private void createVersionListener() { listeners.add(versionListener); } + /* + * METHODS - COUNT CONSUMERS + */ + + private void performResponse(int count, String message) { + for(int b = 0; b < count; b++) { + try { + Thread.sleep(delay); + } catch (InterruptedException e) { + // TODO Add generic Thread sleep error + e.printStackTrace(); + } + ArrayList indexParameter = new ArrayList(); + indexParameter.add(Integer.toString(b)); + photon.sender.sendOscMessage(photon.sender.parameterizeString(message, indexParameter)); + } + } + private void createCountListeners() { - Consumer patchCountConsumer = message -> { + Consumer patchCountConsumer = message -> { //PATCH COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_PATCH_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_PATCH,patchCountConsumer,true)); + + Consumer cuelistCountConsumer = message -> { //CUELIST COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_CUELIST_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_CUELIST_COUNT,cuelistCountConsumer,true)); + + Consumer cueCountConsumer = message -> { //CUE COUNT CONSUMER List argList = message.getArguments(); int count = (Integer) argList.get(0); for(int b = 0; b < count; b++) { @@ -44,24 +76,129 @@ private void createCountListeners() { e.printStackTrace(); } ArrayList indexParameter = new ArrayList(); + String messageAddress = message.getAddress(); + String[] messageAddressArray = messageAddress.split("/"); + indexParameter.add(messageAddressArray[5]); indexParameter.add(Integer.toString(b)); - photon.sender.sendOscMessage(photon.sender.parameterizeString(OscOutgoing.GET_PATCH_INFO, indexParameter)); + photon.sender.sendOscMessage(photon.sender.parameterizeString(OscOutgoing.GET_CUE_INFO, indexParameter)); } }; - OscListener patchCountListener = new OscListener(photon,OscIncoming.RETURN_PATCH,patchCountConsumer,true); - listeners.add(patchCountListener); + listeners.add(new OscListener(photon,OscIncoming.RETURN_CUE_COUNT,cueCountConsumer,true)); + + Consumer groupCountConsumer = message -> { //GROUP COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_GROUP_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_GROUP_COUNT,groupCountConsumer,true)); + + Consumer macroCountConsumer = message -> { //MACRO COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_MACRO_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_MACRO_COUNT,macroCountConsumer,true)); + + Consumer subCountConsumer = message -> { //SUB COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_SUB_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_SUB_COUNT,subCountConsumer,true)); + + Consumer presetCountConsumer = message -> { //PRESET COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_PRESET_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_PRESET_COUNT,presetCountConsumer,true)); + + Consumer intensityPaletteCountConsumer = message -> { //INTENSITY PALETTE COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_INTENSITY_PALETTE_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_INTENSITY_PALETTE_COUNT,intensityPaletteCountConsumer,true)); + + Consumer focusPaletteCountConsumer = message -> { //FOCUS PALETTE COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_FOCUS_PALETTE_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_FOCUS_PALETTE_COUNT,focusPaletteCountConsumer,true)); + + Consumer colorPaletteCountConsumer = message -> { //COLOR PALETTE COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_COLOR_PALETTE_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_COLOR_PALETTE_COUNT,colorPaletteCountConsumer,true)); + + Consumer beamPaletteCountConsumer = message -> { //BEAM PALETTE COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_BEAM_PALETTE_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_BEAM_PALETTE_COUNT,beamPaletteCountConsumer,true)); + + Consumer curveCountConsumer = message -> { //CURVE COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_CURVE_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_CURVE_COUNT,curveCountConsumer,true)); + + Consumer effectCountConsumer = message -> { //EFFECT COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_EFFECT_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_EFFECT_COUNT,effectCountConsumer,true)); + + Consumer snapshotCountConsumer = message -> { //SNAPSHOT COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_SNAPSHOT_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_SNAPSHOT_COUNT,snapshotCountConsumer,true)); + + Consumer pixelmapCountConsumer = message -> { //PIXELMAP COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_PIXELMAP_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_PIXELMAP_COUNT,pixelmapCountConsumer,true)); + Consumer magicSheetCountConsumer = message -> { //MAGIC SHEET COUNT CONSUMER + List argList = message.getArguments(); + int count = (Integer) argList.get(0); + performResponse(count,OscOutgoing.GET_MAGIC_SHEET_INFO); + }; + listeners.add(new OscListener(photon,OscIncoming.RETURN_MAGIC_SHEET_COUNT,magicSheetCountConsumer,true)); } + /* + * METHODS - INFO CONSUMERS + */ + private void createInfoListeners() { + + + + + + + } + /* - * REGISTRAR + * METHODS - REGISTRAR */ private void createConsumers() { createVersionListener(); createCountListeners(); + createInfoListeners(); } private void registerListeners() { @@ -80,4 +217,4 @@ public PhotonOscRoutines(Photon photonIn, int delayIn) { createConsumers(); registerListeners(); } -} +} \ No newline at end of file