コード例 #1
0
        /// <summary>
        /// Returns a clsSettings object, loaded from a specific location
        /// </summary>
        public appSettings Load()
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CSLReader";

            try
            {
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }
            }
            catch (Exception ex)
            {
            }

            string mac = path + "\\" + Program.SerialNumber.Replace(':', '.') + ".cfg";
            // Constructs an instance of the XmlSerializer with the type
            // of object that is being deserialized.
            XmlSerializer mySerializer = new XmlSerializer(typeof(appSettings));
            // To read the file, creates a FileStream.
            FileStream myFileStream = new FileStream(mac, FileMode.Open);
            // Calls the Deserialize method and casts to the object type.
            appSettings pos = (appSettings)mySerializer.Deserialize(myFileStream);

            myFileStream.Close();
            return(pos);
        }
コード例 #2
0
        /// <summary>
        /// Returns a clsSettings object, loaded from a specific location
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public appSettings Load(string fileName)
        {
            // Constructs an instance of the XmlSerializer with the type
            // of object that is being deserialized.
            XmlSerializer mySerializer = new XmlSerializer(typeof(appSettings));
            // To read the file, creates a FileStream.
            FileStream myFileStream = new FileStream(fileName, FileMode.Open);
            // Calls the Deserialize method and casts to the object type.
            appSettings pos = (appSettings)mySerializer.Deserialize(myFileStream);

            myFileStream.Close();
            return(pos);
        }
        public static void LoadSettings()
        {
            appSetting = appSetting.Load();

            //Previous save config not match
            if (appSetting.MAC_ADDRESS != MAC)
                return;

            //Apply previous configuration
            if (ReaderXP.SetPowerLevel(appSetting.Power) != Result.OK)
            {
                MessageBox.Show(String.Format("SetPowerLevel rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }
            if (ReaderXP.SetCurrentLinkProfile(appSetting.Link_profile) != Result.OK)
            {
                MessageBox.Show(String.Format("SetCurrentLinkProfile rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }
            if (appSetting.FixedChannel)
            {
                if (ReaderXP.SetFixedChannel(appSetting.Region, appSetting.Channel_number, appSetting.Lbt ? LBT.ON : LBT.OFF) != Result.OK)
                {
                    MessageBox.Show(String.Format("SetFixedChannel rc = {0}", ReaderXP.LastResultCode));
                    Application.Exit();
                    return;
                }
            }
            else
            {
                if (ReaderXP.SetHoppingChannels(appSetting.Region) != Result.OK)
                {
                    MessageBox.Show(String.Format("SetHoppingChannels rc = {0}", ReaderXP.LastResultCode));
                    Application.Exit();
                    return;
                }
            }
            if (ReaderXP.SetSingulationAlgorithmParms(appSetting.Singulation, appSetting.SingulationAlg) != Result.OK)
            {
                MessageBox.Show(String.Format("SetSingulationAlgorithmParms rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }
        }
コード例 #4
0
        public static void LoadSettings()
        {
            appSetting.AntennaList = AntennaList.DEFAULT_ANTENNA_LIST;
            appSetting.AntennaList.Clear();
            appSetting = appSetting.Load();

            //Previous save config not match
            if (appSetting.SerialNum != SerialNumber)
            {
                return;
            }

            if (ReaderXP.SetCurrentLinkProfile(appSetting.Link_profile) != Result.OK)
            {
                MessageBox.Show(String.Format("SetCurrentLinkProfile rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }

            if (appSetting.FixedChannel)
            {
                if (appSetting.FreqAgile == false)
                {
                    if (ReaderXP.SetFixedChannel(appSetting.Region, appSetting.Channel_number, appSetting.Lbt ? LBT.ON : LBT.OFF) != Result.OK)
                    {
                        MessageBox.Show(String.Format("SetFixedChannel rc = {0}", ReaderXP.LastResultCode));
                        Application.Exit();
                        return;
                    }
                }
                else
                {
                    if (ReaderXP.SetAgileChannels(appSetting.Region) != Result.OK)
                    {
                        MessageBox.Show(String.Format("SetAgileChannel rc = {0}", ReaderXP.LastResultCode));
                        Application.Exit();
                        return;
                    }
                }
            }
            else
            {
                if (ReaderXP.SetHoppingChannels(appSetting.Region) != Result.OK)
                {
                    MessageBox.Show(String.Format("SetHoppingChannels rc = {0}", ReaderXP.LastResultCode));
                    Application.Exit();
                    return;
                }
            }
            if (ReaderXP.SetSingulationAlgorithmParms(appSetting.Singulation, appSetting.SingulationAlg) != Result.OK)
            {
                MessageBox.Show(String.Format("SetSingulationAlgorithmParms rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }

            if (appSetting.AntennaList == null)
            {
                ReaderXP.AntennaList = AntennaList.DEFAULT_ANTENNA_LIST;
            }
            else
            {
                ReaderXP.AntennaList.Copy(appSetting.AntennaList);
            }

            if (appSetting.AntennaList.Store(ReaderXP) != Result.OK)
            {
                MessageBox.Show(String.Format("SetAntennaList rc = {0}", ReaderXP.LastResultCode));
                Application.Exit();
                return;
            }

            if (appSetting.AntennaSequenceMode == AntennaSequenceMode.SEQUENCE ||
                appSetting.AntennaSequenceMode == AntennaSequenceMode.SEQUENCE_SMART_CHECK)
            {
                ReaderXP.AntennaSequenceSize = appSetting.AntennaSequenceSize;
                ReaderXP.AntennaSequenceMode = appSetting.AntennaSequenceMode;
                Array.Copy(appSetting.AntennaPortSequence, 0, ReaderXP.AntennaPortSequence, 0, appSetting.AntennaPortSequence.Length);
                if (ReaderXP.SetAntennaSequence(ReaderXP.AntennaPortSequence, ReaderXP.AntennaSequenceSize, ReaderXP.AntennaSequenceMode) != Result.OK)
                {
                    MessageBox.Show(String.Format("SetAntennaSequence rc = {0}", ReaderXP.LastResultCode));
                    Application.Exit();
                    return;
                }
            }
            else
            {
                ReaderXP.AntennaSequenceSize = 0;
                ReaderXP.SetAntennaSequence((int)ReaderXP.AntennaSequenceSize);
            }
        }