User Tools

Site Tools


Sidebar

Home

Documentation

Tutorial

Reference Manual

Installation

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, this is not necessary when running the script from CCDciel:

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

Use the standard Python functions ( argv, getopt, argparse) to retrieve the script parameters. For example:

print ('Argument List:', str(sys.argv))

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
CCDciel_Versionarray [main version, short revision, full revision]
Devicesarray The driver and connection type for each defined device
Devices_connectedbool True if all the devices are connected
Camera_connected bool True if the camera is connected
Camera_getframe integer Camera frame [x,y,width,heigth]
CcdTempdoubleThe current CCD temperature
Preview_getexposuredouble Get the preview exposure time
Preview_getbinningstring Get the preview binning
Preview_running bool True if the preview is running
Preview_loop_running bool True if the preview is in loop
Capture_getexposuredouble Get the capture exposure
Capture_getbinningstring Get the capture binning
Capture_getobjectnamestring Get the capture object name
Capture_getcountinteger Get the capture image count
Capture_getframetypestring Get the capture frame type
Capture_getditherinteger Get the capture Dither count
Capture_running bool True if a capture is running
Capture_getLastfilenamestring The full path name of the last saved file
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_trackingrate string SIDEREAL, LUNAR, SOLAR, CUSTOM
Telescope_PierSide string pierEast, pierWest, pierUnknown, pierNotImplemented
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
Wheel_GetfiltersNamearray The name of the filters in the wheel
Focuser_connected bool True if the focuser is connected
FocuserPosition int The focuser absolute position
CoverStatusstring The status of the telescope cover
CalibratorStatusstring The status of the flat calibrator
CalibratorBrightnessint The brightness of the calibrator
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
Autoguider_Getlockposition x,y The current guide lock position
Internalguider_GetGuideExposure double The guider exposure time
Internalguider_GetSpectrofunctionbool The value of “Activate spectroscopy function”
Internalguider_GetSpectroSinglestarbool The value of “Activate single star guiding on fixed location”
Internalguider_GetSpectroChangeMultistarbool The value of “Change to multistar after the star is locked”
Internalguider_GetSpectroAstrometrybool The value of “Use astrometry to identify the target”
Internalguider_GetSpectroAstrometryExposuredouble The exposure time for the astrometry
Internalguider_GetSpectroSlitnamestring The selected slit name in the list of slit offset
Internalguider_GetSpectroGuidestaroffsetdouble, double The X,Y guide star offset relative to the target
Internalguider_GetSpectroMultistaroffsetdouble, double The current multi-star guide offset
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
HostOSstringThe operating system on the computer running CCDciel
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
Camera_Resetframe Reset the camera full frame ROI
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
Finder_Stoploop Stop the finder loop
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
Cover_open Open the telescope cover
Cover_close Close the telescope cover
Calibrator_light_off Turn flat calibrator light off
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
Astrometry_plot_dso Plate solve the current image and annotate DSO
Astrometry_plot_hyperleda Plate solve the current image and annotate DSO using the hyperleda catalog
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
CustomHeader_clear Delete all the custom header keywords


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
Camera_Setframe [x,y,width,height] Set the camera frame size (ROI)
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
Finder_Saveimage ON/OFF Activate the saving of finder image when looping
Finder_Startloop exposure time Start the finder loop with the given exposure time
Finder_Snapshot exposure time, filename, count Take a series of finder camera snapshot
Internalguider_Snapshot exposure time, filename, count Take a series of guide camera snapshot, guiding must be stopped before to use this command
Sequence_start sequence Load and start the sequence
Telescope_settrackingrate rate rate = SIDEREAL,LUNAR,SOLAR
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
Autoguider_Setlockposition x,y Set immediately the new guide lock position in PHD2 or Internal guider
Autoguider_Storelockposition x,y Store the guide lock position for the next time guiding is started
Internalguider_SetGuideExposuredouble Set the guider exposure time
Internalguider_SetSpectrofunctionbool Set the value of “Activate spectroscopy function”
Internalguider_SetSpectroSinglestarbool Set the value of “Activate single star guiding on fixed location”
Internalguider_SetSpectroChangeMultistarbool Set the value of “Change to multistar after the star is locked”
Internalguider_SetSpectroAstrometrybool Set the value of “Use astrometry to identify the target”
Internalguider_SetSpectroAstrometryExposuredouble Set the exposure time for the astrometry
Internalguider_SetSpectroSlitnamestring Select this slit name in list to set the slit offset
Internalguider_SetSpectroGuidestaroffsetdouble, double Set the X,Y guide star offset relative to the target
Internalguider_SetSpectroMultistaroffsetdouble, double Set the X,Y multi-star guide offset
Wheel_setfilter number Set the filter number in the wheel
Focuser_setposition number Set the focuser absolute position
SetFocusXY X,Y Select the star at position X,Y for focus operation
Get_Switch nickname,switchname Return the current value for the switch
Set_Switch nickname,switchname,value Set the value of the switch
Calibrator_light_onbrightnessLight the flat calibrator at the specified brightness
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
CustomHeader_add [key,value] Add a new custom header keyword with value. Replace the value if the key already exist
CustomHeader_del key Delete all the occurrence of this custom header keyword
CustomHeader key Return the value for this keyword

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: 2024/12/02 22:11 by pch