<commit_before>package TestDriversAndFactories;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import PacaTraca.PacaTraca;

/**
 * @author <NAME>
 * Very simple class to instantiate a few sensors, store them in a map
 * and then get them from the map and print out their values
 * 
 */
public class PacaTracaTestDriver {

	private HashMap< String, PacaTracaTestHardware > m_sensors = new HashMap< String, PacaTracaTestHardware >( );
	private PacaTracaTestHardwareFactory factory = new PacaTracaTestHardwareFactory();
	public List<String> sensorNames = new ArrayList<String>();
	Random rand = new Random();

	/**
	 * the main module
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PacaTracaTestDriver testCase = new PacaTracaTestDriver( );
		testCase.runTests();
	}
	
	/**
	 * @author <NAME>
	 * Create a factory (a hardware factory in this case)
	 * create some test sensors using the factory
	 * verify the created sensors
	 */
	public void runTests( ) {
		//this.createFaultyTestSensors(factory);
		this.createDummyTestSensors(factory, 5);
		this.randomUpdateDummyTestSensors();
		this.verifySensors(  );
		this.randomUpdateDummyTestSensors();
		this.verifySensors(  );
	}
		
//	/**
//	 * @author <NAME>
//	 * ask the factory to create our sensors (any kind will be fine)
//	 * and then put these sensors into a hash map for safe keeping
//	 */
//	public void createTestSensors( PacaTracaFactory factory ) {
//		m_sensors.put( m_sensor1ID, factory.createPacaTraca( m_sensor1ID ) );
//		m_sensors.put( m_sensor2ID, factory.createPacaTraca( m_sensor2ID ) );
//	}
	
	public void createDummyTestSensors( PacaTracaTestHardwareFactory factory, int numAlpacas ) {
		
		for (int i = 0; i < numAlpacas; i++) {
			AddRandomAlpaca(factory, "Alpaca " + i);
		}
		
	}
	
	public void randomUpdateDummyTestSensors() {
		for(String s : sensorNames){
			float longitude = GetRandomLongitude(s);
			float latitude = GetRandomLatitude(s);
			float speed = GetRandomSpeed(s);
			float course = GetRandomCourse(s);
			int numSatellites = GetRandomNumSatellites(s);
			float heading = GetRandomHeading(s);
			float pitch = GetRandomPitch(s);
			float roll = GetRandomRoll(s);
			float altitude = GetRandomAltitude(s);
			int signalQuality = GetRandomSignalQuality(s);
			float temperature = GetRandomTemperature(s);
			boolean fix = GetRandomFix(s);
			
			updateData(s, longitude, latitude, speed, course, numSatellites, heading, pitch, roll, altitude, signalQuality, temperature, fix);
		}
	}
	
	private float GetRandomLongitude(String ID) {
		return rand.nextInt(359) + rand.nextFloat() - 180;
	}
	
	private float GetRandomLatitude(String ID) {
		return rand.nextInt(179) + rand.nextFloat() - 90;
	}
	
	private float GetRandomSpeed(String ID) {
		return rand.nextInt(15) + rand.nextFloat();
	}
	
	private float GetRandomCourse(String ID) {
		return rand.nextInt(359) + rand.nextFloat();
	}
	
	private int GetRandomNumSatellites(String ID) {<commit_msg>fixed random lat/lng functions so that their returned numbers are always roughly near Orono<commit_after>package TestDriversAndFactories;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import PacaTraca.PacaTraca;

/**
 * @author <NAME>
 * Very simple class to instantiate a few sensors, store them in a map
 * and then get them from the map and print out their values
 * 
 */
public class PacaTracaTestDriver {

	private HashMap< String, PacaTracaTestHardware > m_sensors = new HashMap< String, PacaTracaTestHardware >( );
	private PacaTracaTestHardwareFactory factory = new PacaTracaTestHardwareFactory();
	public List<String> sensorNames = new ArrayList<String>();
	Random rand = new Random();

	/**
	 * the main module
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PacaTracaTestDriver testCase = new PacaTracaTestDriver( );
		testCase.runTests();
	}
	
	/**
	 * @author <NAME>
	 * Create a factory (a hardware factory in this case)
	 * create some test sensors using the factory
	 * verify the created sensors
	 */
	public void runTests( ) {
		//this.createFaultyTestSensors(factory);
		this.createDummyTestSensors(factory, 5);
		this.randomUpdateDummyTestSensors();
		this.verifySensors(  );
		this.randomUpdateDummyTestSensors();
		this.verifySensors(  );
	}
		
//	/**
//	 * @author <NAME>
//	 * ask the factory to create our sensors (any kind will be fine)
//	 * and then put these sensors into a hash map for safe keeping
//	 */
//	public void createTestSensors( PacaTracaFactory factory ) {
//		m_sensors.put( m_sensor1ID, factory.createPacaTraca( m_sensor1ID ) );
//		m_sensors.put( m_sensor2ID, factory.createPacaTraca( m_sensor2ID ) );
//	}
	
	public void createDummyTestSensors( PacaTracaTestHardwareFactory factory, int numAlpacas ) {
		
		for (int i = 0; i < numAlpacas; i++) {
			AddRandomAlpaca(factory, "Alpaca " + i);
		}
		
	}
	
	public void randomUpdateDummyTestSensors() {
		for(String s : sensorNames){
			float longitude = GetRandomLongitude(s);
			float latitude = GetRandomLatitude(s);
			float speed = GetRandomSpeed(s);
			float course = GetRandomCourse(s);
			int numSatellites = GetRandomNumSatellites(s);
			float heading = GetRandomHeading(s);
			float pitch = GetRandomPitch(s);
			float roll = GetRandomRoll(s);
			float altitude = GetRandomAltitude(s);
			int signalQuality = GetRandomSignalQuality(s);
			float temperature = GetRandomTemperature(s);
			boolean fix = GetRandomFix(s);
			
			updateData(s, longitude, latitude, speed, course, numSatellites, heading, pitch, roll, altitude, signalQuality, temperature, fix);
		}
	}
	
	/**
	 * @param ID
	 * @return a random longitude coordinate between -68 and -69, roughly in Orono
	 */
	private float GetRandomLongitude(String ID) {
		int floor = 68;
		int ceiling = 69;
		
		return rand.nextFloat() * (ceiling - floor) + floor;
	}
	
	/**
	 * @param ID
	 * @return a random latitude coordinate between 44 and 45, roughly in Orono
	 */
	private float GetRandomLatitude(String ID) {
		int floor = 44;
		int ceiling = 45;
		
		return rand.nextFloat() * (ceiling - floor) + floor;
	}
	
	private float GetRandomSpeed(String ID) {
		return rand.nextInt(15) + rand.nextFloat();
	}
	
	private float GetRandomCourse(String ID) {
		return rand.nextInt(359) + rand.nextFloat();
	}
	
	private int GetRandomNumSatellites(String ID) {
{'fraction_non_alphanumeric': 0.10569483132157227, 'fraction_numerical': 0.007582791705354379, 'mean_word_length': 4.125297383029342, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, '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': '6955617', 'n_tokens_mistral': 2271, 'n_tokens_neox': 2016, 'n_words': 577}