{
int iRecSize = m_sp1.BytesToRead; // 수신된 데이터 갯수
string strRxData;
string[] reData;
if (iRecSize != 0) // 수신된 데이터의 수가 0이 아닐때만 처리하자
{
strRxData = "";
byte[] buff = new
byte[iRecSize];
m_sp1.Read(buff, 0, iRecSize);
for (int iTemp = 0; iTemp < iRecSize;
iTemp++)
{
if
(chkRxHexa.Checked)
strRxData += " " +
buff[iTemp].ToString("X2");
else
strRxData +=
Convert.ToChar(buff[iTemp]);
}
try
{
Int32.TryParse(strRxData,
out result);
txtRxData.Text +=
result;
if (result >= 500
&& result <=600)
{
pictureBox6.Image = Properties.Resources.a1;
}
else if(result<=500 &&
result>=480){
pictureBox6.Image = Properties.Resources.a2;
}
else if (result<=480 &&
result>=460)
{
pictureBox6.Image =
Properties.Resources.a3;
}
현재 작성하고 있는 프로그램인데요.
센서에서 받아온 result의 값에 따라서 pictureBox에 이미지를 변경하는 프로그램입니다.
문제가 센서에서 값을 받아올때마다 이미지가빨리 변해야하는데
센서에서 데이터가 오는속도와 이미지가 변하는 속도가 너무 차이가 납니다. 이미지 바뀌는 속도가 느려서 문제입니다.
Int32.TryParse(strRxData, out result); 변환하는 부분때문에 느려지는건지 도무지 모르겠습니다.
어떻게하면 데이터받는속도에 맞게 빨리 이미지가 변하도록 만들수 있을지 도와주세요.
데이터를 받는 주기가 얼마나 되나요?
1초?
0.1초?
1초라면 이미지 출력에 속도 문제가 없을거 같고..
0.1초라면 이미지가 변경되는거 눈으로 보기도 힘들거 같은데요.....
어느 정도의 속도로 데이터를 받는지 궁금하네요.
그리고,
Int32.TryParse(strRxData, out result); 에서 속도가 의심된다면...
Int32.TryParse(strRxData, out result); 대신에
result = 590;// 으로 초기값을 두고
if(result == 590 ) result = 490;
else if(result == 490 ) result = 470;
else if(result == 470 ) result = 590;
로 변경하여 테스트 하시면 될겁니다.~