Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/routes/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ export const camera = (base: URL, init?: RequestInit, headers?: () => Promise<He
return dispatchRequest<T>(url, init, headers)
}
},
{
name: 'shutdown',
action: <
T = {
connected: boolean
pulseGuiding: boolean
coolerOn: boolean
coolerPower: number
CCDtemperature: number
heatSinkTemperature: number
state: string
}
>() => {
const url = new URL('camera/shutdown', base)

return dispatchRequest<T>(url, { ...init, method: 'PUT' }, headers)
}
},
{
name: 'getConfiguration',
action: <
Expand Down
16 changes: 16 additions & 0 deletions tests/camera.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,21 @@ suite('@observerly/hyper Fiber API Observing Camera Client', () => {
state: 'idle'
})
})

it('should be able to shutdown the camera', async () => {
const client = setupClient(getURL('/api/v1/'))
const status = await client.camera.shutdown()
expect(isDataResult(status)).toBe(true)
if (!isDataResult(status)) return
expect(status).toStrictEqual({
connected: false,
pulseGuiding: false,
coolerOn: false,
coolerPower: 0,
CCDtemperature: 0,
heatSinkTemperature: 0,
state: 'idle'
})
})
})
})
24 changes: 24 additions & 0 deletions tests/mocks/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ export const cameraHandlers: Handler[] = [
}
})
},
{
method: 'PUT',
url: '/api/v1/camera/shutdown',
handler: eventHandler(event => {
const method = getMethod(event)

if (method !== 'PUT') {
return new Response('Method Not Allowed', {
status: 405,
statusText: 'Method Not Allowed'
})
}

return {
connected: false,
pulseGuiding: false,
coolerOn: false,
coolerPower: 0,
CCDtemperature: 0,
heatSinkTemperature: 0,
state: 'idle'
}
})
},
{
method: 'GET',
url: '/api/v1/camera/config',
Expand Down