Example #1
0
        /// <summary>
        /// ReadFunction for configlist
        /// </summary>
        /// <returns></returns>
        public static List <ConfigurationVO> ReadconfigCsvfile()
        {
            List <ConfigurationVO> Configlist = new List <ConfigurationVO>();

            try
            {
                string filePath = Assembly.GetExecutingAssembly().Location;
                int    position = filePath.LastIndexOf('\\');
                filePath  = filePath.Remove(position);
                filePath += EnumAndConstants.CONFIGURATION_FILE;

                StreamReader reader = new StreamReader(File.OpenRead(filePath));
                while (!reader.EndOfStream)
                {
                    string[] line = reader.ReadLine().Split(',');
                    if (line[0] == "")
                    {
                        continue;
                    }
                    if (line[0].Equals("T1"))
                    {
                        continue;
                    }


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

                    config.mode_operation = Convert.ToInt32(line[11]);
                    config.adcresolution  = Convert.ToInt32(line[12]);
                    config.sampaling_rate = Convert.ToInt32(line[13]);
                    config.ChannelValue   = Convert.ToUInt16(line[14]);
                    config.T5VDAC         = Convert.ToUInt16(line[15]);
                    config.T7VDAC         = Convert.ToUInt16(line[16]);
                    Configlist.Add(config);
                }
                reader.Close();
                return(Configlist);
            }
            catch (Exception ex)
            {
                m_logger.Error(ex);
                return(Configlist);
            }
        }
Example #2
0
        /// <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);
            }
        }