public List<LedCommandRX51> engine1;
public List<LedCommandRX51> engine2;
- public override bool parse (string line) {
+ public override void parse (string line) throws LedPatternError {
string[] key_value = line.split ("=");
- if (key_value.length != 2) {
- print ("pattern line does not contain '=': %s\n", line);
- return false;
- }
+ if (key_value.length != 2)
+ throw new LedPatternError.INVALID_PATTERN ("pattern line does not contain '=': " + line);
+
+ name = key_value[0];
string[] p = key_value[1].split (";");
- if (p.length != 6) {
- print ("pattern does not contain 6 components: %d\n", p.length);
- return false;
- }
+ if (p.length != 6)
+ throw new LedPatternError.INVALID_PATTERN ("%s does not contain 6 components: %d".printf (name, p.length));
- if (p[4].length > 16*4 || p[5].length > 16*4) {
- print ("pattern too long!\n");
- return false;
- }
+ if (p[4].length > 16*4 || p[5].length > 16*4)
+ throw new LedPatternError.INVALID_PATTERN ("%s engine pattern too long!".printf (name));
+
+ if (p[4].length % 4 != 0 || p[5].length % 4 != 0)
+ throw new LedPatternError.INVALID_PATTERN ("%s engine pattern not an even number of bytes!".printf (name));
- name = key_value[0];
priority = p[0].to_int ();
screen_on = p[1].to_int ();
timeout = p[2].to_int ();
}
on_changed ();
- return true;
}
private void parse_led_map (string led_map, out LedColor color1, out LedColor color2) {
public void on_changed () {
bool unresolved = calculate_timing ();
- if (unresolved)
+ if (unresolved) {
unresolved = calculate_timing ();
- if (unresolved)
+ }
+ if (unresolved) {
Hildon.Banner.show_information (null, null, "Timing unresolved");
+ }
changed ();
}