Skip to content

Commit

Permalink
Merge pull request #94 from convertersystems/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
awcullen authored Sep 25, 2019
2 parents e74e78a + ef2e211 commit 1e7d60d
Show file tree
Hide file tree
Showing 15 changed files with 15,190 additions and 1,558 deletions.
83 changes: 46 additions & 37 deletions UaClient.UnitTests/IntegrationTests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public IntegrationTests()
}
}
}
if (userCert != null && userKey != null) {
if (userCert != null && userKey != null)
{
x509Identity = new X509Identity(userCert, userKey);
}
}
Expand Down Expand Up @@ -379,25 +380,30 @@ public async Task TestSubscription()

logger.LogInformation("Subscribe to PublishResponse stream.");
var numOfResponses = 0;
var token = channel.Where(pr => pr.SubscriptionId == id).Subscribe(
pr =>
{
numOfResponses++;

// loop thru all the data change notifications
var dcns = pr.NotificationMessage.NotificationData.OfType<DataChangeNotification>();
foreach (var dcn in dcns)
void onPublish(PublishResponse pr)
{
numOfResponses++;

// loop thru all the data change notifications and log them.
var dcns = pr.NotificationMessage.NotificationData.OfType<DataChangeNotification>();
foreach (var dcn in dcns)
{
foreach (var min in dcn.MonitoredItems)
{
foreach (var min in dcn.MonitoredItems)
{
logger.LogInformation($"sub: {pr.SubscriptionId}; handle: {min.ClientHandle}; value: {min.Value}");
}
logger.LogInformation($"sub: {pr.SubscriptionId}; handle: {min.ClientHandle}; value: {min.Value}");
}
},
ex =>
{
logger.LogInformation("Exception in publish response handler: {0}", ex.GetBaseException().Message);
});
}
}

void onPublishError(Exception ex)
{
logger.LogInformation("Exception in publish response handler: {0}", ex.GetBaseException().Message);
}

var token = channel
.Where(pr => pr.SubscriptionId == id)
.Subscribe(onPublish, onPublishError);

await Task.Delay(5000);

Expand Down Expand Up @@ -590,15 +596,16 @@ public async Task TestViewModel()
app.Run();

var vm = new MyViewModel();
// simulate a view <-> view-model
var d = new PropertyChangedEventHandler((s, e) => { });
vm.PropertyChanged += d;

void onPropertyChanged(object s, PropertyChangedEventArgs e) { }

vm.PropertyChanged += onPropertyChanged; // simulate xaml binding

logger.LogInformation($"Created subscription.");

await Task.Delay(5000);

vm.PropertyChanged -= d;
vm.PropertyChanged -= onPropertyChanged; // simulate un-binding
app.Dispose();

vm.CurrentTime
Expand Down Expand Up @@ -760,18 +767,27 @@ public async Task TransferSubscription()
var subscriptionResponse = await channel1.CreateSubscriptionAsync(subscriptionRequest).ConfigureAwait(false);
var id = subscriptionResponse.SubscriptionId;

var token = channel1.Where(pr => pr.SubscriptionId == id).Subscribe(pr =>
void onPublish(PublishResponse pr)
{
// loop thru all the data change notifications
// loop thru all the data change notifications and log them.
var dcns = pr.NotificationMessage.NotificationData.OfType<DataChangeNotification>();
foreach (var dcn in dcns)
{
foreach (var min in dcn.MonitoredItems)
{
logger.LogInformation($"channel: 1; sub: {pr.SubscriptionId}; handle: {min.ClientHandle}; value: {min.Value}");
logger.LogInformation($"sub: {pr.SubscriptionId}; handle: {min.ClientHandle}; value: {min.Value}");
}
}
});
}

void onPublishError(Exception ex)
{
logger.LogInformation("Exception in publish response handler: {0}", ex.GetBaseException().Message);
}

var token = channel1
.Where(pr => pr.SubscriptionId == id)
.Subscribe(onPublish, onPublishError);

