Skip to content

PLCs

System-level endpoints for listing and inspecting PLC connections.

List PLCs

GET /api/plcs

Returns all configured PLC targets with their connection status.

curl http://localhost:5000/api/plcs
{
  "data": [
    { "plcId": "Line1", "displayName": "Assembly Line 1", "isConnected": true, "state": "Connected", "mode": "Real" },
    { "plcId": "Line2", "displayName": "Assembly Line 2", "isConnected": false, "state": "Disconnected", "mode": "Simulated" }
  ],
  "error": null
}

state is the tri-state connection status (Disconnected, Connecting, or Connected) — more informative than isConnected, which cannot distinguish “reconnecting” from “down”. isConnected is retained for compatibility. mode is Real or Simulated, letting a diagnostics client tell whether it is reading a live PLC or the in-memory simulation. The list is ordered by plcId (case-insensitive); earlier versions returned pool dictionary order, which was not guaranteed stable.

Get PLC Status

GET /api/plcs/{plcId}/status

Returns detailed status for a single PLC, including ADS state when connected.

curl http://localhost:5000/api/plcs/Line1/status
{
  "data": {
    "plcId": "Line1",
    "displayName": "Assembly Line 1",
    "isConnected": true,
    "adsState": "Run"
  },
  "error": null
}

Returns 404 with PLC_NOT_FOUND if the alias doesn’t exist.