Author: remi
Date: 2008-07-30 11:29:05 +0200 (Wed, 30 Jul 2008)
New Revision: 1422
Modified:
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
Log:
* added the functions to translate the command from the *.att format to the
macro format.
Modified:
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
===================================================================
---
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
2008-07-30 09:27:43 UTC (rev 1421)
+++
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTBlockParams.java
2008-07-30 09:29:05 UTC (rev 1422)
@@ -2,10 +2,19 @@
import java.util.Hashtable;
+/**
+ *
+ * @author Remi Jocaille
+ *
+ */
public class ATTBlockParams
{
+ /*
-------------------------------------------------------------------------
+ * Led commands
+ *
---------------------------------------------------------------------- */
+
/*
- * Led commands
+ * Leds blink
*/
public static Hashtable<String,Object> LEDS_BLINK_CANVAS = new
Hashtable<String,Object>();
static {
@@ -13,36 +22,115 @@
LEDS_BLINK_CANVAS.put("count", 1.0);
LEDS_BLINK_CANVAS.put("speed", 1);
}
+ private static String[] ledsBlinkTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ double duration = (Double)struct.get("speed") * 0.008;
+ String cmd = String.format("TUX_CMD:LED:BLINK:LED_BOTH,%d,%g",
+ struct.get("count"), duration);
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Leds on
+ */
public static Hashtable<String,Object> LEDS_ON_CANVAS = new
Hashtable<String,Object>();
static {
LEDS_ON_CANVAS.put("cmd", "leds_on");
LEDS_ON_CANVAS.put("duration", 0.0);
}
+ private static String[] ledsOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:ON:LED_BOTH,1.0";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Ledl on
+ */
public static Hashtable<String,Object> LEDL_ON_CANVAS = new
Hashtable<String,Object>();
static {
LEDL_ON_CANVAS.put("cmd", "ledl_on");
LEDL_ON_CANVAS.put("duration", 0.0);
}
+ private static String[] ledlOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:ON:LED_LEFT,1.0";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Ledr on
+ */
public static Hashtable<String,Object> LEDR_ON_CANVAS = new
Hashtable<String,Object>();
static {
LEDR_ON_CANVAS.put("cmd", "ledr_on");
LEDR_ON_CANVAS.put("duration", 0.0);
}
+ private static String[] ledrOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:ON:LED_RIGHT,1.0";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Leds off
+ */
public static Hashtable<String,Object> LEDS_OFF_CANVAS = new
Hashtable<String,Object>();
static {
LEDS_OFF_CANVAS.put("cmd", "leds_off");
LEDS_OFF_CANVAS.put("duration", 0.0);
}
+ private static String[] ledsOffTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:OFF:LED_BOTH";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Ledl off
+ */
public static Hashtable<String,Object> LEDL_OFF_CANVAS = new
Hashtable<String,Object>();
static {
LEDL_OFF_CANVAS.put("cmd", "ledl_off");
LEDL_OFF_CANVAS.put("duration", 0.0);
}
+ private static String[] ledlOffTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:OFF:LED_LEFT";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Ledr off
+ */
public static Hashtable<String,Object> LEDR_OFF_CANVAS = new
Hashtable<String,Object>();
static {
LEDR_OFF_CANVAS.put("cmd", "ledr_off");
LEDR_OFF_CANVAS.put("duration", 0.0);
}
+ private static String[] ledrOffTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:LED:OFF:LED_RIGHT";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Leds command types
+ */
public static String[] LEDS_CMD_TYPES = {
"leds_blink",
"leds_on",
@@ -52,8 +140,13 @@
"ledl_off",
"ledr_off"
};
+
+ /*
-------------------------------------------------------------------------
+ * Mouth and eyes commands
+ *
---------------------------------------------------------------------- */
+
/*
- * Mouth and eyes commands
+ * Mouth on
*/
public static Hashtable<String,Object> MOUTH_ON_CANVAS = new
Hashtable<String,Object>();
static {
@@ -61,32 +154,100 @@
MOUTH_ON_CANVAS.put("duration", 0.0);
MOUTH_ON_CANVAS.put("count", 2);
}
+ private static String[] mouthOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:MOUTH:ON:%d,NDEF",
+ struct.get("count"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Mouth open
+ */
public static Hashtable<String,Object> MOUTH_OPEN_CANVAS = new
Hashtable<String,Object>();
static {
MOUTH_OPEN_CANVAS.put("cmd", "mouth_open");
MOUTH_OPEN_CANVAS.put("duration", 0.0);
}
+ private static String[] mouthOpenTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:MOUTH:OPEN";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Mouth close
+ */
public static Hashtable<String,Object> MOUTH_CLOSE_CANVAS = new
Hashtable<String,Object>();
static {
MOUTH_CLOSE_CANVAS.put("cmd", "mouth_close");
MOUTH_CLOSE_CANVAS.put("duration", 0.0);
}
+ private static String[] mouthCloseTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:MOUTH:CLOSE";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Eyes on
+ */
public static Hashtable<String,Object> EYES_ON_CANVAS = new
Hashtable<String,Object>();
static {
EYES_ON_CANVAS.put("cmd", "eyes_on");
EYES_ON_CANVAS.put("duration", 0.0);
EYES_ON_CANVAS.put("count", 2);
}
+ private static String[] eyesOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:EYES:ON:%d,NDEF",
+ struct.get("count"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Eyes open
+ */
public static Hashtable<String,Object> EYES_OPEN_CANVAS = new
Hashtable<String,Object>();
static {
EYES_OPEN_CANVAS.put("cmd", "eyes_open");
EYES_OPEN_CANVAS.put("duration", 0.0);
}
+ private static String[] eyesOpenTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:EYES:OPEN";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Eyes close
+ */
public static Hashtable<String,Object> EYES_CLOSE_CANVAS = new
Hashtable<String,Object>();
static {
EYES_CLOSE_CANVAS.put("cmd", "eyes_close");
EYES_CLOSE_CANVAS.put("duration", 0.0);
}
+ private static String[] eyesCloseTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:EYES:CLOSE";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Eyes and mouth command types
+ */
public static String[] EYESMOUTH_CMD_TYPES = {
"mouth_on",
"mouth_open",
@@ -95,8 +256,13 @@
"eyes_open",
"eyes_close"
};
+
+ /*
-------------------------------------------------------------------------
+ * Spinning commands
+ *
---------------------------------------------------------------------- */
+
/*
- * Spinning commands
+ * Spinning left
*/
public static Hashtable<String,Object> SPINNING_LEFT_CANVAS = new
Hashtable<String,Object>();
static {
@@ -105,6 +271,18 @@
SPINNING_LEFT_CANVAS.put("count", 2);
SPINNING_LEFT_CANVAS.put("speed", 5);
}
+ private static String[] spinlOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:SPINNING:LEFT_ON:%d",
+ struct.get("count"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Spinning right
+ */
public static Hashtable<String,Object> SPINNING_RIGHT_CANVAS = new
Hashtable<String,Object>();
static {
SPINNING_RIGHT_CANVAS.put("cmd", "spinr_on");
@@ -112,12 +290,29 @@
SPINNING_RIGHT_CANVAS.put("count", 2);
SPINNING_RIGHT_CANVAS.put("speed", 5);
}
+ private static String[] spinrOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:SPINNING:RIGHT_ON:%d",
+ struct.get("count"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Spinning command types
+ */
public static String[] SPINNING_CMD_TYPES = {
"spinl_on",
"spinr_on"
};
+
+ /*
-------------------------------------------------------------------------
+ * Flippers commands
+ *
---------------------------------------------------------------------- */
+
/*
- * Flippers commands
+ * Flippers on
*/
public static Hashtable<String,Object> FLIPPERS_ON_CANVAS = new
Hashtable<String,Object>();
static {
@@ -125,23 +320,62 @@
FLIPPERS_ON_CANVAS.put("duration", 0.0);
FLIPPERS_ON_CANVAS.put("count", 2);
}
+ private static String[] flippersOnTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:FLIPPERS:ON:%d,NDEF",
+ struct.get("count"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Flippers up
+ */
public static Hashtable<String,Object> FLIPPERS_UP_CANVAS = new
Hashtable<String,Object>();
static {
FLIPPERS_UP_CANVAS.put("cmd", "wings_up");
FLIPPERS_UP_CANVAS.put("duration", 0.0);
}
+ private static String[] flippersUpTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:FLIPPERS:UP";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Flippers down
+ */
public static Hashtable<String,Object> FLIPPERS_DOWN_CANVAS = new
Hashtable<String,Object>();
static {
FLIPPERS_DOWN_CANVAS.put("cmd", "wings_down");
FLIPPERS_DOWN_CANVAS.put("duration", 0.0);
}
+ private static String[] flippersDownTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "TUX_CMD:FLIPPERS:DOWN";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Flippers command types
+ */
public static String[] FLIPPERS_CMD_TYPES = {
"wings_on",
"wings_up",
"wings_down"
};
+
+ /*
-------------------------------------------------------------------------
+ * Wave and flash commands
+ *
---------------------------------------------------------------------- */
+
/*
- * Wave and flash commands
+ * Play flash
*/
public static Hashtable<String,Object> PLAY_FLASH_CANVAS = new
Hashtable<String,Object>();
static {
@@ -149,19 +383,57 @@
PLAY_FLASH_CANVAS.put("duration", 0.0);
PLAY_FLASH_CANVAS.put("index", 0);
}
+ private static String[] soundPlayTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = String.format("TUX_CMD:SOUND_FLASH:PLAY:%d,100.0",
+ struct.get("index"));
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Play wave
+ */
public static Hashtable<String,Object> PLAY_WAVE_CANVAS = new
Hashtable<String,Object>();
static {
PLAY_WAVE_CANVAS.put("cmd", "wav_play");
PLAY_WAVE_CANVAS.put("duration", 0.0);
PLAY_WAVE_CANVAS.put("wav_name", "none");
}
+ private static String[] wavPlayTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[1];
+ String cmd = "";
+ result[0] = cmd;
+ return result;
+ }
+
+ /*
+ * Wave and flash command types
+ */
public static String[] WAVSOUND_CMD_TYPES = {
"sound_play",
"wav_play"
};
+
+ /*
-------------------------------------------------------------------------
+ * TTS commands
+ *
---------------------------------------------------------------------- */
+
/*
- * TTS commands
+ * Locutor name list
*/
+ private static String[] LOCUTOR_NAMES_LIST = {
+ "Bruno8k", "Julie8k", "Ryan8k",
"Heather8k","Sofie8k",
+ "Klaus8k", "Sarah8k", "Graham8k","Lucy8k",
"Salma8k",
+ "Mette8k", "Maria8k", "Chiara8k", "Femke8k",
"Kari8k",
+ "Celia8k", "Erik8k", "Emma8k"
+ };
+
+ /*
+ * TTS play
+ */
public static Hashtable<String,Object> PLAY_TTS_CANVAS = new
Hashtable<String,Object>();
static {
PLAY_TTS_CANVAS.put("cmd", "tts_play");
@@ -170,7 +442,123 @@
PLAY_TTS_CANVAS.put("speaker", 3);
PLAY_TTS_CANVAS.put("pitch", 100);
}
+ private static String[] ttsPlayTmc(Hashtable<String,Object> struct)
+ {
+ String[] result = new String[3];
+ String locutor =
LOCUTOR_NAMES_LIST[(Integer)struct.get("speaker")-1];
+ String cmd = String.format("OSL_CMD:TTS:SET_LOCUTOR:%s",
locutor);
+ result[0] = cmd;
+ cmd = String.format("OSL_CMD:TTS:SET_PITCH:%d",
struct.get("pitch"));
+ result[1] = cmd;
+ String text = (String)struct.get("text");
+ text = text.replace("\n", " ");
+ cmd = String.format("OSL_CMD:TTS:SPEAK:%s", text);
+ result[2] = cmd;
+ return result;
+ }
+
+ /*
+ * TTS command types
+ */
public static String[] TTS_CMD_TYPES = {
"tts_play"
};
+
+ /*
-------------------------------------------------------------------------
+ * ATT command to macro command
+ *
---------------------------------------------------------------------- */
+
+ public String[] attCmdToMacroCmd(Hashtable<String,Object> struct)
+ {
+ String cmd = (String)struct.get("cmd");
+
+ if (cmd.equals("leds_on"))
+ {
+ return ledsOnTmc(struct);
+ }
+ else if (cmd.equals("ledl_on"))
+ {
+ return ledlOnTmc(struct);
+ }
+ else if (cmd.equals("ledr_on"))
+ {
+ return ledrOnTmc(struct);
+ }
+ else if (cmd.equals("leds_off"))
+ {
+ return ledsOffTmc(struct);
+ }
+ else if (cmd.equals("ledl_off"))
+ {
+ return ledlOffTmc(struct);
+ }
+ else if (cmd.equals("ledr_off"))
+ {
+ return ledrOffTmc(struct);
+ }
+ else if (cmd.equals("leds_blink"))
+ {
+ return ledsBlinkTmc(struct);
+ }
+ else if (cmd.equals("mouth_on"))
+ {
+ return mouthOnTmc(struct);
+ }
+ else if (cmd.equals("mouth_open"))
+ {
+ return mouthOpenTmc(struct);
+ }
+ else if (cmd.equals("mouth_close"))
+ {
+ return mouthCloseTmc(struct);
+ }
+ else if (cmd.equals("eyes_on"))
+ {
+ return eyesOnTmc(struct);
+ }
+ else if (cmd.equals("eyes_open"))
+ {
+ return eyesOpenTmc(struct);
+ }
+ else if (cmd.equals("eyes_close"))
+ {
+ return eyesCloseTmc(struct);
+ }
+ else if (cmd.equals("sound_play"))
+ {
+ return soundPlayTmc(struct);
+ }
+ else if (cmd.equals("wav_play"))
+ {
+ return wavPlayTmc(struct);
+ }
+ else if (cmd.equals("spinl_on"))
+ {
+ return spinlOnTmc(struct);
+ }
+ else if (cmd.equals("spinr_on"))
+ {
+ return spinrOnTmc(struct);
+ }
+ else if (cmd.equals("tts_play"))
+ {
+ return ttsPlayTmc(struct);
+ }
+ else if (cmd.equals("wings_on"))
+ {
+ return flippersOnTmc(struct);
+ }
+ else if (cmd.equals("wings_up"))
+ {
+ return flippersUpTmc(struct);
+ }
+ else if (cmd.equals("wings_down"))
+ {
+ return flippersDownTmc(struct);
+ }
+ else
+ {
+ return null;
+ }
+ }
}
Modified:
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
===================================================================
---
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
2008-07-30 09:27:43 UTC (rev 1421)
+++
software_suite_v2/software/tools/attitunesStudio/trunk/src/com/tuxisalive/attitunes/format/ATTFormatReadWrite.java
2008-07-30 09:29:05 UTC (rev 1422)
@@ -162,7 +162,6 @@
attWorkPath = destination;
xmlPath = attWorkPath + fwext + File.separator + "scene.xml";
wavsPath = attWorkPath + fwext + File.separator + "wavs" +
File.separator;
- System.out.println(xmlPath);
return true;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn