Ejemplo n.º 1
0
        private void SetDataToUI(string[] data)
        {
            if (data == null)
            {
                return;
            }

            string NA = TesterEnviorment.STR_NA;

            dataGridView1.Rows.Insert(0, data);

            string EMPTY = TesterEnviorment.STR_EMPTY;

            string strTimestamp   = TesterEnviorment.IsValidStr(data[0]) ? data[0] : EMPTY;
            string strTemperature = TesterEnviorment.IsValidStr(data[1]) ? data[1] : EMPTY;
            string strPH          = TesterEnviorment.IsValidStr(data[2]) ? data[2] : EMPTY;
            string strSalt        = TesterEnviorment.IsValidStr(data[3]) ? data[3] : EMPTY;
            string strOxgen       = TesterEnviorment.IsValidStr(data[4]) ? data[4] : EMPTY;
            string strVolt        = TesterEnviorment.IsValidStr(data[5]) ? data[5] : EMPTY;
            string strAmp         = TesterEnviorment.IsValidStr(data[6]) ? data[6] : EMPTY;

            chartTemperature.Series[0].Points.AddXY(strTimestamp, strTemperature);
            chartPH.Series[0].Points.AddXY(strTimestamp, strPH);
            chartSalt.Series[0].Points.AddXY(strTimestamp, strSalt);
            chartOxgen.Series[0].Points.AddXY(strTimestamp, strOxgen);
            chartVolt.Series[0].Points.AddXY(strTimestamp, strVolt);
            chartAmp.Series[0].Points.AddXY(strTimestamp, strAmp);
        }
Ejemplo n.º 2
0
        void OnTimeSaveToFile(object sender, EventArgs e)
        {
            if (preRecvData != null)
            {
                string[] dump = (string[])preRecvData.Clone();
                TesterEnviorment.ConvertDateTime(dump, testEnv.startTime);

                SetDataToUI(dump);
                SaveTofile(dataGridView1, testEnv.fileName, true);
            }
        }
Ejemplo n.º 3
0
        private void SetCurrentData(string[] data)
        {
            TesterEnviorment.AdjustDataStringFormat(data);

            preRecvData = data;

            textBoxData_Time.Text        = data[0];
            textBoxData_Temperature.Text = data[1];
            textBoxData_pH.Text          = data[2];
            textBoxData_Salt.Text        = data[3];
            textBoxData_Oxygen.Text      = data[4];
            textBoxData_Volt.Text        = data[5];
            textBoxData_Amp.Text         = data[6];
        }
Ejemplo n.º 4
0
        private void SendPacket()
        {
            sendCnt++;

            if (TesterEnviorment.DEBUG_MODE == 1)
            {
                //수조온도  pH농도    염도  용존산소량   음극전위    양극전류
                string[] row = { DateTime.Now.ToString(dateTimeEnd.CustomFormat), "-0023", " 0076"
                                 ,                                                "-2000", "-1234"," 0040", " 0201" };

                SetCurrentData(row);
                sendCnt--;

                if (dataGridView1.Rows.Count == 1)
                {
                    TesterEnviorment.ConvertDateTime(row, testEnv.startTime);

                    SetDataToUI(row);
                    SaveTofile(dataGridView1, testEnv.fileName, true);
                }
            }

            // 시리얼데이터 버퍼 STX 1 / LocalID 2 / ETX 1
            byte[] buffer = new byte[4];
            // Start Byte
            buffer[0] = Rs232Utils.STX;
            // Local ID
            buffer[1] = System.Text.Encoding.ASCII.GetBytes(testEnv.localId.ToCharArray())[0];
            buffer[2] = System.Text.Encoding.ASCII.GetBytes(testEnv.localValue.ToCharArray())[0];
            // End Byte
            buffer[3] = Rs232Utils.ETX;

            try
            {
                if (TesterEnviorment.DEBUG_MODE != 1)
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Write(buffer, 0, buffer.Length);
                    }
                }
            }
            catch (Exception e)
            {
            }

            DisplayStatusbarMessage(string.Format("Serial Status: {0} Send Data: {1}", sendCnt, Rs232Utils.ByteArrayToHexString(buffer)));
        }
Ejemplo n.º 5
0
        private void HandleReadData(object s, EventArgs e)
        {
            try
            {
                // 누적된 데이터를 받고
                string recieveData = recieveSB.ToString();

                if (TesterEnviorment.DEBUG_MODE == 1)
                {
                    this.RecvTextBox.AppendText(recieveData);
                    this.RecvTextBox.AppendText("\r\n");
                }

                // 누적 데이터를 없애고
                recieveSB = "";
                sendCnt   = 0;

                if (recieveData.Length <= 0)
                {
                    return;
                }

                int payloadLength = recieveData.Length;
                if (payloadLength % 5 != 0)
                {
                    return;
                }

                string   token = "";
                int      receivedTokencount = payloadLength / 5;
                string[] datas = new string[TesterEnviorment.PACKET_TOKEN_COUNT];
                if (receivedTokencount > TesterEnviorment.PACKET_TOKEN_COUNT)
                {
                    return;
                }

                for (int i = 0; i < receivedTokencount; i++)
                {
                    token += recieveData[i * 5];
                    token += recieveData[i * 5 + 1];
                    token += recieveData[i * 5 + 2];
                    token += recieveData[i * 5 + 3];
                    token += recieveData[i * 5 + 4];

                    if (token.Equals(TesterEnviorment.STR_NNNNN))
                    {
                        datas[i] = TesterEnviorment.STR_EMPTY;
                    }
                    else
                    {
                        datas[i] = token;
                    }

                    token = "";
                }

                //수조온도  pH농도    염도  용존산소량   음극전위    양극전류
                string[] row = { DateTime.Now.ToString(dateTimeEnd.CustomFormat), datas[0], datas[1]
                                 ,                                                datas[2], datas[3],datas[4], datas[5] };

                SetCurrentData(row);

                if (dataGridView1.Rows.Count == 1)
                {
                    TesterEnviorment.ConvertDateTime(row, testEnv.startTime);

                    SetDataToUI(row);
                    SaveTofile(dataGridView1, testEnv.fileName, true);
                }

                DisplayStatusbarMessage(string.Format("Serial Status: {0} RecvData: {1}", sendCnt, recieveData));
            }
            catch (Exception ex)
            {
                // 누적 데이터를 없애고
                recieveSB = "";
                sendCnt   = 0;
            }
        }
Ejemplo n.º 6
0
        private string MakeStrInvalidSettingEnum(TesterEnviorment.eRunState runState)
        {
            if (runState == TesterEnviorment.eRunState.INVALID_DELAY)
            {
                return "저장 간격이 너무 짧습니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_ENDTIME)
            {
                return "종료 일시는 시작 일시보다 길어야 합니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_LOCAL_VALUE)
            {
                return "Local value 셋팅이 안되어있습니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_LOCALID)
            {
                return "Local Id 셋팅이 안되어있습니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_TARGET)
            {
                return "저장 화일 이름이 없습니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_TARGET_LENGTH)
            {
                return "저장 화일 이름이 너무 짧습니다.";
            }
            else if (runState == TesterEnviorment.eRunState.INVALID_WORKING)
            {
                return "기록이 진행중일때는 설정을 변경할수 없습니다.";
            }

            return "";
        }