Modifying Plug-in Data for Synchronous Mode with Managed Device-Side Code (Windows Embedded CE 6.0)
1/6/2010
If your plug-in communicates in synchronous mode and has a device-side component that uses managed code, perform the following procedure to modify the data.
For information about the files referenced, see Components of a Plug-in.
To modify data in a synchronous-mode plug-in with managed device-side code
On the desktop side, in the MyData.cs file, modify the implementation in the MyData.OnGetData event to send a command packet to the device-side component and receive a response. To accomplish this, your code must include the following actions.
- Create a new variable called sendCommand of type CommandPacket, and set its CommandId property to a new command ID of your choice.
- To supply the parameters that you want to send to the device, use the CommandPacket.AddParameterxxx methods of the sendCommand object.
- Call the base.CommandTransport.ProcessCommand method to send the command packet to the device, and then assign the result to a new receivedCommand variable of type CommandPacket.
- Retrieve any parameters that the device returns by using the CommandPacket.GetParameterxxx methods with the receivedCommand variable.
On the device side, in the file called Sync.cs, modify the implementation in the commandTransport_CommandPacketReceived method to process the new command and return a response to the desktop-side component. To accomplish this, your code must include the following actions.
- Use the e.CommandPacketIn.CommandId property to identify the new command ID that you added to MyData.cs.
- Call the e.CommandPacketIn.GetParameterxxx methods to retrieve any parameters that were sent by the desktop-side component, in the same order that they were packed into the command packet by the desktop-side component.
- Perform any necessary tasks in the device-side code.
- Create a new instance of the CommandPacket class, and then use the CommandPacket.AddParameterxxx methods to marshal the data that you want to send back to the desktop into the new command packet.
- Copy the command packet to the e.CommandPacketOut property.
To store or display any data about the device-side state in the desktop-side code, store that data in a property of the MyData class.
Note
The property must have a public accessor method for this data. If there is no specific property or public accessor method, implement it at this time.
To obtain the data stored in step 3, on the desktop side, in the MyView.cs file, modify the implementation in the MyView.OnPopulateControls method to call the public accessor methods for the MyData object's property. Then call the public accessor methods in the Windows form elements in the MyView.cs file.
(Optional) To add support for rendering the data stored in step 3 to a data file, modify the implementation in the MyData.OnRenderGeneric method to convert the data that you stored in the MyData object's property to a set of name-value pairs. For more information, see GenericDataAcceptor in the Remote Tools Framework Native API.
Save your changes, and then rebuild the plug-in.