var itemsRequest = new CreateMonitoredItemsRequest
{
Expand All @@ -792,18 +808,10 @@ public async Task TransferSubscription()
EndpointUrl);

await channel2.OpenAsync();
var token2 = channel2.Where(pr => pr.SubscriptionId == id).Subscribe(pr =>
{
// loop thru all the data change notifications
var dcns = pr.NotificationMessage.NotificationData.OfType<DataChangeNotification>();
foreach (var dcn in dcns)
{
foreach (var min in dcn.MonitoredItems)
{
logger.LogInformation($"channel: 2; sub: {pr.SubscriptionId}; handle: {min.ClientHandle}; value: {min.Value}");
}
}
});

var token2 = channel2
.Where(pr => pr.SubscriptionId == id)
.Subscribe(onPublish, onPublishError);

var transferRequest = new TransferSubscriptionsRequest
{
Expand All @@ -814,6 +822,7 @@ public async Task TransferSubscription()

StatusCode.IsGood(transferResult.Results[0].StatusCode)
.Should().BeTrue();
logger.LogInformation($"Transfered subscriptions to new client.");

await Task.Delay(3000);

Expand Down
10 changes: 5 additions & 5 deletions UaClient.UnitTests/Workstation.UaClient.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.355.26" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua" Version="1.4.356.27" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
49 changes: 27 additions & 22 deletions UaClient/ServiceModel/Ua/AttributeIds.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,32 @@ namespace Workstation.ServiceModel.Ua
{
public static class AttributeIds
{
public const uint NodeId = 1u;
public const uint NodeClass = 2u;
public const uint BrowseName = 3u;
public const uint DisplayName = 4u;
public const uint Description = 5u;
public const uint WriteMask = 6u;
public const uint UserWriteMask = 7u;
public const uint IsAbstract = 8u;
public const uint Symmetric = 9u;
public const uint InverseName = 10u;
public const uint ContainsNoLoops = 11u;
public const uint EventNotifier = 12u;
public const uint Value = 13u;
public const uint DataType = 14u;
public const uint ValueRank = 15u;
public const uint ArrayDimensions = 16u;
public const uint AccessLevel = 17u;
public const uint UserAccessLevel = 18u;
public const uint MinimumSamplingInterval = 19u;
public const uint Historizing = 20u;
public const uint Executable = 21u;
public const uint UserExecutable = 22u;
public const uint NodeId = 1u;
public const uint NodeClass = 2u;
public const uint BrowseName = 3u;
public const uint DisplayName = 4u;
public const uint Description = 5u;
public const uint WriteMask = 6u;
public const uint UserWriteMask = 7u;
public const uint IsAbstract = 8u;
public const uint Symmetric = 9u;
public const uint InverseName = 10u;
public const uint ContainsNoLoops = 11u;
public const uint EventNotifier = 12u;
public const uint Value = 13u;
public const uint DataType = 14u;
public const uint ValueRank = 15u;
public const uint ArrayDimensions = 16u;
public const uint AccessLevel = 17u;
public const uint UserAccessLevel = 18u;
public const uint MinimumSamplingInterval = 19u;
public const uint Historizing = 20u;
public const uint Executable = 21u;
public const uint UserExecutable = 22u;
public const uint DataTypeDefinition = 23u;
public const uint RolePermissions = 24u;
public const uint UserRolePermissions = 25u;
public const uint AccessRestrictions = 26u;
public const uint AccessLevelEx = 27u;
}
}
2 changes: 1 addition & 1 deletion UaClient/ServiceModel/Ua/AttributeIds.tt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Workstation.ServiceModel.Ua
public static class AttributeIds
{
<# foreach (var f in fields) { #>
public const uint <#= f.Name #> = <#= f.Value #>u;
public const uint <#= f.Name #> = <#= f.Value #>u;
<# } #>
}
}
Loading

0 comments on commit 1e7d60d

Please sign in to comment.