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

ShdrQueueAdapter.AddCondition results in stack overflow #39

Closed
scottmwyant opened this issue Jan 30, 2023 · 2 comments
Closed

ShdrQueueAdapter.AddCondition results in stack overflow #39

scottmwyant opened this issue Jan 30, 2023 · 2 comments

Comments

@scottmwyant
Copy link

Attempting to add a condition by using a ConditionObservationInput object results in a Stack overflow...

using MTConnect.Adapters.Shdr;
using MTConnect.Observations;
using MTConnect.Observations.Input;

    var adapter = new ShdrQueueAdapter("console-adapter");
    adapter.MultilineAssets = true;
    adapter.MultilineDevices = true;
    adapter.AgentConnected += (sender, connectionId) => Console.WriteLine($"Agent Connection (ID = {connectionId}) : Agent Connected");
    adapter.AgentDisconnected += (sender, connectionId) => Console.WriteLine($"Agent Connection (ID = {connectionId}) : Agent Disconnected");
    adapter.PingReceived += (sender, connectionId) => Console.WriteLine($"Agent Connection (ID = {connectionId}) : Agent Ping Received");
    adapter.PongSent += (sender, connectionId) => Console.WriteLine($"Agent Connection (ID = {connectionId}) : Pong Sent to Agent");
    adapter.LineSent += (sender, args) => Console.WriteLine($"Agent Connection (ID = {args.ClientId}) : Line Sent : {args.Message}");
    adapter.Start();

    // var c = new ConditionObservationInput("someId", ConditionLevel.NORMAL, DateTime.Now);
    var c = new ConditionObservationInput("someId");
    adapter.AddCondition(c);

image

@PatrickRitchie
Copy link
Contributor

Try using the "ShdrCondition" class instead of the "ConditionObservationInput" class as there seems to be an issue with using that in the AddCondition() method.

using MTConnect;
using MTConnect.Shdr;

var c = new ShdrCondition("someId");
//var c = new ShdrCondition("someId", ConditionLevel.NORMAL);
//var c = new ShdrCondition("someId", ConditionLevel.NORMAL, UnixDateTime.Now);
adapter.AddCondition(c);

I'm adding better documentation in the "dev" branch and should have a new Release finished this week. Below is a link to the new SHDR readme but note that there are a few changes in the new version (specifically SendCurrent() is now SendChanged()):
https://github.com/TrakHound/MTConnect.NET/tree/dev/src/MTConnect.NET-SHDR

@scottmwyant
Copy link
Author

Resolved, though there may be another problem, see #41.

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

2 participants