Initialization of the custom RfidEventHandler

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

 

One custom event handler is the peace of code (assembly) which is loaded onto RFID-stack of the Microsoft RFID infrastructure and executed each time one Tag (or some other sensor data) enters the processing pipeline on the stack.

 

The EventHandler has to implement the interface RfidEventHandlerBase and one static method GetParameterMetaData().

 

The method GetParameterMetaData() is called by the Rfid infrastructure when the definition of the configuration metadata is required. The example bellow shows how to define the parameter with name “WsUrlKey” of type string.

When the event handler is initializing all defined should be initialize. The right place for initialization is the method

 

public override void Init(Dictionary<string, object> parameters, RfidProcessContext container)

 

Example:

 

Assume, the method GetParameterMetaData() defines two parameters Par1 and Par2.

The parameter Par1 has default value 100 and Parameter Par2 has default value 200.

When the event habdler is bounded on the process in Rfid-MMC both parameters are set on default values.

 

Each time the administrator selects the evant-handler node or the process is started the method Init is called. If no any of parameters Par1 and Par2 has been changed by administrator, the arument Dictionary<string, object> parameters list will be emoty. If one parameter has been set on some other value than default one, then this list will contain one parameter only.

 

Following example shows in general how to initializes the event handler. Pleae note that the argument 'parameters' contains only the list of value which are different than default value. That means this argument will contain only values changed by an administrator.

 

public static Dictionary<string, ParameterMetaData> GetParameterMetaData()

        {

            lock (typeof(MyEvent))

            {

                if (m_Metadata == null)

                {

                    m_Metadata = new Dictionary<string, ParameterMetaData>();

                    m_Metadata.Add(“WsUrlKey”, new ParameterMetaData(typeof(string), "The Url of the webservice hosting the the workflow.", WsUrlDefault));                  

                }

 

                return m_Metadata;

            }

        }

 

   public override void Init(Dictionary<string, object> parameters, RfidProcessContext container)

        {

            if (parameters != null && parameters.ContainsKey(WsUrlKey))

            {

                this.m_WsUrl = (string)parameters[WsUrlKey];

            }           

            else

            {

                this.m_WsUrl = WsUrlDefault;

            }

        }

 

Note that all information in this article are related to the RFID Infrastructure BETA 1.

Damir Dobric


Posted Apr 05 2006, 11:30 AM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.