E-Stop IP
This commit is contained in:
@@ -182,6 +182,8 @@ describe('RobotConfig.load — emergencyStop (Shelly)', () => {
|
||||
test('DEFAULTS.controllers.emergencyStop hat protocol=shelly und url=null', () => {
|
||||
expect(DEFAULTS.controllers.emergencyStop.protocol).toBe('shelly');
|
||||
expect(DEFAULTS.controllers.emergencyStop.url).toBeNull();
|
||||
expect(DEFAULTS.controllers.emergencyStop.urlOn).toBeNull();
|
||||
expect(DEFAULTS.controllers.emergencyStop.urlStatus).toBeNull();
|
||||
});
|
||||
|
||||
test('emergencyStop.url aus robot.json wird übernommen', () => {
|
||||
@@ -198,11 +200,39 @@ describe('RobotConfig.load — emergencyStop (Shelly)', () => {
|
||||
expect(cfg.controllers.emergencyStop.url).toBe(shellyUrl);
|
||||
});
|
||||
|
||||
test('emergencyStop.urlOn + urlStatus aus robot.json werden übernommen (IP statt .local)', () => {
|
||||
const base = 'http://192.168.0.99';
|
||||
const json = {
|
||||
...FULL_ROBOT_JSON,
|
||||
controllers: {
|
||||
...FULL_ROBOT_JSON.controllers,
|
||||
emergencyStop: {
|
||||
protocol: 'shelly',
|
||||
url: `${base}/rpc/Switch.Set?id=0&on=false`,
|
||||
urlOn: `${base}/rpc/Switch.Set?id=0&on=true`,
|
||||
urlStatus: `${base}/rpc/Switch.GetStatus?id=0`,
|
||||
}
|
||||
}
|
||||
};
|
||||
const cfg = load(makeFs(JSON.stringify(json)), {}, log);
|
||||
expect(cfg.controllers.emergencyStop.url).toBe(`${base}/rpc/Switch.Set?id=0&on=false`);
|
||||
expect(cfg.controllers.emergencyStop.urlOn).toBe(`${base}/rpc/Switch.Set?id=0&on=true`);
|
||||
expect(cfg.controllers.emergencyStop.urlStatus).toBe(`${base}/rpc/Switch.GetStatus?id=0`);
|
||||
});
|
||||
|
||||
test('SHELLY_URL Env-Variable überschreibt url aus robot.json', () => {
|
||||
const envUrl = 'http://192.168.0.99/rpc/Switch.Set?id=0&on=false';
|
||||
const cfg = load(makeFs(JSON.stringify(FULL_ROBOT_JSON)), { SHELLY_URL: envUrl }, log);
|
||||
expect(cfg.controllers.emergencyStop.url).toBe(envUrl);
|
||||
});
|
||||
|
||||
test('fehlendes emergencyStop in robot.json → url=null (Default)', () => {
|
||||
// FULL_ROBOT_JSON hat kein emergencyStop → fällt auf Default zurück
|
||||
const cfg = load(makeFs(JSON.stringify(FULL_ROBOT_JSON)), {}, log);
|
||||
expect(cfg.controllers.emergencyStop.protocol).toBe('shelly');
|
||||
expect(cfg.controllers.emergencyStop.url).toBeNull();
|
||||
expect(cfg.controllers.emergencyStop.urlOn).toBeNull();
|
||||
expect(cfg.controllers.emergencyStop.urlStatus).toBeNull();
|
||||
});
|
||||
|
||||
test('emergencyStop hat keine ip/port/axes/heartbeatInterval Felder', () => {
|
||||
|
||||
@@ -27,12 +27,12 @@ describe('ShellyEmergencyStop — Konstruktor', () => {
|
||||
expect(s.url).toBe(OFF_URL);
|
||||
});
|
||||
|
||||
test('_onUrl ersetzt on=false durch on=true', () => {
|
||||
test('_onUrl ersetzt on=false durch on=true (Ableitung)', () => {
|
||||
const s = new ShellyEmergencyStop(OFF_URL);
|
||||
expect(s._onUrl).toBe(ON_URL);
|
||||
});
|
||||
|
||||
test('_statusUrl zeigt auf Switch.GetStatus', () => {
|
||||
test('_statusUrl zeigt auf Switch.GetStatus (Ableitung)', () => {
|
||||
const s = new ShellyEmergencyStop(OFF_URL);
|
||||
expect(s._statusUrl).toBe(STATUS_URL);
|
||||
});
|
||||
@@ -49,6 +49,19 @@ describe('ShellyEmergencyStop — Konstruktor', () => {
|
||||
expect(s.state).toBe('ready');
|
||||
expect(s.error).toBeNull();
|
||||
});
|
||||
|
||||
test('urlOn/urlStatus aus options überschreiben Ableitungslogik (IP statt .local)', () => {
|
||||
// Typischer Docker-Use-case: url hat noch den .local-Hostnamen,
|
||||
// aber urlOn/urlStatus zeigen bereits auf die echte IP.
|
||||
const ipBase = 'http://192.168.0.99';
|
||||
const s = new ShellyEmergencyStop(OFF_URL, {
|
||||
urlOn: `${ipBase}/rpc/Switch.Set?id=0&on=true`,
|
||||
urlStatus: `${ipBase}/rpc/Switch.GetStatus?id=0`,
|
||||
});
|
||||
expect(s._offUrl).toBe(OFF_URL); // url bleibt
|
||||
expect(s._onUrl).toBe(`${ipBase}/rpc/Switch.Set?id=0&on=true`); // explizit
|
||||
expect(s._statusUrl).toBe(`${ipBase}/rpc/Switch.GetStatus?id=0`); // explizit
|
||||
});
|
||||
});
|
||||
|
||||
describe('ShellyEmergencyStop — SenderInterface', () => {
|
||||
|
||||
Reference in New Issue
Block a user