public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.DEBUG); try { // FIXME !!! - don't use Adafruit's library - do your own stepper control through "pure" // MRLComm.ino AdafruitMotorShield fruity = (AdafruitMotorShield) Runtime.createAndStart("fruity", "AdafruitMotorShield"); Runtime.createAndStart("gui01", "GUIService"); fruity.connect("COM3"); Motor motor1 = fruity.createDCMotor(4); motor1.move(0.4f); // create a 200 step stepper on adafruitsheild port 1 Stepper stepper1 = fruity.createStepper(200, 1); // FIXME - needs to be cleaned up - tear down fruity.releaseStepper(stepper1.getName()); // Runtime.createAndStart("python", "Python"); } catch (Exception e) { Logging.logError(e); } }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.DEBUG); DiscoveryThread service = DiscoveryThread.getInstance(); // refactor - this is stupid Thread discovery = new Thread(service); discovery.start(); ArrayList<InetAddress> clients = service.ping(); for (int i = 0; i < clients.size(); ++i) { log.info(String.format("client %s", clients.get(i).toString())); } }
public static void main(String[] args) throws InterruptedException { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.DEBUG); Servo right = new Servo("servo01"); right.map(5, 180, 5, 180); log.info("{}", right.calc(1)); log.info("{}", right.calc(3)); right.map(180, 0, 0, 180); log.info("{}", right.calc(3)); right.map(0, 180, 5, 178); log.info("{}", right.calc(0)); right.startService(); right.test(); // FIXME - routing of servo.attach("arduino", 3); Arduino arduino = (Arduino) Runtime.createAndStart("arduino", "Arduino"); arduino.connect("COM4"); arduino.servoAttach(right.getName(), 13); right.test(); Runtime.createAndStart("gui", "GUIService"); // right.attach(serviceName) /* * Servo left = new Servo("left"); left.startService(); * * //Servo neck = new Servo("neck"); //neck.startService(); * * for (int i = 0; i < 30; ++i) { * * right.attach("arduino", 2); left.attach("arduino", 3); * * right.moveTo(120); // 70 back left.moveTo(70); // 118 back * * Thread.sleep(10000); * * right.moveTo(90); left.moveTo(90); * * //right.detach(); //left.detach(); } */ }
/** * to begin logging call this function Log must not begin before the GUIService has finished * drawing. For some reason, if log entries are written to a JScrollPane before the gui has * completed the whole gui will tank * * <p>by default logging is off */ public void startLogging() { PatternLayout layout = new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"); setLayout(layout); setName("ConsoleGUI"); LoggingFactory.getInstance().addAppender(this); logging = true; }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.INFO); /* try { RemoteStreamInput template = (RemoteStreamInput) Runtime.start( "template", "_TemplateService"); template.test(); Runtime.start("gui", "GUIService"); } catch (Exception e) { Logging.logError(e); } */ }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.INFO); CleverBot cleverbot = new CleverBot("cleverbot"); cleverbot.startService(); log.info(cleverbot.chat("Hi")); log.info(cleverbot.chat("How are you?")); log.info("here"); /* * GUIService gui = new GUIService("gui"); gui.startService(); * */ }
public static void main(String args[]) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.INFO); JFrame frame = new JFrame(); Container container = frame.getContentPane(); final MemoryWidget nodeTree = new MemoryWidget(null); JButton addButton = new JButton("add node"); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { nodeTree.putNode(); } }); JButton removeButton = new JButton("remove selected node"); removeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { nodeTree.removeSelectedNode(); } }); JButton addNodeButton = new JButton("addNode node"); addNodeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { nodeTree.put("root", new Node("fore")); } }); JPanel inputPanel = new JPanel(); inputPanel.add(addButton); inputPanel.add(removeButton); inputPanel.add(addNodeButton); container.add(inputPanel, BorderLayout.NORTH); container.add(nodeTree.getDisplay(), BorderLayout.CENTER); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setVisible(true); nodeTree.put("root", new Node("foreground")); nodeTree.put("root", new Node("background")); nodeTree.put("root.foreground", new Node("objects")); nodeTree.put("root.foreground.objects", new Node("known")); nodeTree.put("root.foreground.objects", new Node("unknown")); }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.DEBUG); try { // BasicConfigurator. log.info("hello"); ThingSpeak thingSpeak = new ThingSpeak("thingSpeak"); thingSpeak.update(33); thingSpeak.startService(); /* * GUIService gui = new GUIService("gui"); gui.startService(); */ } catch (Exception e) { Logging.logError(e); } }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.WARN); try { LIDAR template = new LIDAR("Lidar"); template.startService(); // LIDAR lidar01 = (LIDAR) Runtime.createAndStart("lidar01", "LIDAR"); // creates and runs a serial service // lidar01.connect("dev/lidar01"); // send a command // this sets the mode to a spread of 180 degrees with readings every // 0.5 // degrees // lidar01.setMode(180, 0.5f); // this setMode command catches the reply from the LMS in the // listener // within the // LIDAR service and returns a bool stating if it was successful or // not. // an array of floats holding ranges (after the LDIAR service strips // and // parses the data. // lidar01.singleScan(); Python python = new Python("python"); python.startService(); Runtime.createAndStart("gui", "GUIService"); /* * GUIService gui = new GUIService("gui"); gui.startService(); * */ } catch (Exception e) { Logging.logException(e); } }
public static void main(String[] args) { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.INFO); try { MyoThalmic myo = (MyoThalmic) Runtime.start("myo", "MyoThalmic"); myo.test(); Hub hub = new Hub("com.example.hello-myo"); System.out.println("Attempting to find a Myo..."); log.info("Attempting to find a Myo"); Myo myodevice = hub.waitForMyo(10000); if (myodevice == null) { throw new RuntimeException("Unable to find a Myo!"); } System.out.println("Connected to a Myo armband!"); log.info("Connected to a Myo armband"); DataCollector dataCollector = new DataCollector(); hub.addListener(dataCollector); while (true) { hub.run(1000 / 20); // System.out.print(dataCollector); System.out.println("yaw is " + dataCollector.getYaw()); System.out.println("roll is " + dataCollector.getRoll()); System.out.println("pitch is " + dataCollector.getPitch()); Runtime.start("gui", "GUIService"); } } catch (Exception e) { Logging.logError(e); } }
public static void main(String[] args) throws ClassNotFoundException { // Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); Logging logging = LoggingFactory.getInstance(); logging.configure(); logging.setLevel(Level.INFO); // LoggingFactory.getInstance().setLevel(Level.INFO); int test = 35; log.info("{}", test); log.debug("hello"); log.trace("trace"); log.error("error"); log.info("info"); PID pid = new PID("pid"); pid.startService(); pid.setPID(2.0, 5.0, 1.0); pid.setControllerDirection(DIRECTION_DIRECT); pid.setMode(MODE_AUTOMATIC); pid.setOutputRange(0, 255); pid.setSetpoint(100); pid.setSampleTime(40); GUIService gui = new GUIService("gui"); gui.startService(); for (int i = 0; i < 200; ++i) { pid.setInput(i); Service.sleep(30); if (pid.compute()) { log.info(String.format("%d %f", i, pid.getOutput())); } else { log.warn("not ready"); } } }
@Override public void close() { LoggingFactory.getInstance().removeAppender(this); }
public void stopLogging() { LoggingFactory.getInstance().removeAppender(this); logging = false; }
public static void main(String[] args) throws IOException { LoggingFactory.getInstance().configure(); LoggingFactory.getInstance().setLevel(Level.DEBUG); Index<ServiceReservation> reservations = new Index<ServiceReservation>(); reservations.put("RightArm.Bicep", new ServiceReservation("Bicep", "Servo", "a bicep servo")); reservations.put( "RightArm.Shoulder", new ServiceReservation("Shoulder", "Servo", "a shoulder servo")); reservations.put("RightArm.Rotate", new ServiceReservation("Rotate", "Servo", "a servo")); reservations.put( "RightArm.RightHand", new ServiceReservation("RightHand", "InMoovHand", "a servo")); ArrayList<ServiceReservation> ret = reservations.crawlForDataStartingWith("RightArm"); log.info("size {} from query of RightArm", ret.size()); log.info(reservations.toString()); log.info("here"); // reservations.put("arm.database.config", new ServiceReservation("Rotate","Servo","a servo")); /* reservations.put("global.database.qa.server", "Db2udb04"); reservations.put("global.database.qa.port", "50005"); reservations.put("global.database.qa.schema", "TESTDB2"); reservations.put("global.database.qa.userid", "odcad01"); reservations.put("global.database.qa.password", "3dglasez"); reservations.put("global.database.dev.server", "Db2udb03"); reservations.put("global.database.dev.port", "50004"); reservations.put("global.database.dev.schema", "FIM"); reservations.put("global.database.dev.userid", "odcad00"); reservations.put("global.database.dev.password", "3dglases"); */ /* String test = reservations.get("global.database.dev.userid", "zod"); log.info(test); String dbConfigKey = reservations.get("global.database.config"); IndexNode dbConfigNode = reservations.getNode(String.format("global.database.%s",dbConfigKey)); HashMap<String,IndexNode> dbConfig = dbConfigNode.getBranches(); log.info(dbConfig.get("server").getValue().toString()); log.info(dbConfig.get("port").getValue().toString()); log.info(dbConfig.get("schema").getValue().toString()); log.info(dbConfig.get("userid").getValue().toString()); log.info(dbConfig.get("password").getValue().toString()); // reservations.put("global.database.config","qa"); dbConfigKey = reservations.get("global.database.config"); dbConfigNode = reservations.getNode(String.format("global.database.%s",dbConfigKey)); dbConfig = dbConfigNode.getBranches(); log.info(dbConfig.get("server").getValue().toString()); log.info(dbConfig.get("port").getValue().toString()); log.info(dbConfig.get("schema").getValue().toString()); log.info(dbConfig.get("userid").getValue().toString()); log.info(dbConfig.get("password").getValue().toString()); */ HashMap<String, String> hash = new HashMap<String, String>(); ArrayList<String> array = new ArrayList<String>(); hash.put("hash1", "hashValue1"); hash.put("hash2", "hashValue2"); hash.put("hash3", "hashValue3"); array.add("array1"); array.add("array2"); array.add("array3"); array.add("array4"); // config.put("arrayList", array); // config.put("hashMap", hash); File outfile = new File("out.xml"); FileInputStream in = new FileInputStream(outfile); Index config2 = new Index(); // config2.loadFromXML(in); }