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

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

@ -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,10 +629,14 @@ namespace OpcPublisher
}
catch (Exception e)
{
if (!(e is OperationCanceledException))
{
Trace(e, "Error while processing monitored item messages.");
}
}
}
}
private static string _iotHubOwnerConnectionString = string.Empty;
private static Microsoft.Azure.Devices.Client.TransportType _iotHubProtocol = Microsoft.Azure.Devices.Client.TransportType.Mqtt_WebSocket_Only;

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

@ -101,6 +101,8 @@ namespace OpcPublisher
{ "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)}",
(Microsoft.Azure.Devices.Client.TransportType p) => IotHubProtocol = p
@ -459,6 +461,14 @@ namespace OpcPublisher
// stop on user request
WriteLine("");
WriteLine("");
if (_noShutdown)
{
// 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
{
@ -467,8 +477,10 @@ namespace OpcPublisher
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 : "")}");
}
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;
}
}