Send SourceTimestamp in ISO 8601 format and OPC UA status code as uint,
address review comments.
This commit is contained in:
Родитель
245a63b395
Коммит
fe933ace8c
|
@ -114,7 +114,7 @@ The syntax of the configuration file is as follows:
|
|||
// "DisplayName": "CurrentTime",
|
||||
// "Value": {
|
||||
// "Value": "10.11.2017 14:03:17",
|
||||
// "SourceTimestamp": "2017-11-10 14:03:17Z"
|
||||
// "SourceTimestamp": "2017-11-10T14:03:17Z"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
@ -202,7 +202,7 @@ The syntax of the configuration file is as follows:
|
|||
// members won't be nested:
|
||||
// "DisplayName": "CurrentTime",
|
||||
// "Value": "10.11.2017 14:03:17",
|
||||
// "SourceTimestamp": "2017-11-10 14:03:17Z"
|
||||
// "SourceTimestamp": "2017-11-10T14:03:17Z"
|
||||
// The 'Flat' property can only be used for the 'MonitoredItem' and 'Value'
|
||||
// objects of the 'Defaults' object and will be used for all
|
||||
// messages sent by publisher.
|
||||
|
@ -216,10 +216,11 @@ The syntax of the configuration file is as follows:
|
|||
"Publish": true,
|
||||
"Name": "SourceTimestamp"
|
||||
},
|
||||
// StatusCode is the 32 bit OPC UA status code formatted as hexadezimal number.
|
||||
// 'StatusCode' is the 32 bit OPC UA status code
|
||||
"StatusCode": {
|
||||
"Publish": false,
|
||||
"Name": "StatusCode"
|
||||
// 'Pattern' is ignored for the 'StatusCode' value
|
||||
},
|
||||
// 'Status' is the symbolic name of 'StatusCode'
|
||||
"Status": {
|
||||
|
|
|
@ -404,7 +404,7 @@ namespace OpcPublisher
|
|||
|
||||
// process Value object properties
|
||||
if (!string.IsNullOrEmpty(messageData.Value) || !string.IsNullOrEmpty(messageData.SourceTimestamp) ||
|
||||
!string.IsNullOrEmpty(messageData.StatusCode) || !string.IsNullOrEmpty(messageData.Status))
|
||||
messageData.StatusCode != null || !string.IsNullOrEmpty(messageData.Status))
|
||||
{
|
||||
if (!(bool)telemetryConfiguration.Value.Flat)
|
||||
{
|
||||
|
@ -434,7 +434,7 @@ namespace OpcPublisher
|
|||
}
|
||||
|
||||
// process StatusCode
|
||||
if (!string.IsNullOrEmpty(messageData.StatusCode))
|
||||
if (messageData.StatusCode != null)
|
||||
{
|
||||
await _jsonWriter.WritePropertyNameAsync(telemetryConfiguration.Value.StatusCode.Name);
|
||||
await _jsonWriter.WriteValueAsync(messageData.StatusCode);
|
||||
|
@ -527,7 +527,7 @@ namespace OpcPublisher
|
|||
// sanity check that the user has set a large enough IoTHub messages size
|
||||
if ((_iotHubMessageSize > 0 && jsonMessageSize > _iotHubMessageSize ) || (_iotHubMessageSize == 0 && jsonMessageSize > iotHubMessageBufferSize))
|
||||
{
|
||||
Trace(Utils.TraceMasks.Error, $"There is a telemetry message (size: {jsonMessageSize}), which will not fit into an IoTHub message (max size: {_iotHubMessageSize}].");
|
||||
Trace(Utils.TraceMasks.Error, $"There is a telemetry message (size: {jsonMessageSize}), which will not fit into an IoTHub message (max size: {iotHubMessageBufferSize}].");
|
||||
Trace(Utils.TraceMasks.Error, $"Please check your IoTHub message size settings. The telemetry message will be discarded silently. Sorry:(");
|
||||
_tooLargeCount++;
|
||||
continue;
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace OpcPublisher
|
|||
public string DisplayName;
|
||||
public string Value;
|
||||
public string SourceTimestamp;
|
||||
public string StatusCode;
|
||||
public uint? StatusCode;
|
||||
public string Status;
|
||||
public bool PreserveValueQuotes;
|
||||
|
||||
|
@ -193,9 +193,12 @@ namespace OpcPublisher
|
|||
{
|
||||
SourceTimestamp = telemetryConfiguration.Value.SourceTimestamp.PatternMatch(SourceTimestamp);
|
||||
}
|
||||
if (telemetryConfiguration.Value.StatusCode.Publish == true)
|
||||
if (telemetryConfiguration.Value.StatusCode.Publish == true && StatusCode != null)
|
||||
{
|
||||
StatusCode = telemetryConfiguration.Value.StatusCode.PatternMatch(StatusCode);
|
||||
if (!string.IsNullOrEmpty(telemetryConfiguration.Value.StatusCode.Pattern))
|
||||
{
|
||||
Trace($"'Pattern' settngs for StatusCode are ignored.");
|
||||
}
|
||||
}
|
||||
if (telemetryConfiguration.Value.Status.Publish == true)
|
||||
{
|
||||
|
@ -249,13 +252,13 @@ namespace OpcPublisher
|
|||
}
|
||||
if (telemetryConfiguration.Value.SourceTimestamp.Publish == true && value.SourceTimestamp != null)
|
||||
{
|
||||
// use the SourceTimestamp as reported in the notification event argument in univeral sortable format
|
||||
messageData.SourceTimestamp = value.SourceTimestamp.ToString();
|
||||
// use the SourceTimestamp as reported in the notification event argument in ISO8601 format
|
||||
messageData.SourceTimestamp = value.SourceTimestamp.ToString("o");
|
||||
}
|
||||
if (telemetryConfiguration.Value.StatusCode.Publish == true && value.StatusCode != null)
|
||||
{
|
||||
// use the StatusCode as reported in the notification event argument
|
||||
messageData.StatusCode = value.StatusCode.Code.ToString("X");
|
||||
messageData.StatusCode = value.StatusCode.Code;
|
||||
}
|
||||
if (telemetryConfiguration.Value.Status.Publish == true && value.StatusCode != null)
|
||||
{
|
||||
|
@ -278,7 +281,7 @@ namespace OpcPublisher
|
|||
messageData.PreserveValueQuotes = true;
|
||||
if (markerStart >= 0)
|
||||
{
|
||||
// we either have a value in quotes of just a value
|
||||
// we either have a value in quotes or just a value
|
||||
int valueLength;
|
||||
int valueStart = marker.Length;
|
||||
if (valueString.IndexOf("\"", valueStart) >= 0)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// "DisplayName": "CurrentTime",
|
||||
// "Value": {
|
||||
// "Value": "10.11.2017 14:03:17",
|
||||
// "SourceTimestamp": "2017-11-10 14:03:17Z"
|
||||
// "SourceTimestamp": "2017-11-10T14:03:17Z"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
@ -101,7 +101,7 @@
|
|||
// members won't be nested:
|
||||
// "DisplayName": "CurrentTime",
|
||||
// "Value": "10.11.2017 14:03:17",
|
||||
// "SourceTimestamp": "2017-11-10 14:03:17Z"
|
||||
// "SourceTimestamp": "2017-11-10T14:03:17Z"
|
||||
// The 'Flat' property could only be used for the 'MonitoredItem' and 'Value'
|
||||
// configuratíon settings of the 'Defaults' objet and will be used for all JSON
|
||||
// messages sent by publisher.
|
||||
|
@ -115,10 +115,11 @@
|
|||
"Publish": true,
|
||||
"Name": "SourceTimestamp"
|
||||
},
|
||||
// StatusCode is the 32 bit OPC UA status code formatted as hexadezimal number.
|
||||
// 'StatusCode' is the 32 bit OPC UA status code
|
||||
"StatusCode": {
|
||||
"Publish": false,
|
||||
"Name": "StatusCode"
|
||||
// 'Pattern' is ignored for the 'StatusCode' value
|
||||
},
|
||||
// 'Status' is the symbolic name of 'StatusCode'
|
||||
"Status": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче