本文整理汇总了C#中serialstatus类的典型用法代码示例。如果您正苦于以下问题:C# serialstatus类的具体用法?C# serialstatus怎么用?C# serialstatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
serialstatus类属于命名空间,在下文中一共展示了serialstatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Log_Load
private void Log_Load(object sender, EventArgs e)
{
if (!MainV2.comPort.BaseStream.IsOpen)
{
this.Close();
CustomMessageBox.Show("Please Connect");
return;
}
try
{
var list = MainV2.comPort.GetLogList();
foreach (var item in list)
{
genchkcombo(item.id);
TXT_seriallog.AppendText(item.id + "\t" + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + "\test size:\t" + item.size +"\r\n");
}
if (list.Count == 0)
{
TXT_seriallog.AppendText("No logs to download");
}
}
catch { CustomMessageBox.Show(Strings.ErrorLogList, Strings.ERROR); this.Close(); }
status = serialstatus.Done;
}
开发者ID:novakeugene,项目名称:MissionPlanner,代码行数:29,代码来源:LogDownloadMavLink.cs
示例2: GetLog
string GetLog(ushort no)
{
MainV2.comPort.Progress += comPort_Progress;
status = serialstatus.Reading;
// get df log from mav
var ms = MainV2.comPort.GetLog(no);
status = serialstatus.Done;
updateDisplay();
MainV2.comPort.Progress -= comPort_Progress;
// set log fn
byte[] hbpacket = MainV2.comPort.getHeartBeat();
MAVLink.mavlink_heartbeat_t hb = (MAVLink.mavlink_heartbeat_t)MainV2.comPort.DebugPacket(hbpacket);
logfile = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " " + no + ".bin";
// make log dir
Directory.CreateDirectory(Path.GetDirectoryName(logfile));
// save memorystream to file
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(logfile)))
{
bw.Write(ms.ToArray());
}
// read binary log to assci log
var temp1 = Log.BinaryLog.ReadLog(logfile);
// delete binary log file
//File.Delete(logfile);
logfile = logfile + ".log";
// write assci log
using (StreamWriter sw = new StreamWriter(logfile))
{
foreach (string line in temp1)
{
sw.Write(line);
}
sw.Close();
}
// get gps time of assci log
DateTime logtime = DFLog.GetFirstGpsTime(logfile);
// rename log is we have a valid gps time
if (logtime != DateTime.MinValue)
{
string newlogfilename = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar + logtime.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
try
{
File.Move(logfile, newlogfilename);
// rename bin as well
File.Move(logfile.Replace(".log", ""), newlogfilename.Replace(".log", ".bin"));
logfile = newlogfilename;
}
catch (Exception ex) { CustomMessageBox.Show("Failed to rename file " + logfile + "\nto " + newlogfilename, "Error"); }
}
return logfile;
}
开发者ID:jchevin,项目名称:MissionPlanner-master,代码行数:71,代码来源:LogDownloadMavLink.cs
示例3: downloadthread
private void downloadthread(int startlognum, int endlognum)
{
for (int a = startlognum; a <= endlognum; a++)
{
currentlog = a;
System.Threading.Thread.Sleep(500);
comPort.Write("dump ");
System.Threading.Thread.Sleep(100);
comPort.Write(a.ToString() + "\r");
status = serialstatus.Createfile;
while (status != serialstatus.Done)
{
System.Threading.Thread.Sleep(100);
}
}
}
开发者ID:GOBbluth89,项目名称:arduplane-custom-tamu,代码行数:18,代码来源:Log.cs
示例4: comPort_DataReceived
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
while (comPort.BytesToRead > 0 && threadrun)
{
updateDisplay();
string line = "";
comPort.ReadTimeout = 500;
try
{
line = comPort.ReadLine(); //readline(comPort);
if (!line.Contains("\n"))
line = line + "\n";
}
catch
{
line = comPort.ReadExisting();
//byte[] data = readline(comPort);
//line = Encoding.ASCII.GetString(data, 0, data.Length);
}
receivedbytes += line.Length;
//string line = Encoding.ASCII.GetString(data, 0, data.Length);
switch (status)
{
case serialstatus.Connecting:
if (line.Contains("ENTER") || line.Contains("GROUND START") || line.Contains("reset to FLY") || line.Contains("interactive setup") || line.Contains("CLI") || line.Contains("Ardu"))
{
try
{
comPort.Write("\n\n\n\n");
}
catch { }
comPort.Write("logs\r");
status = serialstatus.Done;
}
break;
case serialstatus.Closefile:
sw.Close();
TextReader tr = new StreamReader(logfile);
this.Invoke((System.Windows.Forms.MethodInvoker)delegate()
{
TXT_seriallog.AppendText("Createing KML for " + logfile);
});
while (tr.Peek() != -1)
{
processLine(tr.ReadLine());
}
tr.Close();
try
{
writeKML(logfile + ".kml");
}
catch { } // usualy invalid lat long error
status = serialstatus.Done;
break;
case serialstatus.Createfile:
receivedbytes = 0;
Directory.CreateDirectory(Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs");
logfile = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + @"logs" + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm") + " " + currentlog + ".log";
sw = new StreamWriter(logfile);
status = serialstatus.Waiting;
lock (thisLock)
{
this.Invoke((System.Windows.Forms.MethodInvoker)delegate()
{
TXT_seriallog.Clear();
});
}
//if (line.Contains("Dumping Log"))
{
status = serialstatus.Reading;
}
break;
case serialstatus.Done:
//
if (line.Contains("start") && line.Contains("end"))
{
Regex regex2 = new Regex(@"^Log ([0-9]+),", RegexOptions.IgnoreCase);
if (regex2.IsMatch(line))
{
MatchCollection matchs = regex2.Matches(line);
logcount = int.Parse(matchs[0].Groups[1].Value);
genchkcombo(logcount);
//status = serialstatus.Done;
}
}
if (line.Contains("No logs"))
//.........这里部分代码省略.........
开发者ID:GOBbluth89,项目名称:arduplane-custom-tamu,代码行数:101,代码来源:Log.cs
示例5: downloadsinglethread
private void downloadsinglethread()
{
try
{
for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i)
{
int a = (int)CHK_logs.CheckedItems[i];
currentlog = a;
var logname = GetLog((ushort)a);
CreateLog(logname);
if (chk_droneshare.Checked)
{
try
{
Utilities.DroneApi.droneshare.doUpload(logname);
}
catch (Exception ex) { CustomMessageBox.Show("Droneshare upload failed " + ex.ToString()); }
}
}
status = serialstatus.Done;
updateDisplay();
Console.Beep();
}
catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error in log " + currentlog); }
}
开发者ID:novakeugene,项目名称:MissionPlanner,代码行数:31,代码来源:LogDownloadMavLink.cs
示例6: BUT_clearlogs_Click
private void BUT_clearlogs_Click(object sender, EventArgs e)
{
try
{
System.Threading.Thread.Sleep(500);
comPort.Write("erase\r");
System.Threading.Thread.Sleep(100);
TXT_seriallog.AppendText("!!Allow 30-90 seconds for erase\n");
status = serialstatus.Done;
CHK_logs.Items.Clear();
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message, Strings.ERROR);
}
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:16,代码来源:LogDownload.cs
示例7: CreateLog
void CreateLog(string logfile)
{
TextReader tr = new StreamReader(logfile);
//
this.Invoke((System.Windows.Forms.MethodInvoker)delegate()
{
TXT_seriallog.AppendText("Creating KML for " + logfile + "\n");
});
LogOutput lo = new LogOutput();
while (tr.Peek() != -1)
{
lo.processLine(tr.ReadLine());
}
tr.Close();
try
{
lo.writeKML(logfile + ".kml");
}
catch { } // usualy invalid lat long error
status = serialstatus.Done;
updateDisplay();
}
开发者ID:novakeugene,项目名称:MissionPlanner,代码行数:27,代码来源:LogDownloadMavLink.cs
示例8: downloadthread
private void downloadthread(dltype type)
{
try
{
downloading = true;
List<int> items = new List<int>();
switch(type)
{
case dltype.All:
for (int i = 0; i < CHK_logs.Items.Count; ++i)
items.Add((int)CHK_logs.Items[i]);
break;
case dltype.Selected:
for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i)
items.Add((int)CHK_logs.CheckedItems[i]);
break;
case dltype.MinusOne:
items.Add(-1);
break;
}
for (int i = 0; i < items.Count; ++i)
{
currentlog = items[i];
comPort.Write("dump ");
comPort.Write(items[i].ToString() + "\r");
log.Info("state ->Createfile\r");
status = serialstatus.Createfile;
if (i==items.Count-1) downloading = false;
while (status != serialstatus.Done && status != serialstatus.Error)
{
System.Threading.Thread.Sleep(10);
}
if (exitpending || status == serialstatus.Error)
{
downloading = false;
return;
}
}
Console.Beep();
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message, "Error in log " + currentlog);
}
}
开发者ID:rh-galaxy,项目名称:MissionPlanner,代码行数:51,代码来源:LogDownload.cs
示例9: Log_Load
private void Log_Load(object sender, EventArgs e)
{
log.Info("state ->Connecting\r");
status = serialstatus.Connecting;
connect_substate = 0;
comPort = GCSViews.Terminal.comPort;
t11 = new System.Threading.Thread(delegate()
{
var start = DateTime.Now;
bool threaderror = false;
threadrun = true;
try
{
comPort.Write("exit\rlogs\r"); // more in "connecting"
}
catch (Exception ex)
{
log.Info("state ->Error\r");
status = serialstatus.Error;
log.Error("Error in comport thread " + ex);
threaderror = true;
}
while (threadrun)
{
try
{
updateDisplay();
System.Threading.Thread.Sleep(1);
while (comPort.BytesToRead > 0)
{
comPort_DataReceived((object)null, (SerialDataReceivedEventArgs)null);
}
}
catch (Exception ex)
{
if (!threaderror)
{
log.Info("state ->Error\r");
status = serialstatus.Error;
log.Error("Error in comport thread " + ex);
threaderror = true;
}
} // cant exit unless told to
}
log.Info("Comport thread close");
});
t11.IsBackground = true;
t11.Name = "Log serial thread";
t11.Start();
// doesnt seem to work on mac
//comPort.DataReceived += new SerialDataReceivedEventHandler(comPort_DataReceived);
}
开发者ID:rh-galaxy,项目名称:MissionPlanner,代码行数:59,代码来源:LogDownload.cs
示例10: Log_Load
private void Log_Load(object sender, EventArgs e)
{
if (MainV2.config["log_isarducopter"] != null)
{
CHK_arducopter.Checked = bool.Parse(MainV2.config["log_isarducopter"].ToString());
CHK_arduplane.Checked = bool.Parse(MainV2.config["log_isarduplane"].ToString());
CHK_ardurover.Checked = bool.Parse(MainV2.config["log_isardurover"].ToString());
}
status = serialstatus.Connecting;
MainV2.comPort.giveComport = true;
comPort = MainV2.comPort.BaseStream;
comPort.DtrEnable = false;
comPort.RtsEnable = false;
try
{
Console.WriteLine("Log_load " + comPort.IsOpen);
if (!comPort.IsOpen)
comPort.Open();
Console.WriteLine("Log dtr");
comPort.toggleDTR();
Console.WriteLine("Log discard");
comPort.DiscardInBuffer();
Console.WriteLine("Log w&sleep");
try
{
// try provoke a responce
comPort.Write("\n\n?\r\n\n");
}
catch
{
}
// 10 sec
waitandsleep(10000);
}
catch (Exception ex)
{
log.Error("Error opening comport", ex);
CustomMessageBox.Show("Error opening comport");
}
var t11 = new System.Threading.Thread(delegate()
{
var start = DateTime.Now;
threadrun = true;
readandsleep(100);
try
{
comPort.Write("\n\n\n\nexit\r\nlogs\r\n"); // more in "connecting"
}
catch
{
}
while (threadrun)
{
try
{
updateDisplay();
System.Threading.Thread.Sleep(10);
if (!comPort.IsOpen)
break;
while (comPort.BytesToRead >= 4)
{
comPort_DataReceived((object)null, (SerialDataReceivedEventArgs)null);
}
}
catch (Exception ex)
{
log.Error("crash in comport reader " + ex);
} // cant exit unless told to
}
log.Info("Comport thread close");
}) {Name = "comport reader"};
t11.Start();
// doesnt seem to work on mac
//comPort.DataReceived += new SerialDataReceivedEventHandler(comPort_DataReceived);
}
开发者ID:realbuxtehuder,项目名称:MissionPlanner,代码行数:95,代码来源:Log.cs
示例11: comPort_DataReceived
void comPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
while (comPort.BytesToRead > 0 && threadrun)
{
updateDisplay();
string line = "";
comPort.ReadTimeout = 500;
try
{
line = comPort.ReadLine();
if (!line.Contains("\n"))
line = line + "\n";
}
catch
{
line = comPort.ReadExisting();
}
receivedbytes += line.Length;
//string line = Encoding.ASCII.GetString(data, 0, data.Length);
switch (status)
{
case serialstatus.Connecting:
if (connect_substate==0 && line.Contains("] logs"))
{
connect_substate++;
break;
}
if (connect_substate == 1 && line.Contains("Log]"))
{
connect_substate++;
}
if (connect_substate == 2)
{
// clear history
this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate()
{
TXT_seriallog.Clear();
});
log.Info("state ->ReceiveListing\r");
status = serialstatus.ReceiveListing;
}
break;
case serialstatus.Done:
break;
case serialstatus.Closefile:
sw.Close();
DateTime logtime = DFLog.GetFirstGpsTime(logfile);
if (logtime != DateTime.MinValue)
{
string newlogfilename = MainV2.LogDir + Path.DirectorySeparatorChar + logtime.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
try
{
File.Move(logfile, newlogfilename);
logfile = newlogfilename;
}
catch (Exception ex) { CustomMessageBox.Show("Failed to rename file " + logfile + "\nto " + newlogfilename,"Error"); }
}
CreateLog(logfile);
log.Info("state ->ReceiveListing\r");
status = serialstatus.ReceiveListing;
break;
case serialstatus.Createfile:
receivedbytes = 0;
Directory.CreateDirectory(MainV2.LogDir);
logfile = MainV2.LogDir + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " " + currentlog + ".log";
sw = new StreamWriter(logfile);
log.Info("state ->Reading\r");
status = serialstatus.Reading;
break;
case serialstatus.ReceiveListing:
{
Regex regex2 = new Regex(@"^Log ([0-9]+)[,\s]", RegexOptions.IgnoreCase);
if (regex2.IsMatch(line))
{
MatchCollection matchs = regex2.Matches(line);
int lognr = int.Parse(matchs[0].Groups[1].Value);
genchkcombo(lognr);
}
}
if (line.Contains("Log]"))
{
log.Info("state ->Done\r");
status = serialstatus.Done;
}
break;
case serialstatus.Reading:
//.........这里部分代码省略.........
开发者ID:rh-galaxy,项目名称:MissionPlanner,代码行数:101,代码来源:LogDownload.cs
示例12: downloadthread
private void downloadthread(int startlognum, int endlognum)
{
try
{
for (int a = startlognum; a <= endlognum; a++)
{
currentlog = a;
var logname = GetLog((ushort)a);
CreateLog(logname);
}
status = serialstatus.Done;
updateDisplay();
Console.Beep();
}
catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error in log " + currentlog); }
}
开发者ID:ECain,项目名称:MissionPlanner,代码行数:20,代码来源:LogDownloadMavLink.cs
示例13: downloadsinglethread
private void downloadsinglethread()
{
try
{
for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i)
{
int a = (int)CHK_logs.CheckedItems[i];
{
currentlog = a;
var logname = GetLog((ushort)a);
CreateLog(logname);
}
}
status = serialstatus.Done;
updateDisplay();
Console.Beep();
}
catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error in log " + currentlog); }
}
开发者ID:ECain,项目名称:MissionPlanner,代码行数:23,代码来源:LogDownloadMavLink.cs
示例14: GetLog
string GetLog(ushort no)
{
log.Info("GetLog " + no);
MainV2.comPort.Progress += comPort_Progress;
status = serialstatus.Reading;
// used for log fn
byte[] hbpacket = MainV2.comPort.getHeartBeat();
if (hbpacket != null)
log.Info("Got hbpacket length: " + hbpacket.Length);
// get df log from mav
using (var ms = MainV2.comPort.GetLog(no))
{
ms.Seek(0, SeekOrigin.Begin);
if (ms != null)
log.Info("Got Log length: " + ms.Length);
status = serialstatus.Done;
updateDisplay();
MainV2.comPort.Progress -= comPort_Progress;
MAVLink.mavlink_heartbeat_t hb = (MAVLink.mavlink_heartbeat_t) MainV2.comPort.DebugPacket(hbpacket);
logfile = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") +
" " +
no + ".bin";
// make log dir
Directory.CreateDirectory(Path.GetDirectoryName(logfile));
log.Info("about to write: " + logfile);
// save memorystream to file
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(logfile)))
{
byte[] buffer = new byte[256*1024];
while (ms.Position < ms.Length)
{
int read = ms.Read(buffer, 0, buffer.Length);
bw.Write(buffer, 0, read);
}
}
}
log.Info("about to convertbin: " + logfile);
// create ascii log
BinaryLog.ConvertBin(logfile, logfile + ".log");
//update the new filename
logfile = logfile + ".log";
log.Info("about to GetFirstGpsTime: " + logfile);
// get gps time of assci log
DateTime logtime = new DFLog().GetFirstGpsTime(logfile);
// rename log is we have a valid gps time
if (logtime != DateTime.MinValue)
{
string newlogfilename = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar +
logtime.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
try
{
File.Move(logfile, newlogfilename);
// rename bin as well
File.Move(logfile.Replace(".log", ""), newlogfilename.Replace(".log", ".bin"));
logfile = newlogfilename;
}
catch
{
CustomMessageBox.Show(Strings.ErrorRenameFile + " " + logfile + "\nto " + newlogfilename,
Strings.ERROR);
}
}
return logfile;
}
开发者ID:jilinggui,项目名称:MissionPlanner,代码行数:86,代码来源:LogDownloadMavLink.cs
示例15: downloadthread
private void downloadthread(int startlognum, int endlognum)
{
try
{
for (int a = startlognum; a <= endlognum; a++)
{
currentlog = a;
System.Threading.Thread.Sleep(1100);
comPort.Write("dump ");
System.Threading.Thread.Sleep(100);
comPort.Write(a.ToString() + "\r");
comPort.DiscardInBuffer();
status = serialstatus.Createfile;
while (status != serialstatus.Done)
{
System.Threading.Thread.Sleep(100);
}
}
Console.Beep();
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message, Strings.ERROR);
}
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:27,代码来源:LogDownload.cs
示例16: downloadthread
private void downloadthread(dltype type)
{
try
{
List<int> items = new List<int>();
switch(type)
{
case dltype.All:
for (int i = 0; i < CHK_logs.Items.Count; ++i)
items.Add((int)CHK_logs.Items[i]);
break;
case dltype.Selected:
for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i)
items.Add((int)CHK_logs.CheckedItems[i]);
break;
}
for (int i = 0; i < items.Count; ++i)
{
currentlog = items[i];
var logname = GetLog((ushort)currentlog);
CreateLog(logname);
}
status = serialstatus.Done;
Console.Beep();
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message, "Error in log " + currentlog);
}
}
开发者ID:rh-galaxy,项目名称:MissionPlanner,代码行数:34,代码来源:LogDownloadMavLink.cs
示例17: downloadsinglethread
private void downloadsinglethread()
{
try
{
for (int i = 0; i < CHK_logs.CheckedItems.Count; ++i)
{
int a = (int) CHK_logs.CheckedItems[i];
{
currentlog = a;
System.Threading.Thread.Sleep(1100);
comPort.Write("dump ");
System.Threading.Thread.Sleep(100);
comPort.Write(a.ToString() + "\r");
comPort.DiscardInBuffer();
status = serialstatus.Createfile;
while (status != serialstatus.Done)
{
System.Threading.Thread.Sleep(100);
}
}
}
Console.Beep();
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message, Strings.ERROR);
}
}
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:30,代码来源:LogDownload.cs
示例18: Log_Load
private void Log_Load(object sender, EventArgs e)
{
if (!MainV2.comPort.BaseStream.IsOpen)
{
this.Close();
CustomMessageBox.Show("Please Connect");
return;
}
try
{
var list = MainV2.comPort.GetLogList();
foreach (var item in list)
{
genchkcombo(item.id);
TXT_seriallog.AppendText(item.id + " " + new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(item.time_utc).ToLocalTime() + " est size: " + item.size +"\n");
}
}
catch { CustomMessageBox.Show("Cannot get log list.","Error"); this.Close(); }
status = serialstatus.Done;
}
开发者ID:LeoTosti,项目名称:x-drone,代码行数:24,代码来源:LogDownloadMavLink.cs
示例19: GetLog
string GetLog(ushort no)
{
MainV2.comPort.Progress += comPort_Progress;
status = serialstatus.Reading;
// get df log from mav
var ms = MainV2.comPort.GetLog(no);
status = serialstatus.Done;
updateDisplay();
MainV2.comPort.Progress -= comPort_Progress;
// set log fn
byte[] hbpacket = MainV2.comPort.getHeartBeat();
MAVLink.mavlink_heartbeat_t hb = (MAVLink.mavlink_heartbeat_t)MainV2.comPort.DebugPacket(hbpacket);
logfile = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " " + no + ".bin";
// make log dir
Directory.CreateDirectory(Path.GetDirectoryName(logfile));
// save memorystream to file
using (BinaryWriter bw = new BinaryWriter(File.OpenWrite(logfile)))
{
bw.Write(ms.ToArray());
}
// create ascii log
BinaryLog.ConvertBin(logfile, logfile + ".log");
//update the new filename
logfile = logfile + ".log";
// get gps time of assci log
DateTime logtime = new DFLog().GetFirstGpsTime(logfile);
// rename log is we have a valid gps time
if (logtime != DateTime.MinValue)
{
string newlogfilename = MainV2.LogDir + Path.DirectorySeparatorChar
+ MainV2.comPort.MAV.aptype.ToString() + Path.DirectorySeparatorChar
+ hbpacket[3] + Path.DirectorySeparatorChar + logtime.ToString("yyyy-MM-dd HH-mm-ss") + ".log";
try
{
File.Move(logfile, newlogfilename);
// rename bin as well
File.Move(logfile.Replace(".log", ""), newlogfilename.Replace(".log", ".bin"));
logfile = newlogfilename;
}
catch { CustomMessageBox.Show(Strings.ErrorRenameFile+ " " + logfile + "\nto " + newlogfilename, Strings.ERROR); }
}
return logfile;
}
开发者ID:novakeugene,项目名称:MissionPlanner,代码行数:59,代码来源:LogDownloadMavLink.cs
示例20: BUT_clearlogs_Click
private void BUT_clearlogs_Click(object sender, EventArgs e)
{
try
{
MainV2.comPort.EraseLog();
TXT_seriallog.AppendText("!!Allow 30-90 seconds for erase\n");
status = serialstatus.Done;
CHK_logs.Items.Clear();
}
catch (Exception ex) { CustomMessageBox.Show(ex.Message, "Error"); }
}
开发者ID:jlcox1970,项目名称:MissionPlanner,代码行数:11,代码来源:LogDownloadMavLink.cs
注:本文中的serialstatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论