Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing two consecutive conditions failed in streams #32

Merged

Conversation

SergeyGulik
Copy link

Hi Patrick,
Found a problem with two consecutive conditions arriving as part of the stream document. Only the first was successfully parsed.
Conditions as I see them now are by default empty nodes and thus no content parsing should be done.
Could please pay attention to the test I've added? There is a value override that seems strange for me, maybe it is an earlier introduced bug.

…he stream document. Only the first was successfully parsed.

Conditions as I see them now are by default empty nodes and thus no content parsing should be done.
@PatrickRitchie
Copy link
Contributor

Consecutive Conditons in XML Stream

Yes, it looks like you are correct that two consecutive Conditions were not being read correctly and it looks like the commit you added will fix this.

Condition Level

It looks like the Condition Levels read from XML are being added to the internal Values list as PascalCase (ex. Fault, Warning, Normal) but when they are read using the Conditions property in the DeviceStream/ComponentStream they are converted to the Enum which is uppercase. In this scenario, reading as a ConditionObservation, you get uppercase but reading as the abstract Observation using the Values property, you get Pascal Case. The below should fix this issue:

MTConnect.NET-XML > Streams > XmlStreamsResponseDocument > ReadObservationsXml

image

When read as ConditionObservation

public ConditionLevel Level
{
    get => GetValue(ValueKeys.Level).ConvertEnum<ConditionLevel>();
    set => AddValue(ValueKeys.Level, value.ToString());
}

Timestamps

I also noticed some issues with the timestamps when looking at the Test you added. It looks like timestamps were being read from XML as Local time instead of UTC. The below code should fix this:

MTConnect.NET-XML > Streams > XmlStreamsResponseDocument > ReadObservationProperties

image

Updated Release

I will merge the commit you added as well as add the changes I listed here and create a new Release and update the Nuget package.

@PatrickRitchie PatrickRitchie merged commit 98b2ee9 into TrakHound:master Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants