<commit_before>package org.myrobotlab.service;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.myrobotlab.codec.serial.ArduinoMsgCodec;
import org.myrobotlab.codec.serial.Codec;
import org.myrobotlab.framework.Service;
import org.myrobotlab.logging.Level;
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.LoggingFactory;
import org.myrobotlab.service.Arduino.Sketch;
import org.slf4j.Logger;

/**
 * 
 * @author GroG
 *
 */
public class ArduinoTest {

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

	static Arduino arduino = null;
	static Serial serial = null;
	static TestCatcher catcher = null;

	static VirtualDevice virtual = null;
	static Python logic = null;
	static String vport = "vport";
	static Serial uart = null;

	int servoPin = 9;

	static ArduinoMsgCodec codec = new ArduinoMsgCodec();

	// FIXME - test for re-entrant !!!!
	// FIXME - single switch for virtual versus "real" hardware

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		LoggingFactory.getInstance().configure();
		LoggingFactory.getInstance().setLevel(Level.INFO);

		log.info("setUpBeforeClass");

		Runtime.start("gui", "GUIService");
		Runtime.start("webgui", "WebGUI");
		
		arduino = (Arduino) Runtime.start("arduino", "Arduino");
		serial = arduino.getSerial();

		catcher = (TestCatcher) Runtime.start("catcher", "TestCatcher");
		virtual = (VirtualDevice) Runtime.start("virtual", "VirtualDevice");
		virtual.createVirtualArduino(vport);
		logic = virtual.getLogic();

		catcher.subscribe(arduino.getName(), "publishError");

		uart = virtual.getUART();
		uart.setCodec("arduino");
		Codec codec = uart.getRXCodec();
		codec.setTimeout(1000);
		uart.setTimeout(100); // don't want to hang when decoding results...

		arduino.setBoard(Arduino.BOARD_TYPE_ATMEGA2560);
		arduino.connect(vport);

		Service.sleep(500);
		// nice to be able to check messages
		// uart.addByteListener(catcher);
		log.info("here");

	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {<commit_msg>gui & webgui removed from arduino test<commit_after>package org.myrobotlab.service;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.myrobotlab.codec.serial.ArduinoMsgCodec;
import org.myrobotlab.codec.serial.Codec;
import org.myrobotlab.framework.Service;
import org.myrobotlab.logging.Level;
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.LoggingFactory;
import org.myrobotlab.service.Arduino.Sketch;
import org.slf4j.Logger;

/**
 * 
 * @author GroG
 *
 */
public class ArduinoTest {

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

	static Arduino arduino = null;
	static Serial serial = null;
	static TestCatcher catcher = null;

	static VirtualDevice virtual = null;
	static Python logic = null;
	static String vport = "vport";
	static Serial uart = null;

	int servoPin = 9;

	static ArduinoMsgCodec codec = new ArduinoMsgCodec();

	// FIXME - test for re-entrant !!!!
	// FIXME - single switch for virtual versus "real" hardware

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		LoggingFactory.getInstance().configure();
		LoggingFactory.getInstance().setLevel(Level.INFO);

		log.info("setUpBeforeClass");

		//Runtime.start("gui", "GUIService");
		//Runtime.start("webgui", "WebGUI");
		
		arduino = (Arduino) Runtime.start("arduino", "Arduino");
		serial = arduino.getSerial();

		catcher = (TestCatcher) Runtime.start("catcher", "TestCatcher");
		virtual = (VirtualDevice) Runtime.start("virtual", "VirtualDevice");
		virtual.createVirtualArduino(vport);
		logic = virtual.getLogic();

		catcher.subscribe(arduino.getName(), "publishError");

		uart = virtual.getUART();
		uart.setCodec("arduino");
		Codec codec = uart.getRXCodec();
		codec.setTimeout(1000);
		uart.setTimeout(100); // don't want to hang when decoding results...

		arduino.setBoard(Arduino.BOARD_TYPE_ATMEGA2560);
		arduino.connect(vport);

		Service.sleep(500);
		// nice to be able to check messages
		// uart.addByteListener(catcher);
		log.info("here");

	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
{'fraction_non_alphanumeric': 0.1226158038147139, 'fraction_numerical': 0.00670718926849717, 'mean_word_length': 5.01765447667087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1877843', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1500, 'n_words': 341}