Exemple #1
0
 def test_client_Client_processRequest_some_browseNext_request(self):
     
     originalRequest = BrowseRequest(1) 
     
     originalRequest.targets[0].address = self.address_StaticScalar
     originalRequest.serviceSettingsGiven = True
     browseSettings = pyuaf.client.settings.BrowseSettings()
     browseSettings.maxReferencesToReturn = 3 # ridiculously low, to force automatic BrowseNext calls
     browseSettings.maxAutoBrowseNext = 0     # meaning: no automatic BrowseNext
     originalRequest.serviceSettings = browseSettings
     
     result = self.client.processRequest(originalRequest)
     
     self.assertTrue( result.overallStatus.isGood() )
     
     self.assertTrue( len(result.targets[0].continuationPoint) > 0 )
     
     noOfManualBrowseNext = 0
     
     while len(result.targets[0].continuationPoint) > 0:
         
         nextRequest = BrowseNextRequest(1)
         nextRequest.targets[0].address           = originalRequest.targets[0].address
         nextRequest.targets[0].continuationPoint = result.targets[0].continuationPoint
             
         result = self.client.processRequest(nextRequest)
         
         self.assertTrue( result.overallStatus.isGood() )
         
         noOfManualBrowseNext += 1
     
     self.assertGreaterEqual( noOfManualBrowseNext , 3 )
Exemple #2
0
    def test_client_Client_processRequest_some_browseNext_request(self):

        originalRequest = BrowseRequest(1)

        originalRequest.targets[0].address = self.address_StaticScalar
        originalRequest.serviceSettingsGiven = True
        browseSettings = pyuaf.client.settings.BrowseSettings()
        browseSettings.maxReferencesToReturn = 3  # ridiculously low, to force automatic BrowseNext calls
        browseSettings.maxAutoBrowseNext = 0  # meaning: no automatic BrowseNext
        originalRequest.serviceSettings = browseSettings

        result = self.client.processRequest(originalRequest)

        self.assertTrue(result.overallStatus.isGood())

        self.assertTrue(len(result.targets[0].continuationPoint) > 0)

        noOfManualBrowseNext = 0

        while len(result.targets[0].continuationPoint) > 0:

            nextRequest = BrowseNextRequest(1)
            nextRequest.targets[0].address = originalRequest.targets[0].address
            nextRequest.targets[0].continuationPoint = result.targets[
                0].continuationPoint

            result = self.client.processRequest(nextRequest)

            self.assertTrue(result.overallStatus.isGood())

            noOfManualBrowseNext += 1

        self.assertGreaterEqual(noOfManualBrowseNext, 3)
Exemple #3
0
    def test_client_Client_browseNext(self):

        originalRequest = BrowseRequest(1)

        originalRequest.targets[0].address = self.address_StaticScalar
        originalRequest.serviceConfig.serviceSettings.maxReferencesToReturn = 3  # ridiculously low, to force continuationPoints
        originalRequest.serviceConfig.serviceSettings.maxAutoBrowseNext = 0  # meaning: no automatic BrowseNext

        result = self.client.processRequest(originalRequest)

        self.assertTrue(result.overallStatus.isGood())

        self.assertTrue(len(result.targets[0].continuationPoint) > 0)

        noOfManualBrowseNext = 0

        while len(result.targets[0].continuationPoint) > 0:

            result = self.client.browseNext(
                [originalRequest.targets[0].address],
                [result.targets[0].continuationPoint])

            self.assertTrue(result.overallStatus.isGood())

            noOfManualBrowseNext += 1

        self.assertGreaterEqual(noOfManualBrowseNext, 3)
