Skip to content

Commit

Permalink
Merge pull request #2776 from OPCFoundation/master
Browse files Browse the repository at this point in the history
Merge updates to release branch
  • Loading branch information
mregen authored Sep 26, 2024
2 parents c4f0f73 + 3d24c0e commit 4c2744e
Show file tree
Hide file tree
Showing 37 changed files with 3,670 additions and 762 deletions.
4 changes: 2 additions & 2 deletions .azurepipelines/get-version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

try {
# Try install tool
# Note: Keep Version 3.6.141, it is known working for 4 digit versioning
& dotnet @("tool", "install", "--tool-path", "./tools", "--version", "3.6.141", "--framework", "net60", "nbgv") 2>&1
# Note: Keep Version 3.6.143, it is known working for 4 digit versioning
& dotnet @("tool", "install", "--tool-path", "./tools", "--version", "3.6.143", "--framework", "net60", "nbgv") 2>&1

$props = (& ./tools/nbgv @("get-version", "-f", "json")) | ConvertFrom-Json
if ($LastExitCode -ne 0) {
Expand Down
10 changes: 5 additions & 5 deletions Applications/ConsoleReferenceClient/ClientSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ Task FetchReferenceIdTypesAsync(ISession session)

if (ServiceResult.IsNotBad(value.StatusCode))
{
var valueString = ClientSamples.FormatValueAsJson(uaClient.Session.MessageContext, variableId.ToString(), value, true);
var valueString = ClientSamples.FormatValueAsJson(uaClient.Session.MessageContext, variableId.ToString(), value, JsonEncodingType.Compact);
m_output.WriteLine(valueString);
}
else
Expand All @@ -992,7 +992,7 @@ Task FetchReferenceIdTypesAsync(ISession session)
{
if (ServiceResult.IsNotBad(errors[ii]))
{
var valueString = ClientSamples.FormatValueAsJson(uaClient.Session.MessageContext, variableIds[ii].ToString(), value, true);
var valueString = ClientSamples.FormatValueAsJson(uaClient.Session.MessageContext, variableIds[ii].ToString(), value, JsonEncodingType.Compact);
m_output.WriteLine(valueString);
}
else
Expand Down Expand Up @@ -1102,15 +1102,15 @@ public async Task SubscribeAllValuesAsync(
/// </summary>
/// <param name="name">The key of the Json value.</param>
/// <param name="value">The DataValue.</param>
/// <param name="jsonReversible">Use reversible encoding.</param>
/// <param name="jsonEncodingType">Use reversible encoding.</param>
public static string FormatValueAsJson(
IServiceMessageContext messageContext,
string name,
DataValue value,
bool jsonReversible)
JsonEncodingType jsonEncodingType)
{
string textbuffer;
using (var jsonEncoder = new JsonEncoder(messageContext, jsonReversible))
using (var jsonEncoder = new JsonEncoder(messageContext, jsonEncodingType))
{
jsonEncoder.WriteDataValue(name, value);
textbuffer = jsonEncoder.CloseAndReturnText();
Expand Down
4 changes: 2 additions & 2 deletions Fuzzing/Encoders/Fuzz.Tests/Opc.Ua.Encoders.Fuzz.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit.Console" Version="3.18.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Console" Version="3.18.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Opc.Ua.PubSub/Encoding/JsonDataSetMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ private void EncodeField(IJsonEncoder encoder, Field field)
valueToEncode = field.Value.StatusCode;
}

#pragma warning disable CS0618 // Type or member is obsolete
switch (m_fieldTypeEncoding)
{
case FieldTypeEncodingMask.Variant:
Expand Down Expand Up @@ -519,6 +520,7 @@ private void EncodeField(IJsonEncoder encoder, Field field)
encoder.UsingReversibleEncoding(encoder.WriteDataValue, fieldName, dataValue, false);
break;
}
#pragma warning restore CS0618 // Type or member is obsolete
}
#endregion

Expand Down
46 changes: 32 additions & 14 deletions Libraries/Opc.Ua.PubSub/IntervalRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class IntervalRunner : IDisposable
private readonly object m_lock = new object();

private double m_interval = kMinInterval;
private DateTime m_nextPublishTime = DateTime.MinValue;
private double m_nextPublishTick = 0;

// event used to cancel run
private CancellationTokenSource m_cancellationToken = new CancellationTokenSource();

Expand Down Expand Up @@ -154,30 +155,47 @@ protected virtual void Dispose(bool disposing)
/// </summary>
private async Task ProcessAsync()
{
lock (m_lock)
{
m_nextPublishTick = HiResClock.Ticks;
}
do
{
int sleepCycle = 0;
DateTime now = DateTime.UtcNow;
DateTime nextPublishTime = DateTime.MinValue;

lock (m_lock)
if (m_cancellationToken.IsCancellationRequested)
{
sleepCycle = Convert.ToInt32(m_interval);
break;
}

long nowTick = HiResClock.Ticks;
double nextPublishTick = 0;

nextPublishTime = m_nextPublishTime;
lock(m_lock)
{
nextPublishTick = m_nextPublishTick;
}

if (nextPublishTime > now)
double sleepCycle = (nextPublishTick - nowTick) / HiResClock.TicksPerMillisecond;
if (sleepCycle > 16)
{
sleepCycle = (int)Math.Min((nextPublishTime - now).TotalMilliseconds, sleepCycle);
sleepCycle = (int)Math.Max(kMinInterval, sleepCycle);
// Use Task.Delay if sleep cycle is larger
await Task.Delay(TimeSpan.FromMilliseconds(sleepCycle), m_cancellationToken.Token).ConfigureAwait(false);
}

// Still ticks to consume (spurious wakeup too early), improbable
nowTick = HiResClock.Ticks;
if (nowTick < nextPublishTick)
{
SpinWait.SpinUntil(() => HiResClock.Ticks >= nextPublishTick);
}
}
else if (sleepCycle >= 0 && sleepCycle <= 16)
{
SpinWait.SpinUntil(() => HiResClock.Ticks >= nextPublishTick);
}

lock (m_lock)
{
var nextCycle = Convert.ToInt32(m_interval);
m_nextPublishTime = DateTime.UtcNow.AddMilliseconds(nextCycle);
var nextCycle = (long)m_interval * HiResClock.TicksPerMillisecond;
m_nextPublishTick += nextCycle;

if (IntervalAction != null && CanExecuteFunc != null && CanExecuteFunc())
{
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Opc.Ua.Server/Opc.Ua.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ProjectReference Include="..\..\Stack\Opc.Ua.Core\Opc.Ua.Core.csproj" />
<ProjectReference Include="..\Opc.Ua.Configuration\Opc.Ua.Configuration.csproj" />
</ItemGroup>

<Target Name="GetPackagingOutputs" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void Open(string location, bool noPrivateKeys = false)
NoPrivateKeys = noPrivateKeys;
StorePath = location;
m_directory = directory;
if (m_noSubDirs)
if (m_noSubDirs || m_directory == null)
{
m_certificateSubdir = m_directory;
m_crlSubdir = m_directory;
Expand All @@ -125,39 +125,6 @@ public void Open(string location, bool noPrivateKeys = false)
// force load
ClearCertificates();
m_lastDirectoryCheck = DateTime.MinValue;

// create folders if they do not exist
try
{
if (!m_directory.Exists)
{
m_directory.Create();
}

if (!m_certificateSubdir.Exists)
{
m_certificateSubdir.Create();
}

if (noPrivateKeys)
{
if (!m_crlSubdir.Exists)
{
m_crlSubdir.Create();
}
}
else
{
if (!m_privateKeySubdir.Exists)
{
m_privateKeySubdir.Create();
}
}
}
catch (IOException ex)
{
Utils.LogError("Failed to create certificate store: {0}", ex.Message);
}
}
}
}
Expand Down Expand Up @@ -825,17 +792,16 @@ private IDictionary<string, Entry> Load(string thumbprint)
DateTime now = DateTime.UtcNow;

// refresh the directories.
m_certificateSubdir.Refresh();
m_certificateSubdir?.Refresh();

if (!NoPrivateKeys)
{
m_privateKeySubdir?.Refresh();
}

// check if store exists.
if (!m_certificateSubdir.Exists)
if (m_certificateSubdir?.Exists != true)
{
m_certificateSubdir.Create();
ClearCertificates();
return m_certificates;
}
Expand Down
Loading

0 comments on commit 4c2744e

Please sign in to comment.