package org.myrobotlab.service;

import org.myrobotlab.framework.Service;
import org.myrobotlab.framework.ServiceType;
import org.myrobotlab.logging.Level;
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.LoggingFactory;
import org.slf4j.Logger;

public class Intro extends Service {

  private static final long serialVersionUID = 1L;

  public final static Logger log = LoggerFactory.getLogger(Intro.class);

  public Intro(String n, String id) {
    super(n, id);
  }

  /**
   * This static method returns all the details of the class without it having
   * to be constructed. It has description, categories, dependencies, and peer
   * definitions.
   * 
   * @return ServiceType - returns all the data
   * 
   */
  static public ServiceType getMetaData() {

    ServiceType meta = new ServiceType(Intro.class);
    meta.addDescription("Introduction to MyRobotlab");
    meta.setAvailable(true); 
    meta.addCategory("general");
    return meta;
  }

  public static void main(String[] args) {
    try {

      LoggingFactory.init(Level.INFO);

      Runtime.start("intro", "Intro");
      Runtime.start("servo", "Servo");
      Runtime.start("gui", "SwingGui");

    } catch (Exception e) {
      log.error("main threw", e);
    }
  }
}

@@ -272,16 +272,72 @@
 Logger;%0D
+%0Aimport org.myrobotlab.service.interfaces.ServoControl;%0D
 %0A%0D%0Apubli
@@ -1040,24 +1040,70 @@
 general%22);%0D%0A
+    meta.addPeer(%22servo%22, %22Servo%22, %22servo%22);%0D%0A
     return m
@@ -1408,16 +1408,921 @@
 %0A    %7D%0D%0A
-
   %7D%0D%0A
+%0D%0A  transient Servo servo;%0D%0A%0D%0A  boolean isServoActivated = false;%0D%0A%0D%0A  public boolean isServoActivated() %7B%0D%0A        return isServoActivated;%0D%0A        %7D%0D%0A%0D%0A%0D%0A%0D%0A  public Servo startServo(String port) %7B%0D%0A    return startServo(port, 3);%0D%0A  %7D%0D%0A%0D%0A  public Servo startServo(String port, int pin) %7B%0D%0A  %0D%0A    if (servo == null) %7B%0D%0A      speakBlocking(%22starting servo%22);%0D%0A      isServoActivated = true;%0D%0A%0D%0A      servo = (Servo) startPeer(%22servo%22);%0D%0A%0D%0A      if (port != null) %7B%0D%0A        try %7B%0D%0A          speakBlocking(port);%0D%0A          Arduino controller = (Arduino) startPeer(%22controller%22);%0D%0A          controller.connect(port);%0D%0A          controller.attach(controller, pin);%0D%0A        %7D catch (Exception e) %7B%0D%0A          error(e);%0D%0A        %7D%0D%0A      %7D%0D%0A    %7D%0D%0A    return servo;%0D%0A  %7D%0D%0A%0D%0A  public void stopServo() %7B%0D%0A    speakBlocking(%22stopping servo%22);%0D%0A    releasePeer(%22servo%22);%0D%0A    isServoActivated = false;%0D%0A  %7D%0D%0A%0D%0A
 %7D%0D%0A

add startServo to Intro