MTConnectSharp icon indicating copy to clipboard operation
MTConnectSharp copied to clipboard

Not using standard parameters for Sample requests

Open MattCosturos opened this issue 5 years ago • 0 comments

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));

`

MattCosturos avatar Nov 27 '19 17:11 MattCosturos