Description | The test case uses 5.000 MIs for this test unit.
But the time in the CreateMonitoredItemsHelper and probably also
the WriteHelper when 5.000 items are processed approaches the
PublishingInterval of 5000 ms, which makes the test case fail.
I can make the test cases succeed by preparing the big create
MI and Write request, before creating the subscription as follows:
--- "maintree/Subscription Services/Subscription Publish Min 02/Test Cases/002.js" 2018-11-06 18:09:44.000000000 +0100
+++ "maintree/Subscription Services/Subscription Publish Min 02/Test Cases/002.js" 2018-11-13 21:25:53.637207721 +0100
@@ -43,18 +43,47 @@
function deleteSub5106004() {
// read all items first
ReadHelper.Execute( { NodesToRead: items } );
+
- var writeRequest = new UaWriteRequest();
- var writeResponse = new UaWriteResponse();
- writeRequest.RequestHeader = UaRequestHeader.New( { Session: WriteHelper.Session } );
-
- var createMonitoredItemsRequest = new UaCreateMonitoredItemsRequest();
- var createMonitoredItemsResponse = new UaCreateMonitoredItemsResponse();
- createMonitoredItemsRequest.RequestHeader = UaRequestHeader.New( { Session: CreateMonitoredItemsHelper.Session } );
- createMonitoredItemsRequest.TimestampsToReturn = TimestampsToReturn.Both;
-
- for (var w=0; w<items.length; w++) {
- UaVariant.Increment( { Value: items[w].Value } );
- writeRequest.NodesToWrite[w].NodeId = items[w].NodeId;
- writeRequest.NodesToWrite[w].AttributeId = items[w].AttributeId;
- writeRequest.NodesToWrite[w].IndexRange = items[w].IndexRange;
- writeRequest.NodesToWrite[w].Value.Value = items[w].Value.Value;
- createMonitoredItemsRequest.ItemsToCreate[w] = new UaMonitoredItemCreateRequest();
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.NodeId = items[w].NodeId;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.AttributeId = items[w].AttributeId;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.IndexRange = items[w].IndexRange;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.DataEncoding = items[w].DataEncoding;
- createMonitoredItemsRequest.ItemsToCreate[w].MonitoringMode = items[w].MonitoringMode;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.ClientHandle = items[w].ClientHandle;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.SamplingInterval = items[w].SamplingInterval;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.QueueSize = items[w].QueueSize;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.DiscardOldest = items[w].DiscardOldest;
- }// for...
-
// create subscription
var subscription = new Subscription2( { PublishingInterval:5000, RequestedLifetimeCount:10, MaxKeepAliveCount:1 } );
//subscription
if( !CreateSubscriptionHelper.Execute( { Subscription: subscription } ) ) addError( "Error creating subscription." );
else {
- if( !CreateMonitoredItemsHelper.Execute( { ItemsToCreate: items, TimestampsToReturn: TimestampsToReturn.Both, SubscriptionId: subscription } ) ) {
- createMonitoredItemsRequest.SubscriptionId = subscription.SubscriptionId;
- var uaStatus = CreateMonitoredItemsHelper.Session.createMonitoredItems ( createMonitoredItemsRequest, createMonitoredItemsResponse );
- if( !uaStatus.isGood() ) {
DeleteSubscriptionsHelper.Execute( { SubscriptionIds: subscription } );
return( false );
}
// write a new value to all subscribed items
- for( var i=0; i<items.length; i++ ) UaVariant.Increment( { Value: items[i].Value } );
- WriteHelper.Execute( { NodesToWrite: items, ReadVerification: false } );
- WriteHelper.Session.write( writeRequest, writeResponse );
// queue 2 publish requests:
var timeoutSetting = parseInt( 3 * readSetting( "/Server Test/Session/DefaultTimeoutHint" ).toString(), 10 );
for( var q=0; q<2; q++ ) {
--- "maintree/Subscription Services/Subscription Publish Min 02/Test Cases/003.js" 2018-11-06 18:09:44.000000000 +0100
+++ "maintree/Subscription Services/Subscription Publish Min 02/Test Cases/003.js" 2018-11-13 21:26:33.359602327 +0100
@@ -61,12 +61,41 @@
// read all items first
ReadHelper.Execute( { NodesToRead: items } );
- var writeRequest = new UaWriteRequest();
- var writeResponse = new UaWriteResponse();
- writeRequest.RequestHeader = UaRequestHeader.New( { Session: WriteHelper.Session } );
-
- var createMonitoredItemsRequest = new UaCreateMonitoredItemsRequest();
- var createMonitoredItemsResponse = new UaCreateMonitoredItemsResponse();
- createMonitoredItemsRequest.RequestHeader = UaRequestHeader.New( { Session: CreateMonitoredItemsHelper.Session } );
- createMonitoredItemsRequest.TimestampsToReturn = TimestampsToReturn.Both;
-
- for (var w=0; w<items.length; w++) {
- UaVariant.Increment( { Value: items[w].Value } );
- writeRequest.NodesToWrite[w].NodeId = items[w].NodeId;
- writeRequest.NodesToWrite[w].AttributeId = items[w].AttributeId;
- writeRequest.NodesToWrite[w].IndexRange = items[w].IndexRange;
- writeRequest.NodesToWrite[w].Value.Value = items[w].Value.Value;
- createMonitoredItemsRequest.ItemsToCreate[w] = new UaMonitoredItemCreateRequest();
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.NodeId = items[w].NodeId;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.AttributeId = items[w].AttributeId;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.IndexRange = items[w].IndexRange;
- createMonitoredItemsRequest.ItemsToCreate[w].ItemToMonitor.DataEncoding = items[w].DataEncoding;
- createMonitoredItemsRequest.ItemsToCreate[w].MonitoringMode = items[w].MonitoringMode;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.ClientHandle = items[w].ClientHandle;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.SamplingInterval = items[w].SamplingInterval;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.QueueSize = items[w].QueueSize;
- createMonitoredItemsRequest.ItemsToCreate[w].RequestedParameters.DiscardOldest = items[w].DiscardOldest;
- }// for...
-
// create subscription
var subscription = new Subscription2( { PublishingInterval: 5000, RequestedLifetimeCount: 10, MaxKeepAliveCount: 1 } );
//subscription
if( !CreateSubscriptionHelper.Execute( { Subscription: subscription } ) ) addError( "Error creating subscription." );
else {
- if( !CreateMonitoredItemsHelper.Execute( { ItemsToCreate: items, TimestampsToReturn: TimestampsToReturn.Both, SubscriptionId: subscription } ) ) {
- createMonitoredItemsRequest.SubscriptionId = subscription.SubscriptionId;
- var uaStatus = CreateMonitoredItemsHelper.Session.createMonitoredItems ( createMonitoredItemsRequest, createMonitoredItemsResponse );
-
if( !uaStatus.isGood() ) {
DeleteSubscriptionsHelper.Execute( { SubscriptionIds: subscription } );
return( false );
}
@@ -92,11 +121,7 @@
// write to ALL items
PublishHelper.WaitInterval( { Items: items, Subscription: subscription } );
- for( var w=0; w<items.length; w++ ) {
- UaVariant.Increment( { Value: items[w].Value } );
- items[w].WrittenValue = items[w].Value.Value.clone();
- }// for( var w=0; w<items.length; w++ )
- WriteHelper.Execute( { NodesToWrite:items, ReadVerification:false } );
-
WriteHelper.Session.write( writeRequest, writeResponse );
// wait for our 2 publish requests to come back... but wait a MAX of
@@ -189,7 +214,18 @@
//--------------------------------------------------------------
// small delay and then clean-up
- for (var i = 0; i < 250; i++) UaDateTime.CountDown({ Msecs: 10, SuppressMessage: true });;
- for (var i=0; i<250; i++) UaDateTime.CountDown({ Msecs: 10, SuppressMessage: true });
- for (var w=0; w<items.length; w++) {
- var currentResult = createMonitoredItemsResponse.Results[w];
- if ( currentResult.StatusCode.isGood() ) {
- items[w].IsCreated = true;
- items[w].MonitoredItemId = currentResult.MonitoredItemId;
- items[w].RevisedQueueSize = currentResult.RevisedQueueSize;
- items[w].RevisedSamplingInterval = currentResult.RevisedSamplingInterval;
- items[w].SubscriptionId = createMonitoredItemsRequest.SubscriptionId;
- }
- }
-
DeleteMonitoredItemsHelper.Execute( { ItemsToDelete: items, SubscriptionId: subscription } );
DeleteSubscriptionsHelper.Execute( { SubscriptionIds: subscription } );
|
---|