public void Start() { positivePins = new List <int>() { 11, 10, 9, 6, 5, 3 }; negativePins = new List <int>() { 16, 15, 14, 12, 8, 2 }; valuesOFF = new List <string>() { "LOW", "LOW", "LOW", "LOW", "LOW", "LOW" }; index = new List <int>() { 9 }; middle = new List <int>() { 6 }; thumb = new List <int>() { 10 }; pinky = new List <int>() { 3 }; ring = new List <int>() { 5 }; palm = new List <int>() { 11 }; glove = new HapticsGlove.HapticsGlove(); Debug.Log("Haptics Glove Output"); foreach (var portName in glove.GetPortNames()) { Debug.Log(portName); } Debug.Log(glove.GetPortNames()); glove.OpenPort("COM25", 57600); System.Threading.Thread.Sleep(2000); glove.InitializeMotor(positivePins); glove.InitializeMotor(negativePins); glove.ActivateMotor(negativePins, valuesOFF); glove.ActivateMotor(negativePins, valuesOFF); Debug.Log("Ports Open"); }
static void Main(string[] args) { int[] positivePins = { 10, 9, 6, 5, 3 }; int[] negativePins = { 15, 14, 12, 8, 2 }; string[] negativeInit = { "LOW", "LOW", "LOW", "LOW", "LOW" }; string[] valuesON = { "HIGH", "HIGH", "HIGH", "HIGH", "HIGH" }; var cantidadMotores = 5; var numeroPruebas = 3; HapticsGlove.HapticsGlove glove = new HapticsGlove.HapticsGlove(); foreach (string port in glove.GetPortNames()) { Console.WriteLine(port); } glove.OpenPort("COM3", 38400); glove.InitializeMotor(positivePins); glove.InitializeMotor(negativePins); glove.ActivateMotor(negativePins, negativeInit); glove.ActivateMotor(negativePins, negativeInit); var fecha = DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"); for (var i = 0; i < cantidadMotores; i++) { var indice = i + 1; var nombreArchivoDigital = "prueba" + fecha + "-" + indice + "Motor-Digital.txt"; Console.WriteLine(nombreArchivoDigital); StreamWriter writerDigital = File.CreateText(nombreArchivoDigital); writerDigital.WriteLine("TiempoGeneracionYEnvioMensaje,TiempoActivacionActuadores,TiempoTotal"); int[] pinesPruebaDigital = new int[i + 1]; string[] valuesONPruebaDigital = new string[i + 1]; string[] valuesOFFPruebaDigital = new string[i + 1]; for (var j = 0; j < indice; j++) { pinesPruebaDigital[j] = positivePins[j]; valuesONPruebaDigital[j] = "HIGH"; valuesOFFPruebaDigital[j] = "LOW"; } for (var k = 0; k < numeroPruebas; k++) { var watch = Stopwatch.StartNew(); glove.ActivateMotorTimeTest(pinesPruebaDigital, valuesONPruebaDigital); watch.Stop(); var tiempoMensaje = watch.ElapsedTicks * 1000000 / Stopwatch.Frequency; long tiempoActivacion = Convert.ToInt64(glove.ReadLine()); var tiempoTotal = tiempoMensaje + tiempoActivacion; Console.WriteLine(tiempoMensaje); Console.WriteLine(tiempoActivacion); Console.WriteLine(tiempoTotal); writerDigital.WriteLine(tiempoMensaje + "," + tiempoActivacion + "," + tiempoTotal); Thread.Sleep(200); glove.ActivateMotor(pinesPruebaDigital, valuesOFFPruebaDigital); Thread.Sleep(500); } writerDigital.Close(); var nombreArchivoAnalogo = "prueba" + fecha + "-" + indice + "Motor-Analogo.txt"; Console.WriteLine(nombreArchivoAnalogo); StreamWriter writerAnalogo = File.CreateText(nombreArchivoAnalogo); writerAnalogo.WriteLine("TiempoGeneracionYEnvioMensaje,TiempoActivacionActuadores,TiempoTotal"); int[] pinesPruebaAnalogo = new int[i + 1]; string[] valuesONPruebaAnalogo = new string[i + 1]; string[] valuesOFFPruebaAnalogo = new string[i + 1]; for (var j = 0; j < indice; j++) { pinesPruebaAnalogo[j] = positivePins[j]; valuesONPruebaAnalogo[j] = "255"; valuesOFFPruebaAnalogo[j] = "0"; } for (var k = 0; k < numeroPruebas; k++) { var watch = Stopwatch.StartNew(); glove.ActivateMotorTimeTest(pinesPruebaAnalogo, valuesONPruebaAnalogo); watch.Stop(); var tiempoMensaje = watch.ElapsedTicks * 1000000 / Stopwatch.Frequency; long tiempoActivacion = Convert.ToInt64(glove.ReadLine()); var tiempoTotal = tiempoMensaje + tiempoActivacion; Console.WriteLine(tiempoMensaje); Console.WriteLine(tiempoActivacion); Console.WriteLine(tiempoTotal); writerAnalogo.WriteLine(tiempoMensaje + "," + tiempoActivacion + "," + tiempoTotal); Thread.Sleep(200); glove.ActivateMotor(pinesPruebaAnalogo, valuesOFFPruebaAnalogo); Thread.Sleep(500); } writerAnalogo.Close(); } }
static void Main(string[] args) { int[] positivePins = { 10, 9, 6, 5, 3 }; int[] negativePins = { 15, 14, 12, 8, 2 }; string[] negativeInit = { "LOW", "LOW", "LOW", "LOW", "LOW" }; string[] valuesON = { "HIGH", "HIGH", "HIGH", "HIGH", "HIGH" }; var cantidadMotores = 5; var numeroPruebas = 3; HapticsGlove.HapticsGlove glove = new HapticsGlove.HapticsGlove(); foreach (string port in glove.GetPortNames()) { Console.WriteLine(port); } glove.OpenPort("COM3", 38400); glove.InitializeMotor(positivePins); glove.InitializeMotor(negativePins); glove.ActivateMotor(negativePins, negativeInit); glove.ActivateMotor(negativePins, negativeInit); var fecha = DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss"); for (var i = 0; i < cantidadMotores; i++) { var indice = i + 1; var nombreArchivoDigital = "prueba" +fecha +"-"+ indice + "Motor-Digital.txt"; Console.WriteLine(nombreArchivoDigital); StreamWriter writerDigital = File.CreateText(nombreArchivoDigital); writerDigital.WriteLine("TiempoGeneracionYEnvioMensaje,TiempoActivacionActuadores,TiempoTotal"); int[] pinesPruebaDigital = new int[i + 1]; string[] valuesONPruebaDigital = new string[i + 1]; string[] valuesOFFPruebaDigital = new string[i + 1]; for (var j = 0; j < indice ; j++ ) { pinesPruebaDigital[j] = positivePins[j]; valuesONPruebaDigital[j] = "HIGH"; valuesOFFPruebaDigital[j] = "LOW"; } for (var k = 0; k < numeroPruebas; k++) { var watch = Stopwatch.StartNew(); glove.ActivateMotorTimeTest(pinesPruebaDigital, valuesONPruebaDigital); watch.Stop(); var tiempoMensaje = watch.ElapsedTicks * 1000000 / Stopwatch.Frequency; long tiempoActivacion = Convert.ToInt64(glove.ReadLine()); var tiempoTotal = tiempoMensaje + tiempoActivacion; Console.WriteLine(tiempoMensaje); Console.WriteLine(tiempoActivacion); Console.WriteLine(tiempoTotal); writerDigital.WriteLine(tiempoMensaje + "," + tiempoActivacion + "," +tiempoTotal); Thread.Sleep(200); glove.ActivateMotor(pinesPruebaDigital, valuesOFFPruebaDigital); Thread.Sleep(500); } writerDigital.Close(); var nombreArchivoAnalogo = "prueba" + fecha + "-" + indice + "Motor-Analogo.txt"; Console.WriteLine(nombreArchivoAnalogo); StreamWriter writerAnalogo = File.CreateText(nombreArchivoAnalogo); writerAnalogo.WriteLine("TiempoGeneracionYEnvioMensaje,TiempoActivacionActuadores,TiempoTotal"); int[] pinesPruebaAnalogo = new int[i + 1]; string[] valuesONPruebaAnalogo = new string[i + 1]; string[] valuesOFFPruebaAnalogo = new string[i + 1]; for (var j = 0; j < indice; j++) { pinesPruebaAnalogo[j] = positivePins[j]; valuesONPruebaAnalogo[j] = "255"; valuesOFFPruebaAnalogo[j] = "0"; } for (var k = 0; k < numeroPruebas; k++) { var watch = Stopwatch.StartNew(); glove.ActivateMotorTimeTest(pinesPruebaAnalogo, valuesONPruebaAnalogo); watch.Stop(); var tiempoMensaje = watch.ElapsedTicks * 1000000 / Stopwatch.Frequency; long tiempoActivacion = Convert.ToInt64(glove.ReadLine()); var tiempoTotal = tiempoMensaje + tiempoActivacion; Console.WriteLine(tiempoMensaje); Console.WriteLine(tiempoActivacion); Console.WriteLine(tiempoTotal); writerAnalogo.WriteLine(tiempoMensaje + "," + tiempoActivacion + "," + tiempoTotal); Thread.Sleep(200); glove.ActivateMotor(pinesPruebaAnalogo, valuesOFFPruebaAnalogo); Thread.Sleep(500); } writerAnalogo.Close(); } }