import axiosInstance from '../interceptor'; /** * 对所有设备的指令 */ const generatorUri = 'DIOS/DEVICE/Generator'; interface DeviceActionMessage { deviceUri: string; reqName: string; reqParam: string; reqTransaction: string; reqClientID: string; } const resetAllDevices = async () => { const resetGenerator: DeviceActionMessage = { deviceUri: generatorUri, reqName: 'RESET', reqParam: ``, reqTransaction: '', reqClientID: '', }; try { console.log(`[deviceActions][resetAllDevices][重置高压发生器] ${JSON.stringify(resetGenerator)}`) const response = await axiosInstance.post('/auth/device/action', resetGenerator); if(response.data.code!='0x000000'){ throw new Error('返回码不是0x000000'); } } catch (error) { console.error(`[重置所有设备出错 ] `, error); throw error; } }; const setExpEnable = async () => { const enableGenerator: DeviceActionMessage = { deviceUri: generatorUri, reqName: 'SetExpEnable', reqParam: '', reqTransaction: '', reqClientID: '', }; try { console.log(`[deviceActions][setExpEnable][使能发生器曝光] ${JSON.stringify(enableGenerator)}`); const response = await axiosInstance.post('/auth/device/action', enableGenerator); if (response.data.code !== '0x000000') { throw new Error('返回码不是0x000000'); } } catch (error) { console.error(`[使能发生器曝光出错]`, error); throw error; } }; const setExpDisable = async () => { const disableGenerator: DeviceActionMessage = { deviceUri: generatorUri, reqName: 'SetExpDisable', reqParam: '', reqTransaction: '', reqClientID: '', }; try { console.log(`[deviceActions][setExpDisable][禁止发生器曝光] ${JSON.stringify(disableGenerator)}`); const response = await axiosInstance.post('/auth/device/action', disableGenerator); if (response.data.code !== '0x000000') { throw new Error('返回码不是0x000000'); } } catch (error) { console.error(`[禁止发生器曝光出错]`, error); throw error; } }; export { resetAllDevices, setExpEnable, setExpDisable };