Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MAX14720 MAX30205 USBDevice
FileLog.cs
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All rights Reserved. 00003 * 00004 * This software is protected by copyright laws of the United States and 00005 * of foreign countries. This material may also be protected by patent laws 00006 * and technology transfer regulations of the United States and of foreign 00007 * countries. This software is furnished under a license agreement and/or a 00008 * nondisclosure agreement and may only be used or reproduced in accordance 00009 * with the terms of those agreements. Dissemination of this information to 00010 * any party or parties not specified in the license agreement and/or 00011 * nondisclosure agreement is expressly prohibited. 00012 * 00013 * The above copyright notice and this permission notice shall be included 00014 * in all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00017 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00019 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00020 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00021 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00022 * OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Except as contained in this notice, the name of Maxim Integrated 00025 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00026 * Products, Inc. Branding Policy. 00027 * 00028 * The mere transfer of this software does not imply any licenses 00029 * of trade secrets, proprietary technology, copyrights, patents, 00030 * trademarks, maskwork rights, or any other form of intellectual 00031 * property whatsoever. Maxim Integrated Products, Inc. retains all 00032 * ownership rights. 00033 ******************************************************************************* 00034 */ 00035 00036 using System; 00037 using System.Collections.Generic; 00038 using System.Linq; 00039 using System.Text; 00040 using System.Threading.Tasks; 00041 using System.IO; 00042 using System.Windows.Forms; 00043 00044 using Maxim.Global; 00045 00046 namespace Maxim.Utility 00047 { 00048 public class FileLog 00049 { 00050 StreamWriter outputStream = null; 00051 SaveFileDialog fileDialog = new SaveFileDialog(); 00052 string fileDirectory = null; 00053 00054 public EventHandler<Maxim.Global.ErrorEventArgs> Error; 00055 00056 public FileLog() 00057 { 00058 fileDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 00059 fileDialog.InitialDirectory = fileDirectory; 00060 } 00061 00062 public string FileDirectory 00063 { 00064 get 00065 { 00066 return fileDirectory; 00067 } 00068 set 00069 { 00070 fileDirectory = value; 00071 } 00072 } 00073 00074 public bool SelectCSVFile(string fileName) 00075 { 00076 fileDialog.FileName = fileName + "_" + string.Format("{0:yyyy-MM-dd_HH-mm-ss}", DateTime.Now) + ".csv"; 00077 fileDialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; 00078 fileDialog.InitialDirectory = fileDirectory; 00079 if (fileDialog.ShowDialog() == DialogResult.OK) 00080 { 00081 fileDirectory = Path.GetDirectoryName(fileDialog.FileName); 00082 outputStream = new StreamWriter(fileDialog.FileName, false, System.Text.Encoding.UTF8); 00083 outputStream.AutoFlush = true; 00084 00085 return true; 00086 } 00087 else 00088 return false; 00089 } 00090 00091 public void Close() 00092 { 00093 if (outputStream != null) 00094 { 00095 try 00096 { 00097 outputStream.Flush(); 00098 } 00099 catch (System.ObjectDisposedException) 00100 { 00101 // TODO 00102 } 00103 outputStream.Close(); 00104 } 00105 } 00106 00107 public void Write(string value) 00108 { 00109 outputStream.Write(value); 00110 } 00111 00112 public void WriteLine(string value) 00113 { 00114 //outputStream.WriteLine(string.Format("{0:HH-mm-ss}", DateTime.Now) + ", " + value); 00115 outputStream.WriteLine(value); 00116 } 00117 } 00118 }
Generated on Thu Jul 28 2022 18:07:13 by
1.7.2