RFID.RFIDInterface.Source_FrequencyBand.load C# (CSharp) Method

load() public method

public load ( rfid transport, UInt32 readerHandle ) : rfid.Constants.Result
transport rfid
readerHandle System.UInt32
return rfid.Constants.Result
        public rfid.Constants.Result load(
            rfid.Linkage transport,
            UInt32       readerHandle
        )
        {
            UInt32 config            = 0;
            UInt32 multdiv           = 0;
            UInt32 pllcc             = 0;

            rfid.Constants.Result result = transport.API_ConfigWriteRegister
            (
                SELECTOR_ADDRESS,
                this.band
            );

            if ( rfid.Constants.Result.OK != result )
            {
                return result;
            }

            result = transport.API_ConfigReadRegister
            (
                CONFIG_ADDRESS,
                ref config
            );

            if ( rfid.Constants.Result.OK != result )
            {
                return result;
            }

            result = transport.API_ConfigReadRegister
            (
                MULTDIV_ADDRESS,
                ref multdiv
            );

            if ( rfid.Constants.Result.OK != result )
            {
                return result;
            }

            result = transport.API_ConfigReadRegister
            (
                PLLCC_ADDRESS,
                ref pllcc
            );

            if ( rfid.Constants.Result.OK != result )
            {
                return result;
            }

            try
            {
                this.state = ( BandState ) ( config == 0 ? 0 : 1 );
            }
            catch ( Exception )
            {
                this.state = BandState.UNKNOWN;
            }

            this.multiplier   = ( UInt16 ) ( ( multdiv >> 0  ) & 0xffff );
            this.divider      = ( UInt16 ) ( ( multdiv >> 16 ) & 0xff   );

            this.minDACBand   = ( UInt16 ) ( ( pllcc >> 0  ) & 0xff );
            this.affinityBand = ( UInt16 ) ( ( pllcc >> 8  ) & 0xff );
            this.maxDACBand   = ( UInt16 ) ( ( pllcc >> 16 ) & 0xff );
            this.guardBand    = ( UInt16 ) ( ( pllcc >> 24 ) & 0xff );

            return rfid.Constants.Result.OK;
        }

Usage Example

Example #1
0
        private void okButton_Click( object sender, EventArgs e )
        {
            rfid.Constants.Result result =
                rfid.Constants.Result.OK;

            try
            {
                result = this.channelActive.store( LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle );
            }
            catch ( Exception exp )
            {
                MessageBox.Show( "Reader Error.\n\nAn error occurred while updating the frequency channel settings.\n\nThe follow error occurred: " + exp.Message, "RF Frequency Band Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            if ( rfid.Constants.Result.OK != result )
            {
                MessageBox.Show( "Reader Error.\n\nThe Reader was unable to configure the specified frequency channel settings.\n\nThe follow error occurred: " + result.ToString( ), "RF Frequency Band Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            // Need to retrieve the affinityBand value since potentially
            // modified by the radio during set operation(s)

            Source_FrequencyBand channelUpdated = new Source_FrequencyBand( channelActive.Band );

            try
            {
                 result = channelUpdated.load( LakeChabotReader.MANAGED_ACCESS, this.reader.ReaderHandle );
            }
            catch ( Exception exp )
            {
                MessageBox.Show( "Reader Error.\n\nAn error occurred while retrieving updated frequency channel information.\n\nThe follow error occurred: " + exp.Message, "RF Frequency Band Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            if ( rfid.Constants.Result.OK != result )
            {
                MessageBox.Show( "Reader Error.\n\nThe Reader was unable to configure the specified frequency channel settings.\n\nThe follow error occurred: " + result.ToString( ), "RF Frequency Band Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
                return;
            }

            this.channelMaster.Copy( this.channelActive );

            DialogResult = DialogResult.OK;
        }