예제 #1
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);
            }
        }