Retain K1 connection between scans and admit the next named acquisition
This commit is contained in:
@@ -2,19 +2,13 @@ import type {Sensor} from './runtime';
|
||||
|
||||
export function k1Status(device:Sensor,fresh:boolean):{label:string;tone:'neutral'|'success'|'warning'|'danger'} {
|
||||
if(!fresh)return {label:'Нет свежих сведений с БК',tone:'neutral'};
|
||||
if(device.control?.phase==='completed'&&device.snapshot.acquisition==='idle')return {label:'Устройство остановлено',tone:'neutral'};
|
||||
if(!device.online||!device.verified)return device.control?.network_applied
|
||||
?{label:'Wi-Fi настроен · нет управления',tone:'warning'}:{label:'Связь не подтверждена',tone:'neutral'};
|
||||
if(device.snapshot.acquisition==='failed')return {label:'Ошибка захвата',tone:'danger'};
|
||||
if(device.snapshot.acquisition==='streaming')return {label:'Идёт захват',tone:'success'};
|
||||
if(['preparing','starting'].includes(device.snapshot.acquisition))return {label:'Запускается',tone:'neutral'};
|
||||
if(device.snapshot.acquisition==='stopping')return {label:'Останавливается',tone:'neutral'};
|
||||
return {label:device.control?.can_start?'Готов к запуску':'Подключён',tone:'success'};
|
||||
?{label:'Нет связи с K1',tone:'warning'}:{label:'Связь не подтверждена',tone:'neutral'};
|
||||
return {label:'Подключён',tone:'success'};
|
||||
}
|
||||
|
||||
export function k1ConnectionNotice(device:Sensor,fresh:boolean):string {
|
||||
if(!fresh)return 'Нет свежих сведений с БК. Ожидаем восстановления связи.';
|
||||
if(device.control?.phase==='completed')return 'Устройство остановлено. Проверьте связь с K1 перед следующим запуском; повторно вводить настройки Wi-Fi не нужно.';
|
||||
if(device.control?.reason_code==='application_authority_unavailable')
|
||||
return 'Wi-Fi настроен. Служба K1 на БК не смогла авторизовать подключение. Обновите интеграцию K1 на БК и проверьте состояние устройства.';
|
||||
return device.control?.network_applied
|
||||
|
||||
@@ -1516,13 +1516,14 @@ export function useXgridsK1Runtime(enabled: boolean) {
|
||||
);
|
||||
}
|
||||
|
||||
if (["idle", "closed", "completed"].includes(phase)) {
|
||||
if (["idle", "closed"].includes(phase)) {
|
||||
throw new ApiError(
|
||||
"K1 ещё не подключён. Сначала завершите подключение устройства в «Парке».",
|
||||
);
|
||||
}
|
||||
|
||||
if (phase === "connection-ready") {
|
||||
if (phase === "connection-ready" || (phase === "completed"
|
||||
&& nextState.application_control_session?.control_socket_open === true)) {
|
||||
const physical = nextState.application_control_session?.physical_command
|
||||
?? nextState.physical_command;
|
||||
if (physical?.requires_reconciliation === true) {
|
||||
|
||||
Reference in New Issue
Block a user