ArcFM Desktop Developer Guide
Upgrade Packet Adapters

Resource Center Home

With the 9.3 Rev2 release, Mobile started using XML packets rather than workspace packets. Since data is now transferred in XML format, any custom packet adapters that add custom data to the workspace packets must be upgraded to support XML packets.

Existing custom packet adapters already implement the IMMPacketAdapter interface. To upgrade, you must implement the IMMPacketAdapterXml interface. It has the same methods and properties as IMMPacketAdapter, but with some modified parameters and one additional method.

Below are code snippets for the IMMPacketAdapterXml methods and properties that differ from the original IMMPacketAdapter methods and properties.  These are just a few examples. All methods on this interface must be implemented.

Read Method

The IMMPacketAdapterXml::Read method contains an additional parameter called pElement. This is an IXMLDOMElement from the XML DOM document that is being read.

IMMPacketAdapterXml::Read
Copy Code
IMMPacketAdapterXml_Read(ByVal Packet As mmFramework.IMMPacket, ByVal Hook As Object, _
ByVal pElement As MSXML2.IXMLDOMElement) As Boolean

Write Method

The IMMPacketAdapterXml::Write method contains the same pElement parameter. It provides the IXMLDOMElement from the XML DOM document being written.

IMMPacketAdapterXml::Write
Copy Code
IMMPacketAdapterXml_Write(ByVal Packet As mmFramework.IMMPacket, ByVal Hook As Object, _
ByVal pElement As MSXML2.IXMLDOMElement) As Boolean

ConvertPacketToXmlPacket Method

This method on the IMMPacketAdapterXml interface does not exist on the old IMMPacketAdapter interface. The Convert to XML subtask (discussed in the Mobile Configuration Guide) uses this method to convert old workspace packets to XML packets. The method takes an existing pSrcPacket as an input parameter (this is the workspace packet) and generates the element of the XML packet that stores data for the packet adapter. The following code snippet shows you the code should verify that the incoming pSrcPacket is of a packet type that the ConvertPacketToXmlPacket method can convert.

ConvertPacketToXMLPacket Method
Copy Code
If (TypeOf pSrcPacket Is IMMWorkspacePacket) Then

     Dim pWSPacket As IMMWorkspacePacket
     Set pWSPacket = pSrcPacket
     ' ... do the rest of the conversion here ...
Else
     ' ... unsupported source packet ...
End If

The following code sample shows how the ConvertPacketToXmlPacket method is used in the Packet Adapter that maintains Extent data.

ConvertPacketToXmlPacket Example
Copy Code
Private Function IMMPacketAdapterXml_ConvertPacketToXmlPacket(ByVal pSrcPacket As mmFramework.IMMPacket, ByVal pXmlPacket As mmFramework.IMMXmlPacket, ByVal Hook As Object, ByVal pElement As MSXML2.IXMLDOMElement) As Boolean
  
    IMMPacketAdapterXml_ConvertPacketToXmlPacket = False
    If (TypeOf pSrcPacket Is IMMWorkspacePacket) Then
        Dim pWSPacket As IMMWorkspacePacket
        Set pWSPacket = pSrcPacket
        
        Dim pNodeDataNode As IXMLDOMNode
        Set pNodeDataNode = WriteMainTags(pElement)
        
        If pNodeDataNode Is Nothing Then Exit Function
        
        Dim pExtentNode As IXMLDOMNode
        Set pExtentNode = pNodeDataNode.selectSingleNode("EXTENT")
            
        Dim pNamedNodeMap As IXMLDOMNamedNodeMap
        Set pNamedNodeMap = pExtentNode.Attributes
        Dim pAttributeNode As IXMLDOMAttribute
        Set pAttributeNode = pNamedNodeMap.getNamedItem("GOT_EXTENT")
    
        Dim stream As IVariantStream
        Set stream = ReadFrompackage(IMMPacketAdapter_ProgID, pWSPacket.Workspace)
        
        If Not stream Is Nothing Then
            Dim lVersion As Long
            lVersion = stream.Read  'version number
            If lVersion <= smk_lVersionNumber Then
                Dim bGotMapExtent As Boolean
                bGotMapExtent = stream.Read
                If bGotMapExtent Then
                    pAttributeNode.Value = CStr(True)
                    
                    Dim pExtent As IEnvelope
                    Set pExtent = New Envelope
                    Set pExtent = stream.Read
                    Dim pPersistStream As IPersistStream
                    Set pPersistStream = pExtent
                    
                    Dim str As String
                    str = m_pMobilePacketHelper.MimeEncode(pPersistStream)
        
                    Dim pCDATANode As IXMLDOMCDATASection
                    Set pCDATANode = pExtentNode.firstChild
                    
                    If Not pCDATANode Is Nothing Then
                        pExtentNode.removeChild pCDATANode
                    End If
                    Set pCDATANode = pExtentNode.ownerDocument.createCDATASection(str)
                    pExtentNode.appendChild pCDATANode
                Else
                    pAttributeNode.Value = CStr(False)
                End If
            Else
              RaiseError "IMMTimeTravel not implemented: cannot load future version, sorry.", mk_sToolName
            End If
        End If
        
        IMMPacketAdapterXml_ConvertPacketToXmlPacket = True
    Else
        RaiseError DetailedErrorSource & vbNewLine & "Unsupported packet type for conversion", mk_sToolName, False
    End If
    IMMPacketAdapterXml_ConvertPacketToXmlPacket = True
    
End Function

 

 

 


Send Comment to ArcFMdocumentation@schneider-electric.com