Exemple #1
0
 bool readFromFile()
 {
     try {
         GlobalData.listMasterData = new List <masterinformation>();
         if (File.Exists(_file) == false)
         {
             return(false);
         }
         var lines = File.ReadLines(_file);
         foreach (var line in lines)
         {
             if (!line.Contains("Channel"))
             {
                 string[]          buffer = line.Split(',');
                 masterinformation mf     = new masterinformation()
                 {
                     Channel   = buffer[0],
                     Frequency = buffer[1],
                     pwAnten1  = buffer[2],
                     pwAnten2  = buffer[3]
                 };
                 GlobalData.listMasterData.Add(mf);
             }
         }
         return(true);
     }
     catch {
         return(false);
     }
 }
Exemple #2
0
        public static bool Save()
        {
            try {
                if (GlobalData.autoAttenuator == null || GlobalData.autoAttenuator.Count == 0)
                {
                    return(true);
                }
                StreamWriter st     = new StreamWriter(fileName);
                string       _title = "ChannelNumber,ChannelFreq (Hz),Anten1-Attenuator (dBm),Anten2-Attenuator (dBm)";
                st.WriteLine(_title);

                //1,2412,1,9.45
                //1.2412,2,8.54
                //tach list ban dau ra lam 2 list at1 va list at2
                List <autoattenuator> _li1 = new List <autoattenuator>();
                List <autoattenuator> _li2 = new List <autoattenuator>();
                foreach (var item in GlobalData.autoAttenuator)
                {
                    if (item.Anten == "1")
                    {
                        _li1.Add(item);
                    }
                    else
                    {
                        _li2.Add(item);
                    }
                }

                //add du lieu vao list attenuator
                List <masterinformation> _liAttenuator = new List <masterinformation>();
                for (int i = 0; i < _li1.Count; i++)
                {
                    masterinformation mf = new masterinformation()
                    {
                        Channel = _li1[i].Channel, Frequency = _li1[i].Frequency, pwAnten1 = _li1[i].Attenuator, pwAnten2 = _li2[i].Attenuator
                    };
                    _liAttenuator.Add(mf);
                }

                //ghi du lieu vao file
                foreach (var item in _liAttenuator)
                {
                    st.WriteLine(item.ToString());
                }

                st.Dispose();
                return(true);
            } catch {
                return(false);
            }
        }
Exemple #3
0
        public static bool Save()
        {
            try {
                if (GlobalData.autoCalculateMaster == null || GlobalData.autoCalculateMaster.Count == 0)
                {
                    return(true);
                }
                string       fileName = string.Format("{0}tmpMaster\\Master_{1}_{2}.csv", System.AppDomain.CurrentDomain.BaseDirectory, DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"));
                StreamWriter st       = new StreamWriter(fileName);
                string       _title   = "Channel,Freq,Anten1,Anten2";
                st.WriteLine(_title);

                //1,2412,1,9.45
                //1.2412,2,8.54
                //tach list ban dau ra lam 2 list at1 va list at2
                List <masterinformation> _li1 = new List <masterinformation>();
                List <masterinformation> _li2 = new List <masterinformation>();
                foreach (var item in GlobalData.autoCalculateMaster)
                {
                    if (item.Anten == "1")
                    {
                        masterinformation _mi = new masterinformation()
                        {
                            Channel = item.Channel, Frequency = item.Frequency, pwAnten1 = item.masterPower
                        };
                        _li1.Add(_mi);
                    }
                    else
                    {
                        masterinformation _mi = new masterinformation()
                        {
                            Channel = item.Channel, Frequency = item.Frequency, pwAnten2 = item.masterPower
                        };
                        _li2.Add(_mi);
                    }
                }

                //add du lieu vao list attenuator
                List <masterinformation> _liMaster = new List <masterinformation>();
                for (int i = 0; i < _li1.Count; i++)
                {
                    masterinformation mf = new masterinformation()
                    {
                        Channel = _li1[i].Channel, Frequency = _li1[i].Frequency, pwAnten1 = _li1[i].pwAnten1, pwAnten2 = _li2[i].pwAnten2
                    };
                    _liMaster.Add(mf);
                }

                //ghi du lieu vao file
                foreach (var item in _liMaster)
                {
                    st.WriteLine(item.ToString());
                }

                st.Dispose();
                return(true);
            }
            catch {
                return(false);
            }
        }