Merge remote-tracking branch 'github/master'

Merge github master changes.
This commit is contained in:
Hans Gschossmann 2017-11-15 21:01:42 +01:00
Родитель 9458173156 dfe4670d06
Коммит 32c6d54bd9
4 изменённых файлов: 40 добавлений и 15 удалений

Просмотреть файл

@ -347,6 +347,10 @@ The complete usage of the application can be shown using the `--help` command li
--vc, --verboseconsole=VALUE
the output of publisher is shown on the console.
Default: False
--ns, --noshutdown=VALUE
publisher could not be stopped by pressing a key
on the console, but will run forever.
Default: False
--ih, --iothubprotocol=VALUE
the protocol to use for communication with Azure
IoTHub (allowed values: Amqp, Http1, Amqp_

Просмотреть файл

@ -61,14 +61,14 @@ namespace OpcPublisher
{
while (true)
{
if (ct.IsCancellationRequested)
{
return;
}
try
{
await Task.Delay((int)_diagnosticsInterval * 1000, ct);
if (ct.IsCancellationRequested)
{
return;
}
Trace("==========================================================================");
Trace($"OpcPublisher status @ {System.DateTime.UtcNow} (started @ {PublisherStartTime})");

Просмотреть файл

@ -505,7 +505,7 @@ namespace OpcPublisher
// if we are in shutdown do not wait, else wait infinite if send interval is not set
millisecondsTillNextSend = ct.IsCancellationRequested ? 0 : Timeout.Infinite;
}
bool gotItem = _monitoredItemsDataQueue.TryTake(out messageData, (int)millisecondsTillNextSend);
bool gotItem = _monitoredItemsDataQueue.TryTake(out messageData, (int)millisecondsTillNextSend, ct);
// the two commandline parameter --ms (message size) and --si (send interval) control when data is sent to IoTHub
// pls see detailed comments on performance and memory consumption at https://github.com/Azure/iot-edge-opc-publisher
@ -629,7 +629,11 @@ namespace OpcPublisher
}
catch (Exception e)
{
Trace(e, "Error while processing monitored item messages.");
if (!(e is OperationCanceledException))
{
Trace(e, "Error while processing monitored item messages.");
}
}
}
}

Просмотреть файл

@ -100,6 +100,8 @@ namespace OpcPublisher
{ "di|diagnosticsinterval=", $"shows publisher diagnostic info at the specified interval in seconds. 0 disables diagnostic output.\nDefault: {DiagnosticsInterval}", (uint u) => DiagnosticsInterval = u },
{ "vc|verboseconsole=", $"the output of publisher is shown on the console.\nDefault: {VerboseConsole}", (bool b) => VerboseConsole = b },
{ "ns|noshutdown=", $"publisher could not be stopped by pressing a key on the console, but will run forever.\nDefault: {_noShutdown}", (bool b) => _noShutdown = b },
// IoTHub specific options
{ "ih|iothubprotocol=", $"the protocol to use for communication with Azure IoTHub (allowed values: {string.Join(", ", Enum.GetNames(IotHubProtocol.GetType()))}).\nDefault: {Enum.GetName(IotHubProtocol.GetType(), IotHubProtocol)}",
@ -459,16 +461,26 @@ namespace OpcPublisher
// stop on user request
WriteLine("");
WriteLine("");
WriteLine("Publisher is running. Press any key to quit.");
try
if (_noShutdown)
{
ReadKey(true);
}
catch
{
// wait forever if there is no console
// wait forever if asked to do so
WriteLine("Publisher is running infinite...");
await Task.Delay(Timeout.Infinite);
}
else
{
WriteLine("Publisher is running. Press any key to quit.");
try
{
ReadKey(true);
}
catch
{
// wait forever if there is no console
WriteLine("There is no console. Publisher is running infinite...");
await Task.Delay(Timeout.Infinite);
}
}
WriteLine("");
WriteLine("");
ShutdownTokenSource.Cancel();
@ -543,7 +555,11 @@ namespace OpcPublisher
{
Trace(e, $"Failed to connect and monitor a disconnected server. {(e.InnerException != null ? e.InnerException.Message : "")}");
}
await Task.Delay(_publisherSessionConnectWaitSec * 1000, ct);
try
{
await Task.Delay(_publisherSessionConnectWaitSec * 1000, ct);
}
catch { }
if (ct.IsCancellationRequested)
{
return;
@ -681,5 +697,6 @@ namespace OpcPublisher
private static PublisherServer _publisherServer;
private static bool _opcTraceInitialized = false;
private static int _publisherSessionConnectWaitSec = 10;
private static bool _noShutdown = false;
}
}