/// <summary> /// 存储船舶状态信息 /// </summary> /// <param name="fileName"></param> public void StoreShipData(string fileName) { using (FileStream fs = new FileStream(@"D:\" + fileName + ".txt", FileMode.Append)) { //数据保存信息量为: //船号,纬度,经度,X坐标(m),Y坐标,航向角,航迹角,速度,速度等级,时间 //在速度等级后面增加舵角信息,舵角控制输出量信息和速度控制输出量信息 //共13个存储量 string str_data = ShipID.ToString() + "," + Lat.ToString("0.00000000") + "," + Lon.ToString("0.00000000") + "," + pos_X.ToString("0.000") + "," + pos_Y.ToString("0.000") + "," + phi.ToString("0.0") + "," + GPS_Phi.ToString("0.0") + "," + speed.ToString("0.00") + "," + gear.ToString() + "," + rud.ToString("0.0") + ',' + CtrlRudOut.ToString() + ',' + CtrlSpeedOut.ToString() + ',' + Time.ToString();//将数据转换为字符串 byte[] data = System.Text.Encoding.Default.GetBytes(str_data); byte[] data3 = new byte[2]; data3[0] = 0x0d; data3[1] = 0x0a; //开始写入 fs.Write(data, 0, data.Length); fs.Write(data3, 0, data3.Length); //清空缓冲区、关闭流 fs.Flush(); fs.Close(); } }
public void Write(Writer writer) { writer.WriteEnum <PlayerTag>(PlayerTag); writer.Write(ShipID.ToString()); writer.Write(HasTarget); writer.Write(TargetShipID.ToString()); }
/// <summary> /// 存储船舶状态信息 /// </summary> /// <param name="fileName"></param> public void StoreShipData(string fileName, DataTable dataRec) { /*using (FileStream fs = new FileStream(@"D:\" + fileName + ".txt", FileMode.Append)) * { * //数据保存信息量为: * //船号,纬度,经度,X坐标(m),Y坐标,和领队误差,航向角,航迹角,速度,速度等级,时间 * //在速度等级后面增加舵角信息,舵角控制输出量信息和速度控制输出量信息 * //共13个存储量 * string str_data = ShipID.ToString() + "," + Lat.ToString("0.00000000") + "," + Lon.ToString("0.00000000") + "," + pos_X.ToString("0.000") + "," + pos_Y.ToString("0.000") + "," + XError.ToString("0.000") + "," + phi.ToString("0.0") + "," + GPS_Phi.ToString("0.0") + "," + speed.ToString("0.00") + "," + gear.ToString() + "," + rud.ToString("0.0") + ',' + CtrlRudOut.ToString() + ',' + CtrlSpeedOut.ToString() + ',' + Time.ToString();//将数据转换为字符串 + + byte[] data = System.Text.Encoding.Default.GetBytes(str_data); + byte[] data3 = new byte[2]; + data3[0] = 0x0d; data3[1] = 0x0a; + //开始写入 + fs.Write(data, 0, data.Length); + + fs.Write(data3, 0, data3.Length); + + //清空缓冲区、关闭流 + fs.Flush(); + fs.Close(); + }*/ /*gridView.Rows.Add(ShipID.ToString(), Lat.ToString("0.00000000"), Lon.ToString("0.00000000"), * pos_X.ToString("0.000"), pos_Y.ToString("0.000"), XError.ToString("0.000"), * phi.ToString("0.0"), GPS_Phi.ToString("0.0"), * speed.ToString("0.00"), gear.ToString(), * rud.ToString("0.0"), CtrlRudOut.ToString(), CtrlSpeedOut.ToString(), * Time.ToString());*/ dataRec.Rows.Add(new object[] { ShipID.ToString(), Lat.ToString("0.00000000"), Lon.ToString("0.00000000"), Fter_pos_X.ToString("0.000"), Fter_pos_Y.ToString("0.000"), XError.ToString("0.000"), phi.ToString("0.0"), GPS_Phi.ToString("0.0"), Fter_GPS_Phi.ToString("0.0"), speed.ToString("0.00"), gear.ToString(), rud.ToString("0.0"), CtrlRudOut.ToString(), CtrlSpeedOut.ToString(), e1.ToString(), e2.ToString(), Vf.ToString(), F2.ToString(), MotorSpd.ToString(), HUST_1_Demo.Form1.followLineID.ToString(),//多段直线ID戳 sTime.ToString() }); }
public void StoreShipData(string fileName) { using (FileStream fs = new FileStream(@"D:\" + fileName + ".txt", FileMode.Append)) { string str_data = ShipID.ToString() + "," + Lat.ToString("0.00000000") + "," + Lon.ToString("0.00000000") + "," + pos_X.ToString() + "," + pos_Y.ToString() + "," + phi.ToString() + "," + GPS_Phi.ToString() + "," + speed.ToString("0.000") + "," + gear.ToString() + "," + Time.ToString();//将数据转换为字符串 byte[] data = System.Text.Encoding.Default.GetBytes(str_data); byte[] data3 = new byte[2]; data3[0] = 0x0d; data3[1] = 0x0a; //开始写入 fs.Write(data, 0, data.Length); fs.Write(data3, 0, data3.Length); //清空缓冲区、关闭流 fs.Flush(); fs.Close(); } }
public void Write(Writer writer) { writer.WriteEnum <PlayerTag>(PlayerTag); writer.Write(ShipID.ToString()); writer.WriteEnum <Autopilot.ChadburnSetting>(ChadburnSetting); }
public void Write(Writer writer) { writer.WriteEnum <PlayerTag>(PlayerTag); writer.Write(ShipID.ToString()); writer.Write(Course); }