Skip to content

Not using standard parameters for Sample requests #4

@MattCosturos

Description

@MattCosturos

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

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions