string GetResult(ParaResult re)
 {
     if (re.para_result == ParaStatus.NotAvailable)
     {
         return "-";
     }
     else if ((re.para_result == ParaStatus.Warning))
     {
         return re.para_value.ToString() + "(Warning: Out of range)";
     }
     else
     {
         return re.para_value.ToString();
     }
 }
 string GetStatus(ParaResult re)
 {
     if (re.para_result == ParaStatus.NotAvailable)
     {
         return "Not Connected";
     }
     else if ((re.para_result == ParaStatus.Warning))
     {
         return "Warning: Voltage out of range";
     }
     else
     {
         return "OK";
     }
 }
        public void Receive(string strInput)
        {
            // only receive data match address
            if (strInput.StartsWith(sAddr))
            {
                string[] split_data = strInput.Split(' ');

                List<string> data = new List<string>();

                foreach (string str in split_data)
                {
                    if(!String.IsNullOrEmpty(str))
                    {
                        data.Add(str);
                    }
                }

                if (data.Count >= 4)
                {
                    tTimeout.Enabled = false;
                    eDataStatus = DataStatus.Available;
                    if (data.Contains("="))  //diagnostic data or calibration data
                    {
                        int parse_index;

                        try{
                            parse_index = Int32.Parse(data[1]);
                        }
                        catch
                        {
                            parse_index = 0;
                        }

                        for (int i = 0; i < iParaCount; i++)
                        {
                            if (parse_index == iParaIndex[i])
                            {
                                int out_value = 0;

                                bool IsGetValue = true;
                                try
                                {
                                    out_value = Int32.Parse(data[3]);
                                }
                                catch
                                {
                                    IsGetValue = false;
                                }

                                if (IsGetValue)
                                {
                                    ParaResult result = new ParaResult();

                                    if (out_value >= iLowerLimit[i] && out_value <= iUpperLimit[i])
                                    {
                                        result.para_result = ParaStatus.Pass;
                                        result.para_value = out_value;
                                    }
                                    else
                                    {
                                        result.para_result = ParaStatus.Warning;
                                        result.para_value = out_value;
                                    }

                                    iParaResult[i] = result;

                                    if (parse_index == 76)
                                    {
                                        this.sSerialNum = result.para_value.ToString();
                                    }
                                }

                            }
                        }
                    }

                    if (data.Count >= 5) // regular data
                    {

                        for (int i = 1; i < 5; i++)
                        {
                            double out_value = 0.0;

                            try
                            {
                                out_value = Double.Parse(data[i]);
                            }
                            catch
                            {
                                out_value = 0;
                            }

                            if (out_value >= dRegLowLimit[i-1] && out_value <= dRegUpLimit[i-1])
                            {
                                iRegResult[i-1].para_result = ParaStatus.Pass;
                                iRegResult[i-1].para_value = out_value;
                            }
                            else
                            {
                                iRegResult[i-1].para_result = ParaStatus.Warning;
                                iRegResult[i-1].para_value = out_value;
                            }

                            switch (i)
                            {
                                case 1:
                                    dPressure = out_value;
                                    break;
                                case 2:
                                    dTemp = out_value;
                                    break;
                                case 3:
                                    dVolFlowRate = out_value;
                                    break;
                                case 4:
                                    dPreMassFlowRate = dMassFlowRate;
                                    dMassFlowRate = out_value;
                                    break;
                            }

                        }
                    }

                }

            }
        }