mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Started work on adding effect engine config to HyperCon
Former-commit-id: c899c72d15de8cbe0b83f5458a4484eb794a9071
This commit is contained in:
parent
068a98b84f
commit
3531bab2a1
@ -0,0 +1,206 @@
|
||||
package org.hyperion.hypercon;
|
||||
|
||||
public class JsonStringBuffer {
|
||||
|
||||
private final StringBuffer mStrBuf = new StringBuffer();
|
||||
|
||||
private final int mStartIndentLevel;
|
||||
private int mIndentLevel = 0;
|
||||
|
||||
/** Flag indicating that the parts written are 'commented-out' */
|
||||
private boolean mComment = false;
|
||||
|
||||
public JsonStringBuffer() {
|
||||
this(0);
|
||||
|
||||
mStrBuf.append("{\n");
|
||||
++mIndentLevel;
|
||||
}
|
||||
|
||||
public JsonStringBuffer(int pIndentLevel) {
|
||||
mStartIndentLevel = pIndentLevel;
|
||||
mIndentLevel = pIndentLevel;
|
||||
}
|
||||
|
||||
public void newLine() {
|
||||
mStrBuf.append('\n');
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
|
||||
for (int i=0; i<mIndentLevel; ++i) {
|
||||
mStrBuf.append('\t');
|
||||
}
|
||||
mStrBuf.append("\"end-of-json\" : \"end-of-json\"\n");
|
||||
|
||||
--mIndentLevel;
|
||||
if (mIndentLevel != mStartIndentLevel) {
|
||||
System.err.println("Json write closed in incorrect state!");
|
||||
}
|
||||
for (int i=0; i<mIndentLevel; ++i) {
|
||||
mStrBuf.append('\t');
|
||||
}
|
||||
mStrBuf.append("}\n");
|
||||
}
|
||||
|
||||
public void writeComment(String pComment) {
|
||||
String[] commentLines = pComment.split("\\r?\\n");
|
||||
|
||||
for (String commentLine : commentLines) {
|
||||
for (int i=0; i<mIndentLevel; ++i) {
|
||||
mStrBuf.append('\t');
|
||||
}
|
||||
mStrBuf.append("/// ").append(commentLine).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleComment(boolean b) {
|
||||
mComment = b;
|
||||
}
|
||||
|
||||
private void startLine() {
|
||||
if (mComment) mStrBuf.append("// ");
|
||||
for (int i=0; i<mIndentLevel; ++i) {
|
||||
mStrBuf.append('\t');
|
||||
}
|
||||
}
|
||||
|
||||
public void startObject(String pKey) {
|
||||
if (!pKey.isEmpty()) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : \n");
|
||||
}
|
||||
startLine();
|
||||
mStrBuf.append("{\n");
|
||||
|
||||
++mIndentLevel;
|
||||
}
|
||||
|
||||
public void stopObject(boolean endOfSection) {
|
||||
--mIndentLevel;
|
||||
|
||||
startLine();
|
||||
if (endOfSection) {
|
||||
mStrBuf.append("}\n");
|
||||
} else {
|
||||
mStrBuf.append("},\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void stopObject() {
|
||||
--mIndentLevel;
|
||||
|
||||
startLine();
|
||||
mStrBuf.append("},\n");
|
||||
}
|
||||
|
||||
public void startArray(String pKey) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : \n");
|
||||
startLine();
|
||||
mStrBuf.append("[\n");
|
||||
|
||||
++mIndentLevel;
|
||||
}
|
||||
|
||||
public void stopArray() {
|
||||
--mIndentLevel;
|
||||
|
||||
startLine();
|
||||
mStrBuf.append("],\n");
|
||||
}
|
||||
|
||||
|
||||
public void addRawValue(String pKey, String pValue, boolean lastValue) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : ").append(pValue);
|
||||
if (lastValue) {
|
||||
mStrBuf.append("\n");
|
||||
} else {
|
||||
mStrBuf.append(",\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void addValue(String pKey, String pValue, boolean lastValue) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : ").append('"').append(pValue).append('"');
|
||||
if (lastValue) {
|
||||
mStrBuf.append("\n");
|
||||
} else {
|
||||
mStrBuf.append(",\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void addValue(String pKey, double pValue, boolean lastValue) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : ").append(pValue);
|
||||
if (lastValue) {
|
||||
mStrBuf.append("\n");
|
||||
} else {
|
||||
mStrBuf.append(",\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void addValue(String pKey, int pValue, boolean lastValue) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : ").append(pValue);
|
||||
if (lastValue) {
|
||||
mStrBuf.append("\n");
|
||||
} else {
|
||||
mStrBuf.append(",\n");
|
||||
}
|
||||
}
|
||||
|
||||
public void addValue(String pKey, boolean pValue, boolean lastValue) {
|
||||
startLine();
|
||||
mStrBuf.append('"').append(pKey).append('"').append(" : ").append(pValue);
|
||||
if (lastValue) {
|
||||
mStrBuf.append("\n");
|
||||
} else {
|
||||
mStrBuf.append(",\n");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mStrBuf.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] pArgs) {
|
||||
JsonStringBuffer jsonBuf = new JsonStringBuffer();
|
||||
|
||||
String comment = "Device configuration contains the following fields: \n" +
|
||||
"* 'name' : The user friendly name of the device (only used for display purposes) \n" +
|
||||
"* 'type' : The type of the device or leds (known types for now are 'ws2801', 'lpd6803', 'sedu', 'test' and 'none') \n" +
|
||||
"* 'output' : The output specification depends on selected device \n" +
|
||||
" - 'ws2801' this is the device (eg '/dev/spidev0.0 or /dev/ttyS0') \n" +
|
||||
" - 'test' this is the file used to write test output (eg '/home/pi/hyperion.out') \n" +
|
||||
"* 'rate' : The baudrate of the output to the device \n" +
|
||||
"* 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.). \n";
|
||||
jsonBuf.writeComment(comment);
|
||||
|
||||
jsonBuf.startObject("device");
|
||||
jsonBuf.addValue("name", "MyPi", false);
|
||||
jsonBuf.addValue("type", "ws2801", false);
|
||||
jsonBuf.addValue("output", "/dev/spidev0.0", false);
|
||||
jsonBuf.addValue("rate", 1000000, false);
|
||||
jsonBuf.addValue("colorOrder", "rgb", true);
|
||||
jsonBuf.stopObject();
|
||||
|
||||
jsonBuf.toggleComment(true);
|
||||
jsonBuf.startObject("device");
|
||||
jsonBuf.addValue("name", "MyPi", false);
|
||||
jsonBuf.addValue("type", "ws2801", false);
|
||||
jsonBuf.addValue("output", "/dev/spidev0.0", false);
|
||||
jsonBuf.addValue("rate", 1000000, false);
|
||||
jsonBuf.addValue("colorOrder", "rgb", true);
|
||||
jsonBuf.stopObject();
|
||||
jsonBuf.toggleComment(false);
|
||||
|
||||
jsonBuf.finish();
|
||||
|
||||
System.out.println(jsonBuf.toString());
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import java.util.Vector;
|
||||
|
||||
import org.hyperion.hypercon.spec.ColorConfig;
|
||||
import org.hyperion.hypercon.spec.DeviceConfig;
|
||||
import org.hyperion.hypercon.spec.EffectEngineConfig;
|
||||
import org.hyperion.hypercon.spec.ImageProcessConfig;
|
||||
import org.hyperion.hypercon.spec.Led;
|
||||
import org.hyperion.hypercon.spec.LedFrameConstruction;
|
||||
@ -17,19 +18,22 @@ import org.hyperion.hypercon.spec.MiscConfig;
|
||||
public class LedString {
|
||||
|
||||
/** The configuration of the output device */
|
||||
public DeviceConfig mDeviceConfig = new DeviceConfig();
|
||||
public final DeviceConfig mDeviceConfig = new DeviceConfig();
|
||||
|
||||
/** THe configuration of the 'physical' led frame */
|
||||
public LedFrameConstruction mLedFrameConfig = new LedFrameConstruction();
|
||||
public final LedFrameConstruction mLedFrameConfig = new LedFrameConstruction();
|
||||
|
||||
/** The configuration of the image processing */
|
||||
public ImageProcessConfig mProcessConfig = new ImageProcessConfig();
|
||||
public final ImageProcessConfig mProcessConfig = new ImageProcessConfig();
|
||||
|
||||
/** The color adjustment configuration */
|
||||
public ColorConfig mColorConfig = new ColorConfig();
|
||||
public final ColorConfig mColorConfig = new ColorConfig();
|
||||
|
||||
/** The miscellaneous configuration (bootsequence, blackborder detector, etc) */
|
||||
public MiscConfig mMiscConfig = new MiscConfig();
|
||||
public final MiscConfig mMiscConfig = new MiscConfig();
|
||||
|
||||
/** The effect engine configuration, containing the Effects */
|
||||
public final EffectEngineConfig mEffectEngineConfig = new EffectEngineConfig();
|
||||
|
||||
/** The translation of the led frame construction and image processing to individual led configuration */
|
||||
public Vector<Led> leds;
|
||||
@ -55,14 +59,27 @@ public class LedString {
|
||||
String colorJson = mColorConfig.toJsonString();
|
||||
fw.write(colorJson + ",\n\n");
|
||||
|
||||
String ledJson = ledToJsonString();
|
||||
fw.write(ledJson + ",\n\n");
|
||||
JsonStringBuffer jsonBuf = new JsonStringBuffer(1);
|
||||
|
||||
ledsAppendTo(jsonBuf);
|
||||
|
||||
String blackBorderJson = mProcessConfig.getBlackborderJson();
|
||||
fw.write(blackBorderJson + ",\n\n");
|
||||
jsonBuf.newLine();
|
||||
|
||||
String miscJson = mMiscConfig.toJsonString();
|
||||
fw.write(miscJson + "\n");
|
||||
mProcessConfig.appendTo(jsonBuf);
|
||||
|
||||
jsonBuf.newLine();
|
||||
|
||||
mMiscConfig.appendTo(jsonBuf);
|
||||
|
||||
jsonBuf.newLine();
|
||||
|
||||
mEffectEngineConfig.appendTo(jsonBuf);
|
||||
|
||||
jsonBuf.newLine();
|
||||
|
||||
jsonBuf.addValue("endOfJson", "endOfJson", true);
|
||||
|
||||
fw.write(jsonBuf.toString());
|
||||
|
||||
fw.write("}\n");
|
||||
} catch (IOException e) {
|
||||
@ -70,42 +87,28 @@ public class LedString {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the list with leds specifications to a JSON string as used by the Hyperion Deamon
|
||||
*
|
||||
* @return The JSON string with led-specifications
|
||||
*/
|
||||
String ledToJsonString() {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
|
||||
strBuf.append("\t/// The configuration for each individual led. This contains the specification of the area \n");
|
||||
strBuf.append("\t/// averaged of an input image for each led to determine its color. Each item in the list \n");
|
||||
strBuf.append("\t/// contains the following fields:\n");
|
||||
strBuf.append("\t/// * index: The index of the led. This determines its location in the string of leds; zero \n");
|
||||
strBuf.append("\t/// being the first led.\n");
|
||||
strBuf.append("\t/// * hscan: The fractional part of the image along the horizontal used for the averaging \n");
|
||||
strBuf.append("\t/// (minimum and maximum inclusive)\n");
|
||||
strBuf.append("\t/// * vscan: The fractional part of the image along the vertical used for the averaging \n");
|
||||
strBuf.append("\t/// (minimum and maximum inclusive)\n");
|
||||
|
||||
strBuf.append("\t\"leds\" : \n");
|
||||
strBuf.append("\t[\n");
|
||||
void ledsAppendTo(JsonStringBuffer pJsonBuf) {
|
||||
String ledComment =
|
||||
" The configuration for each individual led. This contains the specification of the area \n" +
|
||||
" averaged of an input image for each led to determine its color. Each item in the list \n" +
|
||||
" contains the following fields:\n" +
|
||||
" * index: The index of the led. This determines its location in the string of leds; zero \n" +
|
||||
" being the first led.\n" +
|
||||
" * hscan: The fractional part of the image along the horizontal used for the averaging \n" +
|
||||
" (minimum and maximum inclusive)\n" +
|
||||
" * vscan: The fractional part of the image along the vertical used for the averaging \n" +
|
||||
" (minimum and maximum inclusive)\n";
|
||||
pJsonBuf.writeComment(ledComment);
|
||||
|
||||
pJsonBuf.startArray("leds");
|
||||
for (Led led : leds)
|
||||
{
|
||||
strBuf.append("\t\t{\n");
|
||||
strBuf.append(String.format(Locale.ROOT, "\t\t\t\"index\" : %d,\n", led.mLedSeqNr));
|
||||
strBuf.append(String.format(Locale.ROOT, "\t\t\t\"hscan\" : { \"minimum\" : %.4f, \"maximum\" : %.4f },\n", led.mImageRectangle.getMinX(), led.mImageRectangle.getMaxX()));
|
||||
strBuf.append(String.format(Locale.ROOT, "\t\t\t\"vscan\" : { \"minimum\" : %.4f, \"maximum\" : %.4f }\n", led.mImageRectangle.getMinY(), led.mImageRectangle.getMaxY()));
|
||||
if (led != leds.lastElement()) {
|
||||
strBuf.append("\t\t},\n");
|
||||
} else {
|
||||
strBuf.append("\t\t}\n");
|
||||
}
|
||||
pJsonBuf.startObject("");
|
||||
pJsonBuf.addValue("index", led.mLedSeqNr, false);
|
||||
pJsonBuf.addRawValue("hscan", String.format(Locale.ENGLISH, "{ %1$cminimum%1$c : %2$.4f, %1$cmaximum%1$c : %3$.4f }", '"', led.mImageRectangle.getMinX(), led.mImageRectangle.getMaxX()), false);
|
||||
pJsonBuf.addRawValue("vscan", String.format(Locale.ENGLISH, "{ %1$cminimum%1$c : %2$.4f, %1$cmaximum%1$c : %3$.4f }", '"', led.mImageRectangle.getMinY(), led.mImageRectangle.getMaxY()), true);
|
||||
pJsonBuf.stopObject(led.equals(leds.get(leds.size()-1)));
|
||||
}
|
||||
|
||||
strBuf.append("\t]");
|
||||
|
||||
return strBuf.toString();
|
||||
pJsonBuf.stopArray();
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class ColorSmoothingPanel extends JPanel {
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
mColorConfig.mSmoothingTime_ms = (Integer)mTimeSpinner.getValue();
|
||||
mColorConfig.mSmoothingUpdateFrequency_Hz = (Integer)mUpdateFrequencySpinner.getValue();
|
||||
mColorConfig.mSmoothingUpdateFrequency_Hz = (Double)mUpdateFrequencySpinner.getValue();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ public class ConfigPanel extends JPanel {
|
||||
mSpecificationTabs.addTab("Hardware", getHardwarePanel());
|
||||
mSpecificationTabs.addTab("Process", getProcessPanel());
|
||||
mSpecificationTabs.addTab("External", getExternalPanel());
|
||||
mSpecificationTabs.addTab("Effect Engine", new EffectEnginePanel(ledString.mEffectEngineConfig));
|
||||
}
|
||||
return mSpecificationTabs;
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package org.hyperion.hypercon.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
import org.hyperion.hypercon.spec.EffectConfig;
|
||||
import org.hyperion.hypercon.spec.EffectEngineConfig;
|
||||
|
||||
public class EffectEnginePanel extends JPanel {
|
||||
|
||||
private final EffectEngineConfig mEffectEngingeConfig;
|
||||
|
||||
private JPanel mControlPanel;
|
||||
private JComboBox<EffectConfig> mEffectCombo;
|
||||
private JButton mAddButton;
|
||||
private JButton mDelButton;
|
||||
|
||||
private JPanel mEffectPanel;
|
||||
private JLabel mPythonLabel;
|
||||
private JComboBox<String> mPythonCombo;
|
||||
private JLabel mJsonArgumentLabel;
|
||||
private JTextArea mJsonArgumentArea;
|
||||
|
||||
public EffectEnginePanel(final EffectEngineConfig pEffectEngineConfig) {
|
||||
super();
|
||||
|
||||
mEffectEngingeConfig = pEffectEngineConfig;
|
||||
|
||||
initialise();
|
||||
}
|
||||
|
||||
private void initialise() {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
add(getControlPanel(), BorderLayout.NORTH);
|
||||
add(getEffectPanel(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
private JPanel getControlPanel() {
|
||||
if (mControlPanel == null) {
|
||||
mControlPanel = new JPanel();
|
||||
mControlPanel.setPreferredSize(new Dimension(150, 35));
|
||||
mControlPanel.setLayout(new BoxLayout(mControlPanel, BoxLayout.LINE_AXIS));
|
||||
|
||||
mEffectCombo = new JComboBox<>(mEffectEngingeConfig.mEffects);
|
||||
mEffectCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
mControlPanel.add(mEffectCombo);
|
||||
|
||||
mAddButton = new JButton("Add");
|
||||
mControlPanel.add(mAddButton);
|
||||
|
||||
mDelButton = new JButton("Del");
|
||||
mControlPanel.add(mDelButton);
|
||||
}
|
||||
return mControlPanel;
|
||||
}
|
||||
|
||||
private JPanel getEffectPanel() {
|
||||
if (mEffectPanel == null) {
|
||||
mEffectPanel = new JPanel();
|
||||
mEffectPanel.setBorder(BorderFactory.createTitledBorder("test-slow"));
|
||||
mEffectPanel.setLayout(new BoxLayout(mEffectPanel, BoxLayout.PAGE_AXIS));
|
||||
|
||||
JPanel subPanel = new JPanel(new BorderLayout());
|
||||
mEffectPanel.add(subPanel);
|
||||
|
||||
mPythonLabel = new JLabel("Python: ");
|
||||
subPanel.add(mPythonLabel, BorderLayout.WEST);
|
||||
|
||||
mPythonCombo = new JComboBox<>(new String[] {"test.py", "rainbow-swirl.py", "rainbow-mood.py"});
|
||||
mPythonCombo.setMaximumSize(new Dimension(150, 25));
|
||||
subPanel.add(mPythonCombo);
|
||||
|
||||
mJsonArgumentLabel = new JLabel("Arguments:");
|
||||
mEffectPanel.add(mJsonArgumentLabel);
|
||||
|
||||
mJsonArgumentArea = new JTextArea();
|
||||
mEffectPanel.add(mJsonArgumentArea);
|
||||
}
|
||||
return mEffectPanel;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package org.hyperion.hypercon.spec;
|
||||
|
||||
import org.hyperion.hypercon.JsonStringBuffer;
|
||||
|
||||
/**
|
||||
* The configuration structure for a single 'effect'.
|
||||
*/
|
||||
public class EffectConfig {
|
||||
|
||||
/** The identifier of the effect */
|
||||
public String mId;
|
||||
|
||||
/** The python-script used to generate the effect */
|
||||
public String mScript;
|
||||
|
||||
/** The JSON-string containing the arguments of the python-script */
|
||||
public String mArgs;
|
||||
|
||||
public void append(JsonStringBuffer pJsonBuf, boolean endOfEffects) {
|
||||
pJsonBuf.startObject(mId);
|
||||
pJsonBuf.addValue("script", mScript, false);
|
||||
|
||||
pJsonBuf.startObject("args");
|
||||
pJsonBuf.stopObject();
|
||||
|
||||
pJsonBuf.stopObject(!endOfEffects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mId;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package org.hyperion.hypercon.spec;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.hyperion.hypercon.JsonStringBuffer;
|
||||
|
||||
/**
|
||||
* The configuration structure for the effect engine. It contains definition for zero or more
|
||||
* 'effects'
|
||||
*/
|
||||
public class EffectEngineConfig {
|
||||
|
||||
public final Vector<EffectConfig> mEffects = new Vector<>();
|
||||
{
|
||||
EffectConfig testSlow = new EffectConfig();
|
||||
testSlow.mId = "test-slow";
|
||||
testSlow.mScript = "/home/pi/hyperion/test.py";
|
||||
testSlow.mArgs = "speed : 0.5";
|
||||
|
||||
EffectConfig testFast = new EffectConfig();
|
||||
testFast.mId = "test-fast";
|
||||
testFast.mScript = "/home/pi/hyperion/test.py";
|
||||
testFast.mArgs = "speed : 2.0";
|
||||
|
||||
EffectConfig rainbowSwirl = new EffectConfig();
|
||||
rainbowSwirl.mId = "Rainbow swirl";
|
||||
rainbowSwirl.mScript = "/home/pi/hyperion/rainbow-swirl.py";
|
||||
rainbowSwirl.mArgs =
|
||||
"\"rotation-time\" : 10.0,\n" +
|
||||
"\"brightness\" : 1.0,\n" +
|
||||
"\"reverse\" : false\n";
|
||||
|
||||
EffectConfig rainbowMood = new EffectConfig();
|
||||
rainbowMood.mId = "Rainbow mood";
|
||||
rainbowMood.mScript = "/home/pi/hyperion/rainbow-mood.py";
|
||||
rainbowMood.mArgs =
|
||||
"\"rotation-time\" : 10.0,\n" +
|
||||
"\"brightness\" : 1.0,\n" +
|
||||
"\"reverse\" : false\n";
|
||||
|
||||
mEffects.add(testSlow);
|
||||
mEffects.add(testFast);
|
||||
mEffects.add(rainbowSwirl);
|
||||
mEffects.add(rainbowMood);
|
||||
}
|
||||
|
||||
public void appendTo(JsonStringBuffer pJsonBuf) {
|
||||
pJsonBuf.startObject("effects");
|
||||
|
||||
for (EffectConfig effect : mEffects) {
|
||||
effect.append(pJsonBuf, effect.equals(mEffects.get(mEffects.size()-1)));
|
||||
}
|
||||
|
||||
pJsonBuf.addValue("endOfEffect", "endOfEffect", true);
|
||||
|
||||
pJsonBuf.stopObject();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package org.hyperion.hypercon.spec;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Observable;
|
||||
|
||||
import org.hyperion.hypercon.JsonStringBuffer;
|
||||
import org.hyperion.hypercon.LedFrameFactory;
|
||||
|
||||
/**
|
||||
@ -161,17 +161,15 @@ public class ImageProcessConfig extends Observable {
|
||||
}
|
||||
}
|
||||
|
||||
public String getBlackborderJson() {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
|
||||
strBuf.append("\t/// The black border configuration, contains the following items: \n");
|
||||
strBuf.append("\t/// * enable : true if the detector should be activated\n");
|
||||
public void appendTo(JsonStringBuffer pJsonBuf) {
|
||||
String comment =
|
||||
"The black border configuration, contains the following items: \n" +
|
||||
" * enable : true if the detector should be activated\n";
|
||||
pJsonBuf.writeComment(comment);
|
||||
|
||||
strBuf.append("\t\"blackborderdetector\" :\n");
|
||||
strBuf.append("\t{\n");
|
||||
strBuf.append(String.format(Locale.ROOT, "\t\t\"enable\" : %s\n", mBlackBorderRemoval ? "true" : "false"));
|
||||
strBuf.append("\t}");
|
||||
|
||||
return strBuf.toString();
|
||||
pJsonBuf.startObject("blackborderdetector");
|
||||
pJsonBuf.addValue("enable", mBlackBorderRemoval, true);
|
||||
pJsonBuf.stopObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.hyperion.hypercon.spec;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.hyperion.hypercon.JsonStringBuffer;
|
||||
|
||||
/**
|
||||
* Miscellaneous configuration items for the Hyperion daemon.
|
||||
@ -53,89 +53,116 @@ public class MiscConfig {
|
||||
/** The TCP port at which the Protobuf server is listening for incoming connections */
|
||||
public int mBoblightPort = 19333;
|
||||
|
||||
public void appendTo(JsonStringBuffer strBuf) {
|
||||
String bootsequenceComment =
|
||||
"The boot-sequence configuration, contains the following items: \n" +
|
||||
" * type : The type of the boot-sequence ('rainbow', 'knightrider', 'none') \n" +
|
||||
" * duration_ms : The length of the boot-sequence [ms]\n";
|
||||
strBuf.writeComment(bootsequenceComment);
|
||||
|
||||
strBuf.toggleComment(!mBootsequenceEnabled);
|
||||
strBuf.startObject("bootsequence");
|
||||
strBuf.addValue("type", mBootSequence.name(), false);
|
||||
strBuf.addValue("duration_ms", mBootSequenceLength_ms, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
|
||||
strBuf.newLine();
|
||||
|
||||
String grabComment =
|
||||
" The configuration for the frame-grabber, contains the following items: \n" +
|
||||
" * width : The width of the grabbed frames [pixels]\n" +
|
||||
" * height : The height of the grabbed frames [pixels]\n" +
|
||||
" * frequency_Hz : The frequency of the frame grab [Hz]\n";
|
||||
strBuf.writeComment(grabComment);
|
||||
|
||||
strBuf.toggleComment(!mFrameGrabberEnabled);
|
||||
strBuf.startObject("framegrabber");
|
||||
strBuf.addValue("width", mFrameGrabberWidth, false);
|
||||
strBuf.addValue("height", mFrameGrabberHeight, false);
|
||||
strBuf.addValue("frequency_Hz", 1000.0/mFrameGrabberInterval_ms, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
|
||||
strBuf.newLine();
|
||||
|
||||
String xbmcComment =
|
||||
"The configuration of the XBMC connection used to enable and disable the frame-grabber. Contains the following fields: \n" +
|
||||
" * xbmcAddress : The IP address of the XBMC-host\n" +
|
||||
" * xbmcTcpPort : The TCP-port of the XBMC-server\n" +
|
||||
" * grabVideo : Flag indicating that the frame-grabber is on(true) during video playback\n" +
|
||||
" * grabPictures : Flag indicating that the frame-grabber is on(true) during picture show\n" +
|
||||
" * grabAudio : Flag indicating that the frame-grabber is on(true) during audio playback\n" +
|
||||
" * grabMenu : Flag indicating that the frame-grabber is on(true) in the XBMC menu\n";
|
||||
strBuf.writeComment(xbmcComment);
|
||||
|
||||
strBuf.toggleComment(!mXbmcCheckerEnabled);
|
||||
strBuf.startObject("xbmcVideoChecker");
|
||||
strBuf.addValue("xbmcAddress", mXbmcAddress, false);
|
||||
strBuf.addValue("xbmcTcpPort", mXbmcTcpPort, false);
|
||||
strBuf.addValue("grabVideo", mVideoOn, false);
|
||||
strBuf.addValue("grabPictures", mPictureOn, false);
|
||||
strBuf.addValue("grabAudio", mAudioOn, false);
|
||||
strBuf.addValue("grabMenu", mMenuOn, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
|
||||
strBuf.newLine();
|
||||
|
||||
String jsonComment =
|
||||
"The configuration of the Json server which enables the json remote interface\n" +
|
||||
" * port : Port at which the json server is started\n";
|
||||
strBuf.writeComment(jsonComment);
|
||||
|
||||
strBuf.toggleComment(!mJsonInterfaceEnabled);
|
||||
strBuf.startObject("jsonServer");
|
||||
strBuf.addValue("port", mJsonPort, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
|
||||
strBuf.newLine();
|
||||
|
||||
String protoComment =
|
||||
"The configuration of the Proto server which enables the protobuffer remote interface\n" +
|
||||
" * port : Port at which the protobuffer server is started\n";
|
||||
strBuf.writeComment(protoComment);
|
||||
|
||||
strBuf.toggleComment(!mProtoInterfaceEnabled);
|
||||
strBuf.startObject("protoServer");
|
||||
strBuf.addValue("port", mProtoPort, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
|
||||
strBuf.newLine();
|
||||
|
||||
String boblightComment =
|
||||
"The configuration of the boblight server which enables the boblight remote interface\n" +
|
||||
" * port : Port at which the boblight server is started\n";
|
||||
strBuf.writeComment(boblightComment);
|
||||
|
||||
strBuf.toggleComment(!mBoblightInterfaceEnabled);
|
||||
strBuf.startObject("boblightServer");
|
||||
strBuf.addValue("port", mBoblightPort, true);
|
||||
strBuf.stopObject();
|
||||
strBuf.toggleComment(false);
|
||||
}
|
||||
/**
|
||||
* Creates the JSON string of the configuration as used in the Hyperion daemon configfile
|
||||
*
|
||||
* @return The JSON string of this MiscConfig
|
||||
*/
|
||||
public String toJsonString() {
|
||||
StringBuffer strBuf = new StringBuffer();
|
||||
|
||||
strBuf.append("\t/// The boot-sequence configuration, contains the following items: \n");
|
||||
strBuf.append("\t/// * type : The type of the boot-sequence ('rainbow', 'knightrider', 'none') \n");
|
||||
strBuf.append("\t/// * duration_ms : The length of the boot-sequence [ms]\n");
|
||||
JsonStringBuffer jsonBuf = new JsonStringBuffer(1);
|
||||
appendTo(jsonBuf);
|
||||
return jsonBuf.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] pArgs) {
|
||||
MiscConfig miscConfig = new MiscConfig();
|
||||
|
||||
String bootPreamble = mBootsequenceEnabled? "\t" : "//\t";
|
||||
strBuf.append(bootPreamble).append("\"bootsequence\" :\n");
|
||||
strBuf.append(bootPreamble).append("{\n");
|
||||
strBuf.append(bootPreamble).append(String.format(Locale.ROOT, "\t\"type\" : \"%s\",\n", mBootSequence.name()));
|
||||
strBuf.append(bootPreamble).append(String.format(Locale.ROOT, "\t\"duration_ms\" : %d\n", mBootSequenceLength_ms));
|
||||
strBuf.append(bootPreamble).append("},\n\n");
|
||||
|
||||
strBuf.append("\t/// The configuration for the frame-grabber, contains the following items: \n");
|
||||
strBuf.append("\t/// * width : The width of the grabbed frames [pixels]\n");
|
||||
strBuf.append("\t/// * height : The height of the grabbed frames [pixels]\n");
|
||||
strBuf.append("\t/// * frequency_Hz : The frequency of the frame grab [Hz]\n");
|
||||
JsonStringBuffer jsonBuf = new JsonStringBuffer(1);
|
||||
miscConfig.appendTo(jsonBuf);
|
||||
|
||||
String grabPreamble = mFrameGrabberEnabled? "\t" : "//\t";
|
||||
strBuf.append(grabPreamble).append("\"framegrabber\" :\n");
|
||||
strBuf.append(grabPreamble).append("{\n");
|
||||
strBuf.append(grabPreamble).append(String.format(Locale.ROOT, "\t\"width\" : %d,\n", mFrameGrabberWidth));
|
||||
strBuf.append(grabPreamble).append(String.format(Locale.ROOT, "\t\"height\" : %d,\n", mFrameGrabberHeight));
|
||||
strBuf.append(grabPreamble).append(String.format(Locale.ROOT, "\t\"frequency_Hz\" : %.1f\n", 1000.0/mFrameGrabberInterval_ms));
|
||||
strBuf.append(grabPreamble).append("},\n\n");
|
||||
|
||||
strBuf.append("\t/// The configuration of the XBMC connection used to enable and disable the frame-grabber. Contains the following fields: \n");
|
||||
strBuf.append("\t/// * xbmcAddress : The IP address of the XBMC-host\n");
|
||||
strBuf.append("\t/// * xbmcTcpPort : The TCP-port of the XBMC-server\n");
|
||||
strBuf.append("\t/// * grabVideo : Flag indicating that the frame-grabber is on(true) during video playback\n");
|
||||
strBuf.append("\t/// * grabPictures : Flag indicating that the frame-grabber is on(true) during picture show\n");
|
||||
strBuf.append("\t/// * grabAudio : Flag indicating that the frame-grabber is on(true) during audio playback\n");
|
||||
strBuf.append("\t/// * grabMenu : Flag indicating that the frame-grabber is on(true) in the XBMC menu\n");
|
||||
|
||||
String xbmcPreamble = mXbmcCheckerEnabled? "\t" : "//\t";
|
||||
strBuf.append(xbmcPreamble).append("\"xbmcVideoChecker\" :\n");
|
||||
strBuf.append(xbmcPreamble).append("{\n");
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"xbmcAddress\" : \"%s\",\n", mXbmcAddress));
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"xbmcTcpPort\" : %d,\n", mXbmcTcpPort));
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"grabVideo\" : %s,\n", mVideoOn));
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"grabPictures\" : %s,\n", mPictureOn));
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"grabAudio\" : %s,\n", mAudioOn));
|
||||
strBuf.append(xbmcPreamble).append(String.format(Locale.ROOT, "\t\"grabMenu\" : %s\n", mMenuOn));
|
||||
strBuf.append(xbmcPreamble).append("},\n\n");
|
||||
|
||||
|
||||
strBuf.append("\t/// The configuration of the Json server which enables the json remote interface\n");
|
||||
strBuf.append("\t/// * port : Port at which the json server is started\n");
|
||||
|
||||
String jsonPreamble = mJsonInterfaceEnabled? "\t" : "//\t";
|
||||
strBuf.append(jsonPreamble).append("\"jsonServer\" :\n");
|
||||
strBuf.append(jsonPreamble).append("{\n");
|
||||
strBuf.append(jsonPreamble).append(String.format(Locale.ROOT, "\t\"port\" : %d\n", mJsonPort));
|
||||
strBuf.append(jsonPreamble).append("},\n\n");
|
||||
|
||||
|
||||
strBuf.append("\t/// The configuration of the Proto server which enables the protobuffer remote interface\n");
|
||||
strBuf.append("\t/// * port : Port at which the protobuffer server is started\n");
|
||||
|
||||
String protoPreamble = mProtoInterfaceEnabled? "\t" : "//\t";
|
||||
strBuf.append(protoPreamble).append("\"protoServer\" :\n");
|
||||
strBuf.append(protoPreamble).append("{\n");
|
||||
strBuf.append(protoPreamble).append(String.format(Locale.ROOT, "\t\"port\" : %d\n", mProtoPort));
|
||||
strBuf.append(protoPreamble).append("},\n\n");
|
||||
|
||||
|
||||
strBuf.append("\t/// The configuration of the boblight server which enables the boblight remote interface\n");
|
||||
strBuf.append("\t/// * port : Port at which the boblight server is started\n");
|
||||
|
||||
String bobligthPreamble = mBoblightInterfaceEnabled? "\t" : "//\t";
|
||||
strBuf.append(bobligthPreamble).append("\"boblightServer\" :\n");
|
||||
strBuf.append(bobligthPreamble).append("{\n");
|
||||
strBuf.append(bobligthPreamble).append(String.format(Locale.ROOT, "\t\"port\" : %d\n", mBoblightPort));
|
||||
strBuf.append(bobligthPreamble).append("},\n\n");
|
||||
|
||||
strBuf.append("\t\"end-of-json\" : \"end-of-json\"");
|
||||
|
||||
return strBuf.toString();
|
||||
System.out.println(jsonBuf.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user