Ejemplo n.º 1
0
        public rfid.Constants.Result store(
            rfid.Linkage transport,
            UInt32                             readerHandle
        )
        {
            UInt32 config    = ( UInt32 ) state;
            UInt32 multdiv   = ( UInt32 ) ( this.divider      << 16 ) | ( UInt32 ) this.multiplier;
            UInt32 pllcc     = ( UInt32 ) ( this.guardBand    << 24 ) |
                               ( UInt32 ) ( this.maxDACBand   << 16 ) |
                               ( UInt32 ) ( this.affinityBand << 8  ) |
                               ( UInt32 ) ( this.minDACBand         ) ;

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

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

            result = transport.API_ConfigWriteRegister
            (
                CONFIG_ADDRESS,
                config
            );

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

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

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

            if ( BandState.ENABLED == ( BandState ) config )
            {
                result = transport.API_ConfigWriteRegister
                (
                    MULTDIV_ADDRESS,
                    multdiv
                );

                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_ConfigWriteRegister
                (
                    PLLCC_ADDRESS,
                    pllcc
                );

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

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

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

            }

            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;
        }
Ejemplo n.º 2
0
        // Grabs the values on board for the specified algorithm but leaves
        // board in original state - warning - MANY POINTS OF FAILURE - you
        // have been warned.
        public rfid.Constants.Result loadForAlgorithm(
            rfid.Linkage                        transport,
            UInt32                              readerHandle,
            rfid.Constants.SingulationAlgorithm algorithm
        )
        {
            // Need to do lower level register manipulation for this one...

            UInt32 reg_0x0901 = 0;

            Result result = Result.OK;

            try
            {
                // Set the algo on the board ~ maintaining all other fields

                result = transport.API_ConfigReadRegister
                (
                    ( UInt16 ) 0x0901, ref reg_0x0901
                );

                if ( rfid.Constants.Result.OK != result )
                {
                    throw new Exception( result.ToString( ) );
                }

                result = transport.API_ConfigWriteRegister
                (
                    ( UInt16 ) 0x0901, ( reg_0x0901 & 0xFFFFFFC0 ) | ( UInt32 ) algorithm
                );

                if ( rfid.Constants.Result.OK != result )
                {
                    throw new Exception( result.ToString( ) );
                }

                // Set for the algo register bank on the board

                result = transport.API_ConfigWriteRegister
                (
                    ( UInt16 ) 0x0902, ( UInt32 ) algorithm
                );

                if ( rfid.Constants.Result.OK != result )
                {
                    throw new Exception( result.ToString( ) );
                }

                result = this.load( transport, readerHandle );

                if ( rfid.Constants.Result.OK != result )
                {
                    throw new Exception( result.ToString( ) );
                }

                // Restore algo bank reg to original value

                result = transport.API_ConfigWriteRegister
                (
                    ( UInt16 ) 0x0901, reg_0x0901
                );

                if ( rfid.Constants.Result.OK != result )
                {
                    throw new Exception( result.ToString( ) );
                }

            }
            catch ( Exception )
            {
                // NOP - let fall thru to result check & msg display
            }

            // If we did ok, our source for the underlying singulation
            // parameters must also now be changed here AND grabbed at
            // the gui level ...

            if ( Result.OK == result )
            {
                switch( algorithm )
                {
                    case SingulationAlgorithm.FIXEDQ:
                    {
                        sourceParameters = new Source_SingulationParametersFixedQ
                            (
                                ( rfid.Structures.FixedQParms ) this.nativeSingulationParms
                            );
                    }
                    break;

                    case SingulationAlgorithm.DYNAMICQ:
                    {
                        sourceParameters = new Source_SingulationParametersDynamicQ
                            (
                                ( rfid.Structures.DynamicQParms ) this.nativeSingulationParms
                            );
                    }
                    break;

                    default:
                        Console.WriteLine( "ERR : Algorithm.Copy( Source_QueryParms from )" );

                    break;
                };
            }

            return result;
        }
Ejemplo n.º 3
0
        // Load frequency info, actually does Nx calls - any
        // of which may fail and cause an error return
        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;
        }