| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
- 안드로이드
- java
- 스시
- chrome
- github
- 부경대 맛집
- 태국지도
- 태국여행준비물
- 깃
- chart
- 크롬
- 여행지도
- 경성대 맛집
- 태국 여행정보
- 소프트웨어
- SDK
- 삼성소프트웨어멤버십
- 태국여행
- Android
- 맛집
- 깃허브
- 갤럭시 노트
- c#
- 갤럭시 노트 해외판
- Tizen
- 서면 맛집
- 자바
- 타이젠
- 일정관리
- git
- Today
- 0
- Total
- 211,887
DREAM IT, WISH IT, DO IT
MS Chart 를 이용한 실시간 그래프 그리기 본문
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
Using System.IO.Ports;
namespace LineChartTEST
{
public partial class Form1 : Form
{
private delegate void CanIJust();
private List<int> _valueList;
private List<double>_timeList;
private List<int> _customValueList;
string InputData = String.Empty;
delegate void SetTextCallback(string text);
SerialPort SP = new SerialPort();
public Form1()
{
InitializeComponent();
_valueList = new List<int>();
_timeList = new List<double>();
_customValueList = new List<int>();
SP.PortName = "COM9";
SP.BaudRate = 115200;
SP.DataBits = 8;
SP.Parity = Parity.None;
SP.StopBits = StopBits.One;
SP.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
SP.Open();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);}
private void UpdateSecondChart()
{
chart.Series[0].Points.AddXY(_timeList[_timeList.Count - 1], _customValueList[_customValueList.Count - 1]);
chart.Series[0].IsValueShownAsLabel = true;
chart.Legends[0].Enabled = false;
chart.Invalidate();}
private void btnClear_Click(object sender, EventArgs e)
{
chart.Series[0].Points.Clear();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
InputData = SP.ReadExisting();
if (InputData != String.Empty)
{
if(InputData.Length > 4)
{
if (String.Compare(InputData.Substring(1, 2), "P") == 0 || String.Compare(InputData, "P")== 0)
{
SP.WriteLine("K");
}
}
else if (String.Compare(InputData, "P")== 0)
{
}
else
{
if (InputData.Length >= 2)
{
SetText(InputData.Substring(0, InputData.Length - 1));
}
else
{
}
}
}
}
private void SetText(string text)
{
if (this.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
_customValueList.Add(Convert.ToInt32(text));
UpdateSecondChart();
}
}
private void button_Click(object sender, EventArgs e)
{
if (SP.IsOpen)
SP.WriteLine("K");
else
MessageBox.Show("Serial port is closed!");
}
}
}
'Programming > C#' 카테고리의 다른 글
| [C#] WPF 아이콘 트레이에 숨기고 열기 (0) | 2013.03.20 |
|---|---|
| [C#] JSON 이용하기. (0) | 2013.03.20 |
| [C#] string to byte[] 변환하기 (0) | 2013.03.20 |
| [C#] FormBorderStyle -> None 상태에서 드래그로 움직이기 (0) | 2013.03.09 |
| MS Chart 를 이용한 실시간 그래프 그리기 (2) | 2012.06.01 |
| MS Chart (C#으로 차트 그리기) (0) | 2012.06.01 |
-
Timberland shops
2012.12.24 12:58
You should always remember to label both each individual ski, http://www.timberlandbaratas.com Mujer Timberland, so to ensure your skis meet you at the other side, http://www.timberlandbaratas.com outlet timberland, They started a number of domestic airline flights as well as to the various important cities of the world, http://www.timberlandbaratas.com Hombre Timberland.One excellent strategy is to simply put your laptop in a secure protected case and put it in the hold it makes sense to put in in your luggage that will got in the cargo hold, http://www.timberlandbaratas.com barato timberland.
Related articles:
http://philkant.tistory.com/396 http://philkant.tistory.com/396
http://parentvine.net/forums/topic/luxury-transport-service-is-because-he-is-under-along-with-e#post- http://parentvine.net/forums/topic/luxury-transport-service-is-because-he-is-under-along-with-e#post-
http://losermarxdr.tistory.com/937 http://losermarxdr.tistory.com/937 -
요원009 2015.12.23 07:47 신고 http://yowon009.tistory.com/107
링크 바꼈습니다.