private void button10_Click(object sender, EventArgs e) { string cmd = "HM\r"; serialPort1.WriteLine(cmd); RecallData.AppendText(cmd + Environment.NewLine); trackBar3.Enabled = true; }
private void buttonStRequest_Click(object sender, EventArgs e) { string cmd = "RV 2\r"; byte[] aaa = Encoding.UTF8.GetBytes(cmd); serialPort1.Write(aaa, 0, aaa.Length); RecallData.AppendText(cmd + Environment.NewLine); }
private void trackBar3_Scroll(object sender, EventArgs e) { label15.Text = "VC:" + trackBar3.Value.ToString(); string cmd = "JC " + trackBar3.Value.ToString() + "\r"; serialPort1.WriteLine(cmd); RecallData.AppendText(cmd + Environment.NewLine); }
private void buttonCW_Click(object sender, EventArgs e) { //serialPort1.WriteLine("EN 1\r"); //System.Threading.Thread.Sleep(50); double ans = Convert.ToDouble(multiplierTextbox.Text) * 6400; string cmd = "MI -" + ans.ToString() + "\r"; RecallData.AppendText(cmd + Environment.NewLine); serialPort1.WriteLine(cmd); //System.Threading.Thread.Sleep(1500); //serialPort1.WriteLine("EN 0\r"); }
private void button3_Click(object sender, EventArgs e) { /*Save data into csv format SAMPLE CODE*/ string strFilePath = @".\runin.csv"; string strFilePath2 = @".\fdrexp.csv"; string strSeperator = ","; StringBuilder sbOutput = new StringBuilder(); /* Using saveFile Dialog to setup file path */ //saveFileDialog1.Filter = "CSV Files|*.csv|All Files|*.*"; //saveFileDialog1.Title = "Save an CSV File"; //saveFileDialog1.ShowDialog(); //// If the file name is not an empty string open it for saving. //if (saveFileDialog1.FileName != "") //{ // switch (saveFileDialog1.FilterIndex) // { // case 1: // strFilePath = saveFileDialog1.FileName; // break; // case 2: // strFilePath = saveFileDialog1.FileName; // break; // } //} //random data /*int[][] inaOutput = new int[][]{ * new int[]{1000, 2000, 3000, 4000, 5000,6,7}, * new int[]{6000, 7000, 8000, 9000, 10000,6,7}, * new int[]{11000, 12000, 13000, 14000, 15000,6,7} * }; * /*-------------------------*/ string[] colHeader = { "System time", "Test Time (sec)", "Z Position (um)", "Over Drive (um)", "Force (gf)", "Resistance (Ohm)", "Real OD (um)" }; //int ilength = inaOutput.GetLength(0); sbOutput.AppendLine(string.Join(strSeperator, colHeader)); //for (int i = 0; i < ilength; i++) // sbOutput.AppendLine(string.Join(strSeperator, inaOutput[i])); // Create and write the csv file if the file doesn't exist File.WriteAllText(strFilePath, sbOutput.ToString()); File.WriteAllText(strFilePath2, sbOutput.ToString()); RecallData.AppendText(strFilePath + " and " + strFilePath2 + " CLEARED " + Environment.NewLine); }
//使用ASCII字元集將位元組轉換為字元組(字串) private void button2_Click(object sender, EventArgs e) { string sss = SendData.Text; byte[] aaa = Encoding.UTF8.GetBytes(SendData.Text + "\r"); //byte[] aaa2 = Encoding.UTF8.GetBytes(SendData.Text + "\r"); serialPort1.Write(aaa, 0, aaa.Length); //serialPort1.WriteLine(SendData.Text + "\r"); RecallData.AppendText(SendData.Text + Environment.NewLine); //AppendText will auto scroll to end //RecallData.Text += (SendData.Text + Environment.NewLine); SendData.Text = ""; //Clear send data }
private void DisplayText(Byte[] buffer) { char[] tmp = new char[buffer.Length]; for (int i = 0; i < buffer.Length; i++) { tmp[i] = Convert.ToChar(buffer[i]); } string buff = new string(tmp); RecallData.AppendText(buff); //RecallData.Text += buff; receiveData = buff; }
private void motorOff_Click(object sender, EventArgs e) { byte[] aaa = Encoding.UTF8.GetBytes("EN 0\r"); serialPort1.Write(aaa, 0, aaa.Length); RecallData.AppendText("EN 0\n"); }