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

Not using standard parameters for Sample requests #4

Open
MattCosturos opened this issue Nov 27, 2019 · 0 comments
Open

Not using standard parameters for Sample requests #4

MattCosturos opened this issue Nov 27, 2019 · 0 comments

Comments

@MattCosturos
Copy link

I was getting all sorts of seemingly random values trying to use the streaming feature of this client.
I reviewed the MTConnect spec documents to better understand the "sample" request as I have never used it before.
https://www.mtconnect.org/standard-download20181#Current%20Release - Section 8.3 of Part 1.

When using the "sample" request, the valid parameters are "from" and "count" not "at"
(When requesting data from an MTConnect agent the "Current" request can use "at" to request values at a specific sequenceID time.)

First I added a var to track the _nextSequence
private long _nextSequence;

Inside ParseStream we need to update _nextSequence from the response header

_nextSequence = Convert.ToInt64(xdoc.Descendants().First(e => e.Name.LocalName == "Header")
    .Attribute("nextSequence").Value);`

Finally in the StreamingTimerElapsed the request for samples should look like

var request = new RestRequest
{
    Resource = "sample"
};
request.AddParameter("from", _nextSequence );	
request.AddParameter("count", 100 );
_restClient.ExecuteAsync(request, r => ParseStream(r));

`

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

No branches or pull requests

1 participant