### Send Goto Command via Websocket (Dwarf Wifi) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/README.md This JavaScript example demonstrates how to send a 'Goto' command to the Dwarf II telescope when connected via Dwarf wifi. It establishes a websocket connection, constructs the command using `startGoto`, and sends it using `socketSend`. The example includes event listeners for connection 'open', 'message', and 'error'. ```javascript import { startGoto, wsURL, DwarfIP, socketSend } from "dwarfii_api"; const socket = new WebSocket(wsURL(DwarfIP)); socket.addEventListener("open", () => { let planet = null; let RA = 10.6; let dec = 41.2; let lat = 40.0; let lon = 90.0; let options = startGoto(planet, RA, dec, lat, lon); socketSend(socket, options); }); socket.addEventListener("message", (event) => { let message = JSON.parse(event.data); console.log(message); }); socket.addEventListener("error", (message) => { console.log("error:", message); }); ``` -------------------------------- ### Install Dwarf II API Package Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/README.md This snippet shows the command to install the dwarfii_api package using npm. It is a prerequisite for using the library. ```bash npm install dwarfii_api ``` -------------------------------- ### Start Tracking Initialization (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/tracking.js.html Initializes the trace functionality for the DwarfII camera. This function prepares the camera for tracking operations by sending a specific initialization command. It does not require any input parameters and returns an options object. ```javascript import { traceInitCmd } from "./api_codes.js"; export function startTrace() { const options = { interface: traceInitCmd }; return options; } ``` -------------------------------- ### Start Time Lapse Photography - JavaScript Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/photo_video.js.html Initiates time-lapse photography on the telephoto camera. It requires interval time, duration, and an optional name. Defaults to a timestamped name if not provided. ```javascript export function startTimeLapse( intervalTime, outTime, name = `DWARF_TL_${nowLocalFileName()}` ) { // intervalTime value: 1s-60s const options = { interface: startTimelapseCmd, camId: telephotoCamera, interval: intervalTime, outTime: outTime, name: name, }; return options; } ``` -------------------------------- ### Start Goto Operation Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html Initiates a goto operation for the telescope, allowing it to move to specified coordinates or a celestial object. It supports targeting either by Right Ascension and Declination or by selecting a planet. ```APIDOC ## POST /api/goto ### Description Initiates a goto operation for the telescope, allowing it to move to specified coordinates or a celestial object. It supports targeting either by Right Ascension and Declination or by selecting a planet. ### Method POST ### Endpoint /api/goto ### Parameters #### Query Parameters - **planet** (number|null) - Optional - The celestial object to target (e.g., a planet ID). - **rightAscension** (string) - Required if `planet` is not specified - The Right Ascension coordinate. - **declination** (string) - Required if `planet` is not specified - The Declination coordinate. - **latitude** (number) - Required - The current latitude of the telescope. - **longitude** (number) - Required - The current longitude of the telescope. ### Request Example ```json { "planet": 1, "latitude": 34.0522, "longitude": -118.2437 } ``` ```json { "rightAscension": "10h00m00s", "declination": "+52deg00min00s", "latitude": 34.0522, "longitude": -118.2437 } ``` ### Response #### Success Response (200) - **interface** (number) - Command identifier. - **camId** (string) - Camera identifier. - **lon** (number) - Longitude used for the operation. - **lat** (number) - Latitude used for the operation. - **date** (string) - Timestamp of the operation. - **path** (string) - Path for logging or data storage. - **planet** (number) - The targeted planet ID (if applicable). - **ra** (string) - The targeted Right Ascension (if applicable). - **dec** (string) - The targeted Declination (if applicable). #### Response Example ```json { "interface": 10001, "camId": "telephotoCamera", "lon": -118.2437, "lat": 34.0522, "date": "2023-07-04T09:03:19Z", "path": "DWARF_GOTO_20230704090319", "planet": 1 } ``` ``` -------------------------------- ### Photo/Video Capture API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/photo_video.js.html Endpoints for capturing photos, starting and stopping video recordings, and managing time-lapse sequences. ```APIDOC ## POST /api/photo_video/takePhoto ### Description Captures a single photograph with specified camera settings. ### Method POST ### Endpoint /api/photo_video/takePhoto ### Parameters #### Query Parameters - **camera** (number) - Optional - Specifies the camera to use (default: `telephotoCamera`). - **photoMode** (number) - Optional - Sets the photo mode (default: `photoSingleShot`). - **count** (number) - Optional - The number of photos to capture (default: 1). - **name** (string) - Optional - The base name for the captured photo file (default: `DWARF_` followed by a local timestamp). ### Request Example ```json { "camera": 1, "photoMode": 0, "count": 1, "name": "MyPhoto_20231027" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the photo capture has been initiated. #### Response Example ```json { "message": "Photo capture initiated successfully." } ``` ## POST /api/photo_video/startVideo ### Description Starts recording video with a specified filename. ### Method POST ### Endpoint /api/photo_video/startVideo ### Parameters #### Query Parameters - **name** (string) - Optional - The base name for the video file (default: `DWARF_` followed by a local timestamp). ### Request Example ```json { "name": "MyVideo_20231027" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating video recording has started. #### Response Example ```json { "message": "Video recording started." } ``` ## POST /api/photo_video/stopVideo ### Description Stops the current video recording. ### Method POST ### Endpoint /api/photo_video/stopVideo ### Parameters None ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating video recording has stopped. #### Response Example ```json { "message": "Video recording stopped." } ``` ## POST /api/photo_video/startTimeLapse ### Description Starts a time-lapse recording. ### Method POST ### Endpoint /api/photo_video/startTimeLapse ### Parameters #### Query Parameters - **name** (string) - Optional - The base name for the time-lapse files (default: `DWARF_` followed by a local timestamp). ### Request Example ```json { "name": "MyTimeLapse_20231027" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating time-lapse recording has started. #### Response Example ```json { "message": "Time-lapse recording started." } ``` ## POST /api/photo_video/stopTimeLapse ### Description Stops the current time-lapse recording. ### Method POST ### Endpoint /api/photo_video/stopTimeLapse ### Parameters None ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating time-lapse recording has stopped. #### Response Example ```json { "message": "Time-lapse recording stopped." } ``` ``` -------------------------------- ### Start Telescope Goto Operation (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html Initiates a goto operation for the telescope. It accepts either planet coordinates or Right Ascension and Declination, along with location data. Returns an options object for the goto command. ```javascript export function startGoto( planet, rightAscension, declination, latitude, longitude ) { const options = { interface: startGotoCmd, camId: telephotoCamera, lon: longitude, lat: latitude, date: nowLocal(), path: `DWARF_GOTO_${nowLocalFileName()}`, }; if (planet !== undefined && planet !== null) { options.planet = planet; } else { options.ra = rightAscension; options.dec = declination; } return options; } ``` -------------------------------- ### Tracking API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html Endpoints for controlling object tracking. Allows starting and stopping tracking and tracing. ```APIDOC ## Tracking API ### Description Endpoints for managing object tracking functionalities. ### Endpoints - **startTracking**: Starts object tracking. - **stopTracking**: Stops object tracking. - **startTrace**: Starts tracing. ### Example Usage Refer to the specific endpoint documentation for detailed request/response formats. ``` -------------------------------- ### Astro Commands and Constants Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_codes.js.html Includes commands and constants for astronomical operations such as goto calibration, starting goto, and taking RAW astro photos. Also defines parameters for binning, file formats, RAW preview, and dark frames. ```TypeScript export const calibrateGotoCmd = 11205; export const startGotoCmd = 11203; export const planetsValueId = { Mercury: 0, Venus: 1, Mars: 2, Jupiter: 3, Saturn: 4, Uranus: 5, Neptune: 6, Moon: 7, }; export const planetsIdValue = { 0: "Mercury", 1: "Venus", 2: "Mars", 3: "Jupiter", 4: "Saturn", 5: "Uranus", 6: "Neptune", 7: "Moon", }; export const takeAstroPhotoCmd = 10011; export const stopAstroPhotoCmd = 10015; export const binning1x1 = 0; export const binning2x2 = 1; export const fileFits = 0; export const fileTiff = 1; export const numberRawImagesCmd = 10014; export const numberSuperImposedImages = 10023; export const setRAWPreviewCmd = 10020; export const rawPreviewContinousSuperimpose = 0; export const rawPreviewSingle15 = 1; export const rawPreviewSingleComposite = 2; export const takeAstroDarkFramesCmd = 10026; export const darkGainDefault = 65528; export const queryShotFieldCmd = 10027; ``` -------------------------------- ### Send Goto Command via WebSocket in Dwarf II API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/index.html Demonstrates how to send a 'Goto' command to the Dwarf II telescope using WebSockets. It imports necessary functions like `startGoto`, `wsURL`, `DwarfIP`, and `socketSend` from the `dwarfii_api` library. The example establishes a WebSocket connection, constructs the Goto options, and sends them over the socket, also showing how to log received messages. ```javascript import { startGoto, wsURL, DwarfIP, socketSend } from "dwarfii_api"; const socket = new WebSocket(wsURL(DwarfIP)); socket.addEventListener("open", () => { let planet = null; let RA = 10.6; let dec = 41.2; let lat = 40.0; let lon = 90.0; let options = startGoto(planet, RA, dec, lat, lon); socketSend(socket, options); }); socket.addEventListener("message", (event) => { let message = JSON.parse(event.data); console.log(message); }); ``` -------------------------------- ### Photo and Video Capture API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/module-photo_video.html This section details the API endpoints for capturing photos, starting and stopping video recordings, and managing time-lapse photography. ```APIDOC ## POST /api/photo_video/takePhoto ### Description Takes a single photograph. ### Method POST ### Endpoint /api/photo_video/takePhoto ### Parameters #### Request Body - **name** (string) - Required - The name for the photo file. ### Request Example ```json { "name": "my_photo_001" } ``` ### Response #### Success Response (200) - **result** (string) - Indicates the success or failure of the operation. #### Response Example ```json { "result": "success" } ``` ## POST /api/photo_video/startVideo ### Description Starts recording a video. ### Method POST ### Endpoint /api/photo_video/startVideo ### Parameters #### Request Body - **name** (string) - Required - The name for the video file. ### Request Example ```json { "name": "my_video_001" } ``` ### Response #### Success Response (200) - **result** (string) - Indicates the success or failure of the operation. #### Response Example ```json { "result": "success" } ``` ## POST /api/photo_video/stopVideo ### Description Stops the current video recording. ### Method POST ### Endpoint /api/photo_video/stopVideo ### Parameters None ### Response #### Success Response (200) - **result** (string) - Indicates the success or failure of the operation. #### Response Example ```json { "result": "success" } ``` ## POST /api/photo_video/startTimeLapse ### Description Starts a time-lapse recording. ### Method POST ### Endpoint /api/photo_video/startTimeLapse ### Parameters #### Request Body - **intervalTime** (number) - Required - The interval between each shot in seconds. - **outTime** (number) - Required - The total duration of the time-lapse in seconds. - **name** (string) - Required - The base name for the time-lapse sequence files. ### Request Example ```json { "intervalTime": 5, "outTime": 300, "name": "my_timelapse_001" } ``` ### Response #### Success Response (200) - **result** (string) - Indicates the success or failure of the operation. #### Response Example ```json { "result": "success" } ``` ## POST /api/photo_video/stopTimeLapse ### Description Stops the current time-lapse recording. ### Method POST ### Endpoint /api/photo_video/stopTimeLapse ### Parameters None ### Response #### Success Response (200) - **result** (string) - Indicates the success or failure of the operation. #### Response Example ```json { "result": "success" } ``` ``` -------------------------------- ### Photo and Video Capture Commands Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_codes.js.html Defines constants for taking photos and recording videos. Includes commands for single shot, continuous shooting, starting and stopping recording, and timelapse photography. ```TypeScript export const previewImageQuality = 10016; export const takePhotoCmd = 10006; export const photoSingleShot = 0; export const photoContinuous = 1; export const startRecordingCmd = 10007; export const stopRecordingCmd = 10009; export const startTimelapseCmd = 10018; export const stopTimelapseCmd = 10019; ``` -------------------------------- ### Start Tracking with Coordinates (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/tracking.js.html Initiates object tracking on the DwarfII camera by specifying a region of interest. This function takes the x and y coordinates of the top-left corner, along with the width and height of the tracking window, as input. It returns an options object containing the tracking command and camera ID. ```javascript import { startTrackingCmd, telephotoCamera, } from "./api_codes.js"; export function startTracking(x, y, width, height) { // x 0-1920 // y 0-1080 // w 0-1920 // h 0-1080 const options = { interface: startTrackingCmd, camId: telephotoCamera, x, y, w: width, h: height, }; return options; } ``` -------------------------------- ### Start Panorama with Panoramic Module Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/panoramic.js.html Initiates a panorama capture sequence using the DwarfII camera. This function requires detailed parameters for grid dimensions, step sizes, speeds, pulse durations, and acceleration steps. It utilizes internal commands and utility functions for file naming. ```javascript import { startPanoCmd, stopPanoCmd } from "./api_codes.js"; import { nowLocalFileName } from "./api_utils.js"; /** * 4.3.1 Start panorama * @param {number} numRows * @param {number} numColumns * @param {number} mStep1 * @param {number} mStep2 * @param {number} speed1 * @param {number} speed2 * @param {number} pulse1 * @param {number} pulse2 * @param {number} accelStep1 * @param {number} accelStep2 * @returns {Object} */ export function startPano( numRows, numColumns, mStep1, mStep2, speed1, speed2, pulse1, pulse2, accelStep1, accelStep2 ) { // mStep 1 2 4 8 16 32 64 128 256 // speed 0-1000*mStep // pulse >=2 // accelStep 0-1000 const options = { interface: startPanoCmd, row: numRows, col: numColumns, mStep1, mStep2, speed1, speed2, pulse1, pulse2, accelStep1, accelStep2 }; return options; } /** * 4.3.2 Stop panorama * @returns {Object} */ export function stopPano() { const options = { interface: stopPanoCmd }; return options; } ``` -------------------------------- ### Tracking Control Commands Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_codes.js.html Constants for controlling the tracking functionality. This includes commands to initialize tracking, start tracking, and stop tracking. ```TypeScript export const traceInitCmd = 11200; export const startTrackingCmd = 11201; export const stopTrackingCmd = 11202; ``` -------------------------------- ### Photo/Video API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html Endpoints for controlling photo and video capture. Allows starting and stopping time-lapses and videos, as well as taking single photos. ```APIDOC ## Photo/Video API ### Description Endpoints for managing photo and video capture functionalities. ### Endpoints - **takePhoto**: Takes a single photo. - **startVideo**: Starts video recording. - **stopVideo**: Stops video recording. - **startTimeLapse**: Starts time-lapse capture. - **stopTimeLapse**: Stops time-lapse capture. ### Example Usage Refer to the specific endpoint documentation for detailed request/response formats. ``` -------------------------------- ### Take Astro Photo via Websocket (Dwarf STA Mode) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/README.md This JavaScript example shows how to send a command to take an astro photo using the Dwarf II in STA mode. It requires the telescope's IP address. The code establishes a websocket connection, prepares the command using `takeAstroPhoto` with options like binning and file format, and sends it via `socketSend`. It also includes handlers for websocket events. ```javascript import { wsURL, socketSend, binning2x2, takeAstroPhoto, fileFits, } from "dwarfii_api"; let myIP = "192.123.45.6"; const socket = new WebSocket(wsURL(myIP)); socket.addEventListener("open", () => { let RA = 10.6; let dec = 41.2; let exposure = 10; let gain = 60; let count = 100; let options = takeAstroPhoto( RA, dec, exposure, gain, binning2x2, count, fileFits ); socketSend(socket, options); }); socket.addEventListener("message", (event) => { let message = JSON.parse(event.data); console.log(message); }); socket.addEventListener("error", (message) => { console.log("error:", message); }); ``` -------------------------------- ### Start Motion Control (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/motion_control.js.html Initiates motion for the telescope. It supports both continuous and pulse modes, with configurable speed, direction, and acceleration. The function takes parameters for motor selection, mode, step settings, speed, direction, pulse count, and acceleration steps. ```javascript import { startMotionCmd, stopMotionCmd, setSpeedCmd, setDirectionCmd, setSubdivideCmd, } from "./api_codes.js"; /** * 5.1 Start * @param {number} motor * @param {number} mode * @param {number} mStep * @param {number} speed * @param {number} direction * @param {number} pulse * @param {number} accelStep * @returns {Object} */ export function startMotion( motor, mode, mStep, speed, direction, pulse, accelStep ) { // motor: 1:spin 2:pitch // mode: 1:continuous mode 2:pulse mode // mStep: 1 2 4 8 16 32 64 128 256 // speed: range:0-65536(1-50000&&<1000*mStep) // direction: 0:anticlockwise 1:clockwise // pulse: range:>=2(mStep<=32)>=5(mStep>32) // accelStep: 0-1000 const options = { interface: startMotionCmd, id: motor, mode, mStep, speed, accelStep, direction, ``` -------------------------------- ### Motion Control Commands Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_codes.js.html Defines commands and constants for controlling the motion system. This covers starting and stopping motion, setting speed and direction, subdividing steps, and selecting specific motors (spin or pitch). ```TypeScript export const startMotionCmd = 10100; export const continuous_mode = 1; export const pulse_mode = 2; export const stopMotionCmd = 10101; export const setSpeedCmd = 10107; export const speedDecelerate = 0; export const speedAccelerate = 1; export const setDirectionCmd = 10108; export const anticlockwise = 0; export const clockwise = 1; export const setSubdivideCmd = 10109; export const spinMotor = 1; export const pitchMotor = 2; ``` -------------------------------- ### Get Local Time for Filename (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_utils.js.html Retrieves the current local time formatted as 'yyyymmddhhmmss' suitable for use in filenames. It relies on the `nowLocal` function to get the time and then formats it. Returns undefined if time parsing fails. ```javascript /** * Returns the now local time as 'yyyymmddhhmmss' * @returns {string|undefined} */ export function nowLocalFileName() { let matches = nowLocal().match(/\d+/g); if (matches) { return matches.join(""); } } ``` -------------------------------- ### startMotion API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/module-motion_control.html Initiates motion for a specified motor with various control parameters. ```APIDOC ## POST /api/motion/startMotion ### Description Starts the motion of a motor with specified mode, step, speed, direction, pulse, and acceleration. ### Method POST ### Endpoint /api/motion/startMotion ### Parameters #### Request Body - **motor** (number) - Required - The motor identifier. - **mode** (number) - Required - The motion mode. - **mStep** (number) - Required - The number of steps for the motion. - **speed** (number) - Required - The speed of the motion. - **direction** (number) - Required - The direction of the motion. - **pulse** (number) - Required - The pulse width. - **accelStep** (number) - Required - The acceleration steps. ### Request Example { "motor": 1, "mode": 0, "mStep": 1000, "speed": 500, "direction": 1, "pulse": 200, "accelStep": 50 } ### Response #### Success Response (200) - **result** (Object) - Indicates the success of the operation. #### Response Example { "result": { "success": true } } ``` -------------------------------- ### startGoto API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/module-astro.html Initiates a goto operation for the telescope, allowing it to move to a specified celestial object or coordinate. This function supports targeting planets by name or by precise celestial coordinates. ```APIDOC ## POST /api/startGoto ### Description Starts a goto operation to a specified celestial target. ### Method POST ### Endpoint /api/startGoto ### Parameters #### Request Body - **planet** (number | null) - Optional - The ID of the planet to go to, or null for custom coordinates. - **rightAscension** (string) - Required - The right ascension coordinate (e.g., 'HH:MM:SS.ss'). - **declination** (string) - Required - The declination coordinate (e.g., '+DD:MM:SS.s'). - **latitude** (number) - Required - The observer's latitude. - **longitude** (number) - Required - The observer's longitude. ### Request Example ```json { "planet": null, "rightAscension": "10:30:00.00", "declination": "+60:00:00.0", "latitude": 34.0522, "longitude": -118.2437 } ``` ### Response #### Success Response (200) - **result** (Object) - An object containing the status of the goto operation. #### Response Example ```json { "result": { "status": "success" } } ``` ``` -------------------------------- ### Panoramic API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html Endpoints for controlling the panoramic feature of the telescope. Allows starting and stopping panoramic captures. ```APIDOC ## Panoramic API ### Description Endpoints for controlling panoramic image capture. ### Endpoints - **startPano**: Starts the panoramic capture. - **stopPano**: Stops the panoramic capture. ### Example Usage Refer to the specific endpoint documentation for detailed request/response formats. ``` -------------------------------- ### Panoramic Shot Commands Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_codes.js.html Commands for capturing panoramic images. Includes functions to start and stop panoramic shooting sequences. ```TypeScript export const startPanoCmd = 10103; export const stopPanoCmd = 10106; ``` -------------------------------- ### GET formatUtcUrl Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/astro.js.html This endpoint retrieves the UTC+0 time. It constructs a URL using the provided IP address and the current UTC time. ```APIDOC ## GET formatUtcUrl ### Description Retrieves the UTC+0 time by combining the IP address with the current UTC timestamp. ### Method GET ### Endpoint /formatUtcUrl ### Parameters #### Query Parameters - **IP** (string) - Required - The IP address to construct the URL. ### Request Example ``` /formatUtcUrl?IP=192.168.1.1 ``` ### Response #### Success Response (200) - **url** (string) - The complete URL with the UTC timestamp. #### Response Example ```json "http://192.168.1.1/utc/2024-01-01T00:00:00Z" ``` ``` -------------------------------- ### Tracking API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/tracking.js.html Endpoints for initiating and managing object tracking with the Dwarf II telescope. ```APIDOC ## Tracking API ### Description APIs for initiating and managing object tracking with the Dwarf II telescope. ### Endpoints #### POST /api/tracking/startTrace ##### Description Initializes trace functionality for tracking. ##### Method POST ##### Endpoint /api/tracking/startTrace ##### Parameters None ##### Request Body None ##### Request Example ```json { "interface": "traceInitCmd" } ``` ##### Response ###### Success Response (200) - **interface** (string) - Command identifier for trace initialization. ##### Response Example ```json { "interface": "traceInitCmd" } ``` #### POST /api/tracking/startTracking ##### Description Starts tracking a specified object within the camera's field of view. ##### Method POST ##### Endpoint /api/tracking/startTracking ##### Parameters ###### Path Parameters None ###### Query Parameters None ###### Request Body - **x** (number) - Required - The x-coordinate of the object's bounding box. - **y** (number) - Required - The y-coordinate of the object's bounding box. - **width** (number) - Required - The width of the object's bounding box. - **height** (number) - Required - The height of the object's bounding box. ##### Request Example ```json { "interface": "startTrackingCmd", "camId": "telephotoCamera", "x": 100, "y": 200, "w": 50, "h": 50 } ``` ##### Response ###### Success Response (200) - **interface** (string) - Command identifier for starting tracking. - **camId** (string) - Identifier for the camera used for tracking. - **x** (number) - The x-coordinate of the tracked object. - **y** (number) - The y-coordinate of the tracked object. - **w** (number) - The width of the tracked object's bounding box. - **h** (number) - The height of the tracked object's bounding box. ##### Response Example ```json { "interface": "startTrackingCmd", "camId": "telephotoCamera", "x": 100, "y": 200, "w": 50, "h": 50 } ``` #### POST /api/tracking/stopTracking ##### Description Stops the current tracking operation. ##### Method POST ##### Endpoint /api/tracking/stopTracking ##### Parameters None ##### Request Body None ##### Request Example ```json { "interface": "stopTrackingCmd" } ``` ##### Response ###### Success Response (200) - **interface** (string) - Command identifier for stopping tracking. ##### Response Example ```json { "interface": "stopTrackingCmd" } ``` ``` -------------------------------- ### Turn On Camera (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/image_transmission.js.html Turns on the camera with specified binning and camera ID. Default values are provided for convenience. This function constructs a command object for the camera. ```javascript import { telephotoCamera, binning2x2, turnOnCameraCmd, } from "./api_codes.js"; export function turnOnCamera(binning = binning2x2, camera = telephotoCamera) { const options = { interface: turnOnCameraCmd, camId: camera, binning: binning, }; return options; } ``` -------------------------------- ### Tracking API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/module-tracking.html Provides methods for initiating and controlling object tracking with the Dwarf II telescope. ```APIDOC ## Tracking API This API provides functionalities to control object tracking on the Dwarf II telescope. ### Methods #### GET /tracking/trace ##### Description Initializes the trace functionality for tracking. ##### Method GET ##### Endpoint /tracking/trace ##### Parameters None ##### Request Example None ##### Response ###### Success Response (200) - **status** (string) - Indicates the success of the operation. ###### Response Example ```json { "status": "trace initialized" } ``` #### POST /tracking/start ##### Description Starts object tracking at a specified position and bounding box. ##### Method POST ##### Endpoint /tracking/start ##### Parameters ###### Request Body - **x** (number) - Required - The x-coordinate of the tracking start point. - **y** (number) - Required - The y-coordinate of the tracking start point. - **width** (number) - Required - The width of the bounding box for tracking. - **height** (number) - Required - The height of the bounding box for tracking. ##### Request Example ```json { "x": 100, "y": 150, "width": 50, "height": 75 } ``` ##### Response ###### Success Response (200) - **status** (string) - Indicates the success of the tracking start operation. ###### Response Example ```json { "status": "tracking started" } ``` #### DELETE /tracking/stop ##### Description Stops the current object tracking operation. ##### Method DELETE ##### Endpoint /tracking/stop ##### Parameters None ##### Request Example None ##### Response ###### Success Response (200) - **status** (string) - Indicates the success of the tracking stop operation. ###### Response Example ```json { "status": "tracking stopped" } ``` ``` -------------------------------- ### Get IR Settings (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/camera_settings.js.html Retrieves the IRCUT state for the telephoto camera, specifically when shooting raw images. This function returns an options object for the API. It depends on 'statusIRTelephotoCmd' and 'telephotoCamera' from './api_codes.js'. ```javascript import { telephotoCamera, statusIRTelephotoCmd, } from "./api_codes.js"; /** * Get telephoto IRCUT state (when shooting raw). * @returns {Object} - An object containing interface and camId for the API command. */ export function iRSettings() { const options = { interface: statusIRTelephotoCmd, camId: telephotoCamera }; return options; } ``` -------------------------------- ### Astro Module API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/photo_video.js.html Endpoints for astrophotography, including calibration, target acquisition, and image capture. ```APIDOC ## POST /api/astro/calibrateGoto ### Description Calibrates the goto system for accurate positioning. ### Method POST ### Endpoint /api/astro/calibrateGoto ### Parameters None ### Response #### Success Response (200) - **message** (string) - Confirmation of calibration initiation. #### Response Example ```json { "message": "Goto calibration initiated." } ``` ## POST /api/astro/startGoto ### Description Initiates the goto command to move the telescope to a specified celestial coordinate. ### Method POST ### Endpoint /api/astro/startGoto ### Parameters #### Request Body - **ra** (string) - Required - Right Ascension coordinate. - **dec** (string) - Required - Declination coordinate. - **coord_type** (string) - Optional - Type of coordinate system (e.g., "EQUATORIAL"). ### Request Example ```json { "ra": "10h30m0s", "dec": "+15d0m0s", "coord_type": "EQUATORIAL" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of goto command execution. #### Response Example ```json { "message": "Goto command executed." } ``` ## POST /api/astro/takeAstroPhoto ### Description Takes an astronomical photograph with specified parameters. ### Method POST ### Endpoint /api/astro/takeAstroPhoto ### Parameters #### Request Body - **exp_time** (number) - Required - Exposure time in seconds. - **iso** (number) - Required - ISO sensitivity. - **name** (string) - Optional - Base name for the image file. ### Request Example ```json { "exp_time": 30, "iso": 800, "name": "AstroImage_20231027" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of astro photo capture initiation. #### Response Example ```json { "message": "Astro photo capture initiated." } ``` ## POST /api/astro/takeAstroDarks ### Description Captures dark frames for calibration purposes. ### Method POST ### Endpoint /api/astro/takeAstroDarks ### Parameters #### Request Body - **exp_time** (number) - Required - Exposure time in seconds for dark frames. - **count** (number) - Required - Number of dark frames to capture. - **name** (string) - Optional - Base name for the dark frame files. ### Request Example ```json { "exp_time": 60, "count": 10, "name": "DarkFrame_20231027" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of dark frame capture initiation. #### Response Example ```json { "message": "Dark frame capture initiated." } ``` ## POST /api/astro/stopAstroPhoto ### Description Stops the current astronomical photograph or dark frame capture. ### Method POST ### Endpoint /api/astro/stopAstroPhoto ### Parameters None ### Response #### Success Response (200) - **message** (string) - Confirmation that the capture has been stopped. #### Response Example ```json { "message": "Astro capture stopped." } ``` ## POST /api/astro/queryShotField ### Description Queries information about the current field of view for astrophotography. ### Method POST ### Endpoint /api/astro/queryShotField ### Parameters None ### Response #### Success Response (200) - **data** (object) - Contains information about the current field (e.g., coordinates, star data). #### Response Example ```json { "data": { "ra": "10h30m0s", "dec": "+15d0m0s", "stars": [ {"name": "Star A", "ra": "...", "dec": "..."} ] } } ``` ## POST /api/astro/updateRawPreviewSource ### Description Updates the source for raw preview images. ### Method POST ### Endpoint /api/astro/updateRawPreviewSource ### Parameters #### Request Body - **source** (string) - Required - The desired source for raw previews (e.g., "telephoto", "wideangle"). ### Request Example ```json { "source": "telephoto" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation of the raw preview source update. #### Response Example ```json { "message": "Raw preview source updated." } ``` ## POST /api/astro/formatUtcUrl ### Description Formats a UTC URL for accessing astronomical data or images. ### Method POST ### Endpoint /api/astro/formatUtcUrl ### Parameters #### Request Body - **year** (number) - Required - The year. - **month** (number) - Required - The month (1-12). - **day** (number) - Required - The day. - **hour** (number) - Required - The hour (0-23). - **minute** (number) - Required - The minute (0-59). - **second** (number) - Required - The second (0-59). - **source_type** (string) - Required - The type of source (e.g., "preview", "raw"). ### Request Example ```json { "year": 2023, "month": 10, "day": 27, "hour": 12, "minute": 30, "second": 0, "source_type": "preview" } ``` ### Response #### Success Response (200) - **url** (string) - The formatted UTC URL. #### Response Example ```json { "url": "https://api.example.com/data?timestamp=2023-10-27T12:30:00Z&type=preview" } ``` ``` -------------------------------- ### System Settings API Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/photo_video.js.html Endpoint for system-level operations like shutting down the device. ```APIDOC ## POST /api/system_settings/shutDown ### Description Initiates a system shutdown of the device. ### Method POST ### Endpoint /api/system_settings/shutDown ### Parameters None ### Response #### Success Response (200) - **message** (string) - Confirmation that the shutdown process has started. #### Response Example ```json { "message": "System shutdown initiated. Device will power off shortly." } ``` ``` -------------------------------- ### Get Camera Working State (JavaScript) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/camera_settings.js.html Returns the current working state of the camera. This function is intended to be used with a camera identifier, although the provided snippet is incomplete. It would likely return an options object for an API call. ```javascript /** * Returns to the camera working state. * @param {number} camera - The camera identifier. */ export function cameraWorkingState(camera) { // Function implementation is missing in the provided text. // Expected to return an object similar to cameraSettings. } ``` -------------------------------- ### Get Current UTC Time String (api_utils.js) Source: https://github.com/dwarftelescopeusers/dwarfii_api/blob/main/docs/api_utils.js.html Retrieves the current Coordinated Universal Time (UTC) and formats it as a 'yyyy-mm-dd hh:mm:ss' string. This function is useful for logging or timestamping events accurately on a global scale. It does not require any external dependencies. ```javascript export function nowUTC() { return new Date().toISOString().replace("T", " ").slice(0, 19); } ```