public static void CreateCsvArrayListVersion2(ArrayList config, string csvNameWithExt, int ChannelOne, int ChannelTwo, bool CreateNew)
        {
            if (config == null || config.Count == 0)
            {
                return;
            }

            List <ConfigurationVO> configList = (List <ConfigurationVO>)config[0];
            int channel = configList[0].channel;

            string newLine   = Environment.NewLine;
            bool   isNewFile = false;

            if (savefile == false)
            {
                isNewFile = true;
                if (File.Exists(csvNameWithExt))
                {
                    File.Delete(csvNameWithExt);
                }
            }
            else
            {
                if (!Directory.Exists(Path.GetDirectoryName(csvNameWithExt)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(csvNameWithExt));
                }
                if (!File.Exists(csvNameWithExt) && CreateNew == true)
                {
                    isNewFile = true;
                }

                if (File.Exists(csvNameWithExt) && CreateNew == false)
                {
                    isNewFile = false;
                }
                if (File.Exists(csvNameWithExt) && CreateNew == true)
                {
                    isNewFile = true;
                }
            }

            using (StreamWriter sw = new StreamWriter(csvNameWithExt, true))
            {
                StringBuilder sb = null;

                sb = new StringBuilder();
                if (isNewFile)
                {
                    for (int j = 1; j <= 10; j++)
                    {
                        sb.Append("T" + j);
                        sb.Append(",");
                    }
                    sb.Append("CHANNEL_VALUE");
                    sb.Append(",");
                    sb.Append("MODE_OPERATION");
                    sb.Append(",");
                    sb.Append("ADCRESOLUTION");
                    sb.Append(",");
                    sb.Append("SAMPALING_RATE");
                    sb.Append(",");
                    sb.Append("T5_VDAC_VALUE");
                    sb.Append(",");
                    sb.Append("T7_VDAC_VALUE");
                    sb.Append(",");
                    sb.Append("\n");

                    ConfigurationVO ConfigVO = configList[0];
                    if (ConfigVO == null)
                    {
                        return;
                    }
                    sb.Append(ConfigVO.T1);
                    sb.Append(",");
                    sb.Append(ConfigVO.T2);
                    sb.Append(",");
                    sb.Append(ConfigVO.T3);
                    sb.Append(",");
                    sb.Append(ConfigVO.T4);
                    sb.Append(",");
                    sb.Append(ConfigVO.T5);
                    sb.Append(",");
                    sb.Append(ConfigVO.T6);
                    sb.Append(",");
                    sb.Append(ConfigVO.T7);
                    sb.Append(",");
                    sb.Append(ConfigVO.T8);
                    sb.Append(",");
                    sb.Append(ConfigVO.T9);
                    sb.Append(",");
                    sb.Append(ConfigVO.T10);
                    sb.Append(",");

                    sb.Append(ConfigVO.ChannelValue);
                    sb.Append(",");
                    sb.Append(ConfigVO.mode_operation);
                    sb.Append(",");
                    sb.Append(ConfigVO.adcresolution);
                    sb.Append(",");
                    sb.Append(ConfigVO.sampaling_rate);
                    sb.Append(",");
                    sb.Append(ConfigVO.T5VDAC);
                    sb.Append(",");
                    sb.Append(ConfigVO.T7VDAC);

                    sb.Append("\n");
                    sw.WriteLine(sb.ToString());
                }
                //Add Adcvalues
                sb = sb.Remove(0, sb.Length);
                sb.Append("Channel ");
                sb.Append(",");
                sb.Append(ChannelOne);
                sb.Append("\n");
                sb.Append("ADC Value");
                sb.Append(",");
                sb.Append("Date");
                sb.Append("\n");
                List <ADCVO> AdcCollection = null;
                AdcCollection = (List <ADCVO>)config[1];
                if (AdcCollection == null || AdcCollection.Count == 0)
                {
                    return;
                }

                for (int iterator = 0; iterator < AdcCollection.Count; iterator++)
                {
                    ADCVO AdcVo = AdcCollection.ElementAt(iterator);
                    if (AdcVo == null)
                    {
                        continue;
                    }
                    sb.Append(AdcVo.AdcValue);
                    sb.Append(",");
                    sb.Append(AdcVo.AdcDate.Ticks);
                    sb.Append("\n");
                }
                sw.WriteLine(sb.ToString());
                sb = sb.Remove(0, sb.Length);
                // both channels
                if (config.Count > 2)
                {
                    AdcCollection = (List <ADCVO>)config[2];
                    sb.Append("Channel ");
                    sb.Append(",");
                    sb.Append(ChannelTwo);
                    sb.Append("\n");
                    sb.Append("ADC Value");
                    sb.Append(",");
                    sb.Append("Date");
                    sb.Append("\n");
                    for (int iterator = 0; iterator < AdcCollection.Count; iterator++)
                    {
                        ADCVO AdcVo = AdcCollection.ElementAt(iterator);
                        if (AdcVo == null)
                        {
                            continue;
                        }
                        sb.Append(AdcVo.AdcValue);
                        sb.Append(",");
                        sb.Append(AdcVo.AdcDate.Ticks);
                        sb.Append("\n");
                    }
                    sw.WriteLine(sb.ToString());
                }
            }
        }
        /// <summary>
        /// Read ConfigList and ADCList
        /// </summary>
        /// <returns></returns>

        public static ArrayList ReadconfigadcCsvfile(string filePath)
        {
            ArrayList list = new ArrayList();
            List <ConfigurationVO> Configcollection      = new List <ConfigurationVO>();
            List <ADCVO>           adccollection         = new List <ADCVO>();
            List <ADCVO>           adccollectionchannel2 = new List <ADCVO>();

            try
            {
                StreamReader reader      = new StreamReader(File.OpenRead(filePath));
                int          Case_Number = 0;
                int          channel_Ref = 0;
                int          channelA    = 0;
                int          channelB    = 0;

                while (!reader.EndOfStream)
                {
                    string[] line = reader.ReadLine().Split(',');
                    if (line[0] == "")
                    {
                        continue;
                    }
                    if (line[0].Equals("T1"))
                    {
                        Case_Number = 1;
                        continue;
                    }
                    else if (line[0].Equals("Channel"))
                    {
                        //if (line[0].Equals("Channel 1"))
                        if (channelA == 0)
                        {
                            channelA = int.Parse(line[1]);
                        }
                        else
                        {
                            channelB = int.Parse(line[1]);
                        }
                        //else if (line[0].Equals("Channel 2"))
                        // channel = 2;
                        Case_Number = 2;
                        continue;
                    }

                    switch (Case_Number)
                    {
                    case 1:
                        ConfigurationVO config = ConfigurationVO.GetInstance();
                        config.T1  = Convert.ToInt32(line[0]) / EnumAndConstants.COMMON_FACTOR;
                        config.T2  = Convert.ToInt32(line[1]) / EnumAndConstants.COMMON_FACTOR;
                        config.T3  = Convert.ToInt32(line[2]) / EnumAndConstants.COMMON_FACTOR;
                        config.T4  = Convert.ToInt32(line[3]) / EnumAndConstants.COMMON_FACTOR;
                        config.T5  = Convert.ToInt32(line[4]) / EnumAndConstants.COMMON_FACTOR;
                        config.T6  = Convert.ToInt32(line[5]) / EnumAndConstants.COMMON_FACTOR;
                        config.T7  = Convert.ToInt32(line[6]) / EnumAndConstants.COMMON_FACTOR;
                        config.T8  = Convert.ToInt32(line[7]) / EnumAndConstants.COMMON_FACTOR;
                        config.T9  = Convert.ToInt32(line[8]) / EnumAndConstants.COMMON_FACTOR;
                        config.T10 = Convert.ToInt32(line[9]) / EnumAndConstants.COMMON_FACTOR;

                        //channel_Ref = config.channel;
                        config.ChannelValue   = Convert.ToUInt16(line[10]);
                        config.mode_operation = Convert.ToInt32(line[11]);
                        config.adcresolution  = Convert.ToInt32(line[12]);
                        config.sampaling_rate = Convert.ToInt32(line[13]);

                        config.T5VDAC = Convert.ToUInt16(line[14]);
                        config.T7VDAC = Convert.ToUInt16(line[15]);
                        Configcollection.Add(config);
                        break;

                    case 2:
                        if (line[0].Equals("ADC Value") || line[0].Equals("Channel 2"))
                        {
                            continue;
                        }

                        ADCVO adcvo = new ADCVO();
                        adcvo.AdcValue = int.Parse(line[0]);
                        adcvo.AdcDate  = new DateTime(Convert.ToInt64(line[1]));
                        if (channelA != 0 && channelB == 0)
                        {
                            adcvo.Channel = channelA;
                            adccollection.Add(adcvo);
                        }
                        else if (channelB != 0)
                        {
                            adcvo.Channel = channelB;
                            adccollectionchannel2.Add(adcvo);
                        }
                        else
                        {
                            adccollection.Add(adcvo);
                        }
                        break;
                    }
                }
                list.Add(Configcollection);
                list.Add(adccollection);
                if (channelB != 0)
                {
                    list.Add(adccollectionchannel2);
                }
                reader.Close();
                return(list);
            }
            catch (Exception ex)
            {
                m_logger.Error(ex);
                return(list);
            }
        }