Add firmware and extension catalogues, configuration transactions, sample review and QML diagnostics. Preserve explicit authority, bounded retries and stop recovery in motor transport.
21 lines
1.7 KiB
JavaScript
21 lines
1.7 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import {before,after,test} from 'node:test';
|
|
import {createServer} from './support/vite-server.mjs';
|
|
let server,h;
|
|
before(async()=>{server=await createServer({appType:'custom',logLevel:'silent',server:{middlewareMode:true}});h=await server.ssrLoadModule('../../plugins/vesc/frontend/src/hallInputs.ts');});
|
|
after(async()=>{await server?.close();});
|
|
const config=(values)=>({configuration:{motor:{parameters:Object.entries(values).map(([name,value])=>({name,value,type:'integer',editor_scale:1}))}}});
|
|
test('Hall selected in FOC is configuration intent, never sensor presence or zero edges',()=>{
|
|
const v=h.hallConfiguration(config({motor_type:2,m_sensor_port_mode:0,foc_sensor_mode:2}));
|
|
assert.equal(v.use,'Холлы выбраны в настройках FOC');assert.deepEqual(v.inputs,[null,null,null]);assert.deepEqual(v.transitions,[null,null,null]);
|
|
});
|
|
test('Sensorless and a repaired contact cannot imply either disconnected or working',()=>{
|
|
const v=h.hallConfiguration(config({motor_type:2,m_sensor_port_mode:0,foc_sensor_mode:0}));
|
|
assert.equal(v.use,'Холлы не выбраны в настройках FOC');assert.deepEqual(v.inputs,[null,null,null]);
|
|
});
|
|
test('missing config or a different motor/port never confirms Hall use',()=>{
|
|
assert.equal(h.hallConfiguration(null).use,'Не прочитано');
|
|
assert.equal(h.hallConfiguration(config({motor_type:0,m_sensor_port_mode:0,foc_sensor_mode:2})).use,'См. параметры выбранного типа мотора');
|
|
assert.equal(h.hallConfiguration(config({motor_type:2,m_sensor_port_mode:1,foc_sensor_mode:2})).use,'Холлы не выбраны в настройках FOC');
|
|
});
|