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
RpcLog.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.ComponentModel; 00039 using System.Data; 00040 using System.Drawing; 00041 using System.Linq; 00042 using System.Text; 00043 using System.Windows.Forms; 00044 using System.IO; 00045 using System.Text.RegularExpressions; 00046 00047 namespace RPCSupport.Dialogs 00048 { 00049 public partial class RpcLog : Form 00050 { 00051 public RpcLog() 00052 { 00053 InitializeComponent(); 00054 } 00055 00056 private const int CP_NOCLOSE_BUTTON = 0x200; 00057 protected override CreateParams CreateParams 00058 { 00059 get 00060 { 00061 CreateParams myCp = base.CreateParams; 00062 myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON; 00063 return myCp; 00064 } 00065 } 00066 00067 internal void LogRpcRequest(string request) 00068 { 00069 //txt_Status.Text += request; 00070 SetTextListBox(request + " "); 00071 } 00072 00073 internal void LogRpcReply(string reply) 00074 { 00075 //txt_Status.Text += reply + "\r\n"; 00076 SetTextListBox(reply + " "); 00077 } 00078 00079 delegate void SetTextCallback(string text); 00080 00081 private void SetText(string text) 00082 { 00083 // InvokeRequired required compares the thread ID of the 00084 // calling thread to the thread ID of the creating thread. 00085 // If these threads are different, it returns true. 00086 if (this.txt_Status.InvokeRequired) 00087 { 00088 SetTextCallback d = new SetTextCallback(SetText); 00089 this.Invoke(d, new object[] { text }); 00090 } 00091 else 00092 { 00093 this.txt_Status.Text += text; 00094 if (this.txt_Status.Text.Length > 2000) this.txt_Status.Text = ""; 00095 } 00096 } 00097 00098 delegate void UpdateCCNetWindowDelegate(String msg); 00099 00100 private void SetTextListBox(String message) 00101 { 00102 // Check whether the caller must call an invoke method when making method calls to listBoxCCNetOutput because the caller is 00103 // on a different thread than the one the listBoxCCNetOutput control was created on. 00104 if (listBox1.InvokeRequired) 00105 { 00106 UpdateCCNetWindowDelegate update = new UpdateCCNetWindowDelegate(SetTextListBox); 00107 listBox1.Invoke(update, message); 00108 } 00109 else 00110 { 00111 listBox1.Items.Add(message); 00112 if (listBox1.Items.Count > 10000) 00113 { 00114 listBox1.Items.RemoveAt(0); // remove first line 00115 } 00116 // Make sure the last item is made visible 00117 listBox1.SelectedIndex = listBox1.Items.Count - 1; 00118 listBox1.ClearSelected(); 00119 } 00120 } 00121 00122 00123 internal void LogRpcStream(string stream) 00124 { 00125 //txt_Status.Text += stream + " "; 00126 SetTextListBox(stream + " "); 00127 } 00128 00129 private void btn_Clear_Click(object sender, EventArgs e) 00130 { 00131 //txt_Status.Text = ""; 00132 listBox1.Items.Clear(); 00133 } 00134 00135 private void txt_Status_TextChanged(object sender, EventArgs e) 00136 { 00137 00138 } 00139 00140 private void btnSaveToFile_Click(object sender, EventArgs e) 00141 { 00142 SaveFileDialog saveFileDialog = new SaveFileDialog(); 00143 DialogResult result = saveFileDialog.ShowDialog(); 00144 if (result == System.Windows.Forms.DialogResult.OK) 00145 { 00146 StreamWriter sw = new StreamWriter(saveFileDialog.FileName); 00147 for (int i = 0; i < listBox1.Items.Count; i++) 00148 { 00149 sw.WriteLine(Regex.Replace(listBox1.Items[i].ToString(), @"\r\n?|\n", "")); 00150 } 00151 sw.Close(); 00152 } 00153 } 00154 } 00155 }
Generated on Thu Jul 28 2022 18:07:15 by
 1.7.2