Replies: 1 comment 2 replies
-
My suggestion would be to create a custom Agent Module that monitors the gateway and reports as a Device in the MTConnect Agent. The machine UI could then read the status of the gateway using MTConnect. Below is an example: Agent Moduleusing MTConnect.Agents;
using MTConnect.Applications;
using MTConnect.Configurations;
using MTConnect.Devices;
using MTConnect.Devices.DataItems;
using MTConnect.Observations.Events;
// Run Agent Application
var app = new MTConnectAgentApplication();
app.Run(args, true);
public class ModuleConfiguration
{
public string GatewayAddress { get; set; }
}
public class GatewayMonitorModule : MTConnectInputAgentModule
{
public const string ConfigurationTypeId = "gateway-monitor"; // This must match the module section in the 'agent.config.yaml' file
public const string DefaultId = "Gateway Monitor Module"; // The ID is mainly just used for logging.
private readonly ModuleConfiguration _configuration;
public GatewayMonitorModule(IMTConnectAgentBroker agent, object configuration) : base(agent)
{
Id = DefaultId;
_configuration = AgentApplicationConfiguration.GetConfiguration<ModuleConfiguration>(configuration);
}
protected override IDevice OnAddDevice()
{
var device = new Device();
device.Uuid = $"gateway-{_configuration.GatewayAddress}"; // A UUID of the gateway. IP/MAC address?
device.Id = "gateway";
device.Name = "gateway";
// Add an Availability DataItem to report the status of the Gateway
device.AddDataItem<AvailabilityDataItem>();
return device;
}
protected override void OnRead()
{
Log(MTConnect.Logging.MTConnectLogLevel.Information, "Read Gateway Data");
bool reachable;
reachable = true; // This is where I would ping/test the gateway of _configuration.GatewayAddress
if (reachable)
{
// Gateway is reachable so report AVAILABLE
AddValueObservation<AvailabilityDataItem>(Availability.AVAILABLE);
}
else
{
// Gateway is NOT reachable so report UNAVAILABLE
AddValueObservation<AvailabilityDataItem>(Availability.UNAVAILABLE);
}
}
} Agent Configurationmodules:
- gateway-monitor:
gatewayAddress: 192.168.1.1
readInterval: 5000
- http-server:
port: 5001 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello @PatrickRitchie
We’re currently working on an IoT use case involving an AWS Greengrass gateway paired with a machine running the MTConnect Agent. Occasionally, the gateway may become unresponsive or enter an unhealthy state due to various issues. We’d like to monitor the gateway’s health from the machine side and report its availability via the MTConnect Agent. This would allow us to display the gateway's status on the machine UI and take necessary actions proactively.
Questions & Suggestions:
Looking forward to your insights. Thank you for your time and support!
Beta Was this translation helpful? Give feedback.
All reactions