Exemple #4
0
 def test_client_Client_processRequest_some_browse_request(self):
     
     request = BrowseRequest(3) 
     
     request.targets[0].address = self.address_Demo
     request.targets[1].address = self.address_StaticScalar
     request.targets[2].address = self.address_DynamicScalar
     request.serviceSettingsGiven = True
     browseSettings = pyuaf.client.settings.BrowseSettings()
     browseSettings.maxReferencesToReturn = 3 # ridiculously low, to force automatic BrowseNext calls
     browseSettings.maxAutoBrowseNext = 100
     request.serviceSettings = browseSettings 
     
     result = self.client.processRequest(request)
     
     self.assertTrue( result.overallStatus.isGood() )
     self.assertGreaterEqual( len(result.targets[0].references) , 5 )
     self.assertGreaterEqual( len(result.targets[1].references) , 5 )
     self.assertGreaterEqual( len(result.targets[2].references) , 5 )
        newNodesToBeBrowsed.append(
            Address(firstLevelBrowseResult.targets[0].references[i].nodeId))

    secondLevelBrowseResult = myClient.browse(newNodesToBeBrowsed)

    # print the result
    print(" - Browse result of the second level:")
    print("   ----------------------------------")
    print(secondLevelBrowseResult)

    print("")
    print("Second option: use the generic function \"processRequest()\"")
    print("==========================================================")

    # create a request with 1 target
    firstLevelBrowseRequest = BrowseRequest(1)
    firstLevelBrowseRequest.targets[0].address = rootNode

    # OPTIONAL: let's also specify a small call timeout, since the UaDemoServer is running
    #           on the local machine anyway
    firstLevelBrowseRequest.serviceConfig.serviceSettings.callTimeoutSec = 2.0

    # OPTIONAL: and finally let's also specify that sessions should have a timeout of 600 seconds
    #           For more info about SessionConfigs, see the sessionconfig example
    firstLevelBrowseRequest.sessionConfig.defaultSessionSettings.sessionTimeoutSec = 600.0

    # process the request
    firstLevelBrowseResult = myClient.processRequest(firstLevelBrowseRequest)

    # print the result
    print(" - Browse result of the first level:")
 
 secondLevelBrowseResult = myClient.browse(newNodesToBeBrowsed)
 
 # print the result
 print(" - Browse result of the second level:")
 print("   ----------------------------------")
 print(secondLevelBrowseResult)
 
 
 print("")
 print("Second option: use the generic function \"processRequest()\"")
 print("==========================================================")
 
 # create a request with 1 target, and re-use the browseSettings and sessionSettings 
 # which we created earlier:
 firstLevelBrowseRequest = BrowseRequest(1)
 firstLevelBrowseRequest.targets[0].address = rootNode
 firstLevelBrowseRequest.serviceSettings = browseSettings
 firstLevelBrowseRequest.sessionSettings = sessionSettings
 
 # process the request
 firstLevelBrowseResult = myClient.processRequest(firstLevelBrowseRequest)
 
 # print the result
 print(" - Browse result of the first level:")
 print("   ---------------------------------")
 print(firstLevelBrowseResult)
 
 # we don't expect that "manual" BrowseNext calls are still needed, as the UAF will
 # have done the BrowseNext calls up to 100 times automatically for us! If there would still be
 # some continuation points left, then we surely have some unexpected problem!
            Address(firstLevelBrowseResult.targets[0].references[i].nodeId))

    secondLevelBrowseResult = myClient.browse(newNodesToBeBrowsed)

    # print the result
    print(" - Browse result of the second level:")
    print("   ----------------------------------")
    print(secondLevelBrowseResult)

    print("")
    print("Second option: use the generic function \"processRequest()\"")
    print("==========================================================")

    # create a request with 1 target, and re-use the browseSettings and sessionSettings
    # which we created earlier:
    firstLevelBrowseRequest = BrowseRequest(1)
    firstLevelBrowseRequest.targets[0].address = rootNode
    firstLevelBrowseRequest.serviceSettings = browseSettings
    firstLevelBrowseRequest.sessionSettings = sessionSettings

    # process the request
    firstLevelBrowseResult = myClient.processRequest(firstLevelBrowseRequest)

    # print the result
    print(" - Browse result of the first level:")
    print("   ---------------------------------")
    print(firstLevelBrowseResult)

    # we don't expect that "manual" BrowseNext calls are still needed, as the UAF will
    # have done the BrowseNext calls up to 100 times automatically for us! If there would still be
    # some continuation points left, then we surely have some unexpected problem!