User Tools

Site Tools


en:documentation:jsonrpc_reference

Python and JSON-RPC reference

This page contain reference for the JSON-RPC interface.

The program accept JSON-RPC 2.0 request on the port 3277 using both direct socket or HTTP POST.

For HTTP POST set your JSON-RPC procedure to use the following URL:

http://localhost:3277/jsonrpc

Python scripts

This JSON-RPC method are the basis for the Python scripts, both internal (launched from CCDciel) or external (launched from a terminal or another application).
A Python function is provided to simplify the use. The host,port parameters can be use to send the command to another instance of CCDciel.
The syntax is:

jsonresult = ccdciel(method)
jsonresult = ccdciel(method,parameter)
jsonresult = ccdciel(method,parameter,host,port)

For example:

from ccdciel import ccdciel
ra = ccdciel('TelescopeRA')['result']

To make Python to find this function in external script you must specify the environment variable PYTHONPATH:

set PYTHONPATH=C:\Program Files\CCDciel\scripts
export PYTHONPATH=/usr/share/ccdciel/scripts

Methods that return a value

The invocation format for this methods is: {“jsonrpc”: “2.0”, “method”: “method_name”, “id”:1}
The responses for this methods are in the form: {“jsonrpc”: “2.0”, “result”: result_value, “id”: 1}
Method name is not case sensitive.

Method nameResult typeResult value
Devices_connectedbool True if all the devices are connected
Camera_connected bool True if the camera is connected
CcdTempdoubleThe current CCD temperature
Preview_running bool True if the preview is running
Preview_loop_running bool True if the preview is in loop
Capture_running bool True if a capture is running
Telescope_connectedbool True if the telescope is connected
Telescope_eqmod bool True if the telescope use the EqMod driver
Telescope_parked bool True if the telescope is parked
Telescope_tracking bool True if the telescope is tracking
Telescope_slewing bool True if the telescope is slewing
TelescopeRAdoubleThe telescope position right ascension
TelescopeDEdoubleThe telescope position declination
Wheel_connected bool True if the filter wheel is connected
Focuser_connected bool True if the focuser is connected
FocuserPosition int The focuser absolute position
Autoguider_connected bool True if the auto-guider is connected
Autoguider_running bool True if the auto-guider is running
Autoguider_guiding bool True if the auto-guider is guiding
Planetarium_connected bool True if the planetarium is connected
TimeNowstringThe current local time on the computer running CCDciel
Obs_latitudedoubleThe observer latitude
Obs_longitudedoubleThe observer longitude
Obs_elevationdoubleThe observer elevation
DirectorySeparatorstringThe directory separator symbol on the computer running CCDciel
AppDirstringThe directory where the program is installed
TmpDirstringThe directory for temporary files
CaptureDirstringThe directory to save the images from capture sequence

Methods that invoke a command without parameter

The invocation format for this methods is: {“jsonrpc”: “2.0”, “method”: “method_name”, “id”:1}
The responses for this methods are in the form: {“jsonrpc”: “2.0”, “result”:{“status”: “OK!”}, “id”: 1}
Status can be “OK!” if the command is successful, or “Failed!” if not. In this later case it can contain information about why it fail.
Method name is not case sensitive.

Method nameFunction
Preview_single Start a single preview
Preview_loop Start a preview loop
Preview_waitloop Wait until the user stop the preview loop
Preview_stop Stop any in progress preview or preview loop
Capture_start Start a capture
Capture_stop Stop a capture
Telescope_track Start telescope tracking
Telescope_abortmotion Stop any telescope movement
Eqmod_clearpoints Clear EqMod alignment data
Eqmod_clearsyncdelta Clear Eqmod sync delta
Eqmod_stdsync Set Eqmod in Standard sync mode
Eqmod_appendsync Set Eqmod in Add point on sync mode
Wheel_getfilter Get the current filter number in the wheel
Autofocus Run auto-focus at the current position, same as the Autofocus button
AutomaticAutofocus Run auto-focus, same as invoked from a sequence, will eventually move to a bright star
Astrometry_solve Plate solve the current image
Astrometry_sync Plate solve the current image and sync the telescope
Astrometry_slew_image_center Plate solve the current image and slew the telescope
Autoguider_connect Connect to the autoguider software
Autoguider_calibrate Force a new calibration of the autoguider
Autoguider_startguiding Start to guide
Autoguider_stopguiding Stop guiding
Autoguider_pause Pause guiding
Autoguider_unpause Restart after pause
Autoguider_dither Dither now
Autoguider_shutdown Close the autoguider program
Planetarium_connect Connect the planetarium software
Planetarium_showimage Plate solve the current image and show in planetarium
Planetarium_shutdown Close the planetarium software
Program_shutdown Close CCDciel
Clear_reference_image Remove the reference image


Methods that invoke a command with parameter

The invocation format for this methods is: {“jsonrpc”: “2.0”, “method”: “method_name”, “params”: [params], “id”:1}
The responses for this methods are in the form: {“jsonrpc”: “2.0”, “result”:{“status”: “OK!”}, “id”: 1}
Status can be “OK!” if the command is successful, or “Failed!” if not. In this later case it can contain information about why it fail.
Method name is not case sensitive.

Method nameParameterFunction
Devices_connection True / False Connect or disconnect the devices
Ccd_settemperature temp Set the CCD temperature
Preview_setexposure exp Set the preview exposure time
Preview_setbinning bin Set the preview binning
Capture_setexposure exp Set the capture exposure
Capture_setbinning bin Set the capture binning
Capture_setobjectname name Set the capture object name
Capture_setcount count Set the capture image count
Capture_setframetype Light/Bias/Dark/Flat Set the capture frame type
Capture_setdither count Set the capture Dither count
Sequence_start sequence Load and start the sequence
Telescope_slew [RA, DEC] Slew to specified coordinates, do not return until the slew is complete
Telescope_slewasync [RA, DEC] Slew to specified coordinates, return immediatelly
Telescope_sync [RA, DEC] Sync to specified coordinates
Telescope_park True / False Park or unpark the telescope
Wheel_setfilter number Set the filter number in the wheel
Focuser_setposition number Set the focuser absolute position
Planetarium_showimage_fov FOV [degree] Plate solve the current image and show in planetarium using the specified field of view
Eq2hz [RA, DEC] From apparent ra,dec, return alt,az coordinates. RA in hours, all other angle in degree
Hz2eq [AZ, ALT] From az,alt, return apparent ra,dec coordinates. RA in hours, all other angle in degree
Save_fits_file filename Save the FITS file
Open_fits_file filename Open the FITS file
Open_reference_image filename Load a reference image
LogMsg text Print text in CCDciel log

Specific status method

This method return a global program status with the same information as the Status web page.

methodstatus
paramsdevices planetarium autoguider safety weather dome mount camera wheel rotator focuser sequence capture log

The params field allow to filter the information send by the program.
When the params field is not specified the response include all the information.

Example:

$ telnet localhost 3277
Connected to localhost.
{"jsonrpc": "2.0", "method": "status", "params": ["camera","focuser"], "id": 2}

{"jsonrpc": "2.0", "result":{"camera": {"connected": true, "binning": "1x1", 
"frame": "0/0/1280/1024", "cooler": false, "temperature": 0.0}, 
"focuser": {"connected": true, "position": 37200, "temperature": 0.0, 
"focusermessage": "AutoFocus successful; 15:03:52 HFD=4.2"}}, "id": 2}

There is three way to get the status information:

en/documentation/jsonrpc_reference.txt · Last modified: 2021/08/28 15:10 by pch