/// <summary> /// 各モードに応じて、クローズ /// </summary> public void Close() { if (null != urgLog) { urgLog.CloseFile(); urgLog = null; } if (null != stream) { try { write(stream, SCIP_Writer.QT()); // stop measurement mode read_line(stream); // ignore echo back stream.Close(); urg.Close(); stream = null; } catch { } } }
public static void TestMode() { const int GET_NUM = 10; const int start_step = 0; const int end_step = 1080; try { string ip_address = LRF_IP_ADDR; int port_number = LRF_PORT; //get_connect_information(out ip_address, out port_number); TcpClient urg = new TcpClient(); urg.Connect(ip_address, port_number); NetworkStream stream = urg.GetStream(); write(stream, SCIP_Writer.SCIP2()); read_line(stream); // ignore echo back write(stream, SCIP_Writer.MD(start_step, end_step)); read_line(stream); // ignore echo back List <double> distances = new List <double>(); long time_stamp = 0; for (int i = 0; i < GET_NUM; ++i) { string receive_data = read_line(stream); if (!SCIP_Reader.MD(receive_data, ref time_stamp, ref distances)) { Console.WriteLine(receive_data); break; } if (distances.Count == 0) { Console.WriteLine(receive_data); continue; } // show distance data Console.WriteLine("time stamp: " + time_stamp.ToString() + " distance[100] : " + distances[100].ToString()); } write(stream, SCIP_Writer.QT()); // stop measurement mode read_line(stream); // ignore echo back stream.Close(); urg.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } finally { Console.WriteLine("Press any key."); //Console.ReadKey(); } }