E-Stop IP

This commit is contained in:
chk
2026-06-12 18:59:56 +02:00
parent 3e3023fa63
commit bfb84fab50
8 changed files with 78 additions and 12 deletions

View File

@@ -17,8 +17,8 @@ const DEFAULTS = {
elbow: { ip: 'fluidNcEllbow.local', port: 5000, protocol: 'telnet', axes: ['a', null, null], heartbeatInterval: 10000 },
hand: { ip: 'fluidNcHand.local', port: 5000, protocol: 'telnet', axes: ['c', 'e', 'b'], heartbeatInterval: 10000 },
// Shelly Smart Plug: schaltet Strom für Emergency Stop.
// url: null → deaktiviert, wenn nicht in robot.json konfiguriert.
emergencyStop: { protocol: 'shelly', url: null }
// url/urlOn/urlStatus: null → deaktiviert, wenn nicht in robot.json konfiguriert.
emergencyStop: { protocol: 'shelly', url: null, urlOn: null, urlStatus: null }
}
};
@@ -87,10 +87,16 @@ function load(fsModule, processEnv, consoleObj) {
const cfg = jsonControllers[key] ?? {};
if (def.protocol === 'shelly') {
// Shelly Smart Plug: nur protocol + url nötig (kein IP/Port/Axes/Heartbeat)
// Shelly Smart Plug: protocol + drei URLs (off / on / status).
// SHELLY_URL überschreibt url aus robot.json (analog zu GRBL_BASE_IP).
// urlOn/urlStatus: explizit konfigurierbar; fehlen sie, leitet ShellyEmergencyStop
// sie aus url ab (url.replace('on=false','on=true') bzw. /rpc/Switch.GetStatus).
const envUrl = env_.SHELLY_URL;
controllers[key] = {
protocol: cfg.protocol ?? def.protocol,
url: cfg.url ?? def.url,
protocol: cfg.protocol ?? def.protocol,
url: envUrl ?? cfg.url ?? def.url,
urlOn: cfg.urlOn ?? def.urlOn,
urlStatus: cfg.urlStatus ?? def.urlStatus,
};
} else {
// Telnet (FluidNC): IP + Port + Achsen + Heartbeat

View File

@@ -25,9 +25,11 @@ module.exports = class ShellyEmergencyStop extends SenderInterface {
constructor(url, options = {}) {
super();
this._offUrl = url || null;
this._onUrl = url ? url.replace('on=false', 'on=true') : null;
// Switch.GetStatus?id=0 — leitet Status-URL aus der Switch.Set-URL ab
this._statusUrl = url ? url.replace(/\/rpc\/.*$/, '/rpc/Switch.GetStatus?id=0') : null;
// Explizite URL-Felder haben Vorrang vor Ableitungslogik.
// Das erlaubt IP-Adressen statt .local-Hostnamen (nötig in Docker-Umgebungen,
// wo mDNS nicht verfügbar ist).
this._onUrl = options.urlOn || (url ? url.replace('on=false', 'on=true') : null);
this._statusUrl = options.urlStatus || (url ? url.replace(/\/rpc\/.*$/, '/rpc/Switch.GetStatus?id=0') : null);
this.url = url || null; // für getStatus / InfoServer-Anzeige
this.state = 'ready';
this.error = null;