Export (0) Print
Expand All

Step 2: Modify the Provider to Support Printing a Tag

To support printing a tag by using the TutorialProvider provider, you add code to the SendMessage method of the MyPhysicalDeviceProxy class to recognize the PrintTagCommand command, create an XML request for the simulator, and send the request to the simulator.

The TutorialProvider provider communicates with the TutorialDevice simulator by using a custom XML protocol. Here is a sample XML command message that the provider can send to the TutorialDevice simulator to print a tag:

    <Command>
        <Name>PrintTag</Name>
        <TagID>AQEBAQ==</TagID>
        <VendorData>
            <ItemID>ITM1234</ItemID>
            <PONumber>PO123456</PONumber>
    </VendorData>
</Command>

You must complete Step 1: Modify the Translator to Support Printing a Tag before performing this step.

You perform the following procedure in this step.

 

Procedure Description

To modify the provider code to support printing a tag

This procedure has instructions to modify the TutorialProvider source code to support printing a tag.

  1. Open the TutorialProvider.sln solution in Visual Studio if it is not already open.

  2. In the Solution Explorer window, double-click MyPhysicalDeviceProxy.cs to open the file in the source editor.

  3. Add the following case block to the Switch block in the SendMessage method before the default: statement:

    case "PrintTagCommand":
        {
            PrintTagCommand cmd = command as PrintTagCommand;
            cmd.Response = new PrintTagResponse();
            byte[] TagIDPrint = cmd.PrintLabel.GetTagId();
            string b64TagIDPrint = Convert.ToBase64String(TagIDPrint);
            string ItemIDPrint = (string)     cmd.VendorDefinedParameters["ItemID"];
            string PONumberPrint = (string) cmd.VendorDefinedParameters["PONumber"];
            string strXMLPrintCmd = "<Command><Name>PrintTag</Name><TagID>" + b64TagIDPrint + "</TagID><VendorData><ItemID>" + ItemIDPrint + "</ItemID><PONumber>" + PONumberPrint + "</PONumber></VendorData></Command>";
            logger.Info("Print Command: " + strXMLPrintCmd);
            ASCIIEncoding encPrint = new ASCIIEncoding();
            byte[] bytesDataCmd = new Byte[1024];
            bytesDataCmd = encPrint.GetBytes(strXMLPrintCmd);
            logger.Info("Sending TCP data");
            netStrm.Write(bytesDataCmd, 0, bytesDataCmd.Length);
            netStrm.Flush();
            logger.Info("Sent TCP data");
            break;
    }
    
  4. In the Solution Explorer window, right-click TutorialProvider, and then click Build.

  • The provider log file for TutorialProvider, which is typically stored at %RFIDDATADIR%\Providers\TutorialProvider, contains the messages logged from the provider code along with other messages.

  • The process log files are rotated. For more information about the log rotation feature, see Log Files with Troubleshooting Information.

Now that you have completed this step, perform Step 3: Test the Process, which gives you step-by-step instructions to test the TutorialProcess process.

© 2013 Microsoft Corporation. All rights reserved.
Show:
© 2014 Microsoft