001 /*
002 * Copyright (C) 2006-2010 Enrique Lara (k957@68k.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package net.sf.jmorse.ant;
018
019 import net.sf.jmorse.AudioMorseWriter;
020
021 import org.apache.tools.ant.Task;
022
023 /**
024 * @author <a href="mailto:k957@68k.org">Enrique Lara</a>
025 *
026 * <?xml version="1.0"?>
027 * <project name="jMorse sample usage of ant task" default="morse:test" basedir=".">
028 * <taskdef name="morse" classname="net.sf.jmorse.ant.MorseTask" />
029 *
030 * <target name="morse:test">
031 * <morse message="CQ DE JMORSE" wpm="15" tone="450" volume="5" />
032 * </target>
033 * </project>
034 *
035 */
036 public class MorseTask extends Task {
037 AudioMorseWriter morse = new AudioMorseWriter();
038
039 // --------------------------------------------------- Instance Variables
040 private int volume = 5;
041 private int tone = 370;
042 private int wpm = 22;
043 private String message = "";
044
045 // --------------------------------------------------- Properties
046 public void setVolume(int volume) {
047 this.volume = volume;
048 }
049
050 public void setTone(int tone) {
051 this.tone = tone;
052 }
053
054 public void setWpm(int wpm) {
055 this.wpm = wpm;
056 }
057
058 public void setMessage(String message) {
059 this.message = message;
060 }
061
062 public void execute() {
063 morse.setWpm(wpm);
064 morse.setVolume(volume);
065 morse.setTone(tone);
066 morse.write(message);
067 }
068 }