Exemplo n.º 1
0
 def test_client_Client_processRequest_some_historyReadRawModifiedRequest(self):
      
     request = HistoryReadRawModifiedRequest(2) 
      
     request.targets[0].address = self.address_byte
     request.targets[1].address = self.address_double
     request.serviceSettingsGiven = True
     serviceSettings = pyuaf.client.settings.HistoryReadRawModifiedSettings()
     serviceSettings.startTime = DateTime(time.time() - 1.0)
     serviceSettings.endTime   = DateTime(time.time())
     request.serviceSettings = serviceSettings
     result = self.client.processRequest(request)
      
     self.assertTrue( result.overallStatus.isGood() )
     self.assertGreater( result.targets[0].dataValues , 0 )
     self.assertGreater( result.targets[1].dataValues , 0 )
Exemplo n.º 2
0
 def test_client_Client_processRequest_some_historyReadRawModifiedRequest_with_automatic_continuation(self):
      
     request = HistoryReadRawModifiedRequest(2) 
      
     request.targets[0].address = self.address_byte
     request.targets[1].address = self.address_double
     
     request.serviceSettingsGiven = True
     serviceSettings = pyuaf.client.settings.HistoryReadRawModifiedSettings()
     serviceSettings.startTime        = DateTime(self.startTime)
     serviceSettings.endTime          = DateTime(time.time())
     serviceSettings.maxAutoReadMore  = 20
     serviceSettings.numValuesPerNode = 1   # ridiculously low, to force automatic calls
     request.serviceSettings = serviceSettings
     
     result = self.client.processRequest(request)
      
     self.assertTrue( result.overallStatus.isGood() )
     self.assertGreater( result.targets[0].dataValues , 0 )
     self.assertGreater( result.targets[1].dataValues , 0 )
     self.assertGreater( result.targets[0].autoReadMore , 0 )
     self.assertGreater( result.targets[1].autoReadMore , 0 )
Exemplo n.º 3
0
 def test_client_Client_processRequest_some_historyReadRawModifiedRequest_with_manual_continuation(self):
     
     request = HistoryReadRawModifiedRequest(1) 
     
     request.targets[0].address = self.address_byte
     serviceSettings = pyuaf.client.settings.HistoryReadRawModifiedSettings()
     serviceSettings.startTime        = DateTime(self.startTime)
     serviceSettings.endTime          = DateTime(time.time())
     serviceSettings.maxAutoReadMore  = 0   # force no automatic calls by the UAF
     serviceSettings.numValuesPerNode = 1   # ridiculously low, to force automatic calls
     
     request.serviceSettingsGiven = True
     request.serviceSettings = serviceSettings
     
     noOfManualBrowseNext = 0
     allData = pyuaf.util.DataValueVector()
     
     result = self.client.processRequest(request)
     
     while len(result.targets[0].continuationPoint) > 0 and noOfManualBrowseNext < 50:
         
         request.targets[0].continuationPoint = result.targets[0].continuationPoint
          
         result = self.client.processRequest(request)
          
         for i in xrange(len(result.targets[0].dataValues)):
             # IMPORTANT: use     <DataValueVector>.allData.append(result.targets[0].dataValues[i])
             #            or      <Python list>.append(DataValue(result.targets[0].dataValues[i]))
             #            but NOT <Python list>.append(result.targets[0].dataValues[i]))
             #            
             #            because <Python list>.append() will NOT COPY THE DATA! It will only 
             #            store the the pointer that was returned by (...).dataValues[i]! 
             allData.append(result.targets[0].dataValues[i])
          
         noOfManualBrowseNext += 1
     
     self.assertTrue( result.overallStatus.isGood() )
     self.assertGreater( len(allData) , 2 )
     self.assertGreater( noOfManualBrowseNext , 0 )
 print("The following values were received:")
 for dataValue in allDataValues:
     print(" - %s" %dataValue.toCompactString())
 
 
 
 print("")
 print("Second option: use the generic method processRequest()")
 print("======================================================")
 
 print("")
 print("Fourth example:")
 print("---------------")
 
 # create a request with 1 target
 request = HistoryReadRawModifiedRequest(1)
 request.targets[0].address = doubleAddress
 
 # configure the request further:
 serviceSettings = HistoryReadRawModifiedSettings()
 serviceSettings.startTime         = DateTime(time.time() - 1)
 serviceSettings.endTime           = DateTime(time.time())
 serviceSettings.callTimeoutSec    = 2.0                        # optional of course
 serviceSettings.numValuesPerNode  = 100
 serviceSettings.maxAutoReadMore   = 10
 serviceSettings.isReadModified    = False                      # we want raw historical data
 request.serviceSettings = serviceSettings
 request.serviceSettingsGiven = True
 
 sessionSettings = SessionSettings()
 sessionSettings.sessionTimeoutSec = 600.0                      # optional of course
 print("The following values were received:")
 for dataValue in allDataValues:
     print(" - %s" %dataValue.toCompactString())
 
 
 
 print("")
 print("Second option: use the generic method processRequest()")
 print("======================================================")
 
 print("")
 print("Fourth example:")
 print("---------------")
 
 # create a request with 1 target
 request = HistoryReadRawModifiedRequest(1)
 request.targets[0].address = doubleAddress
 
 # configure the request:
 request.serviceConfig.serviceSettings.startTime                = DateTime(time.time() - 1)
 request.serviceConfig.serviceSettings.endTime                  = DateTime(time.time())
 request.serviceConfig.serviceSettings.callTimeoutSec           = 2.0                        # optional of course
 request.serviceConfig.serviceSettings.numValuesPerNode         = 100
 request.serviceConfig.serviceSettings.maxAutoReadMore          = 10
 request.serviceConfig.serviceSettings.isReadModified           = False                      # we want raw historical data
 request.sessionConfig.defaultSessionSettings.sessionTimeoutSec = 600.0                      # optional of course
 
 # process the request
 result = myClient.processRequest(request)
 
 # print the result