REM Cooling of the camera in minutes and degrees
minutestogodowntotemp=15
Detectortemperature=-20

REM difference between local time and UT
deltaUT=3

REM autoguiding
autoguide=FALSE
scoperecentering=FALSE

REM minimum height at which we will observe a star. 15 degrees=0.2618 radians
minimumheight=0.2618
REM minimum distance from the moon we can observe, here we take also 15 degrees.
minimummoondistance=0.2618
REM exposure time used for recentering the telescope, for now 5 seconds, or 5000ms
shortExptimeMS=5000
Shoes hauts Pompes Talons Vert Xianshu Big Thin Tie Heel Single Women Bow Pointed GuidingExpTime=10

REM Asking to start or not the telescope
question$="Is the telescope already started ?"
getyesno question$ telescopeparked

Gosub beginnighttime:
Gosub endnighttime:

REM Computing the time till the end of the night
now date
timeleft=endofnighttime-date
frac timeleft time
observingtimeleft=time*24
observingtimeleftmin=observingtimeleft*60
print "Remaining observing time : " observingtimeleft " hours or : " observingtimeleftmin " minutes"
REM In the unlikely case the script is started way too late.
if observingtimeleft<0 then
goto endnight:
endif

REM ***************************************************
REM parsing the first condition
REM ***************************************************
readnextline2:
ENDOFFILE scriptfile result
REM If we are not at the end of the file...
if result=FALSE then
ReadFileTxt scriptfile loop$
REM we split the line
REM the first line has to be a condition
cutstr loop$ " " 1 condition$

REM ************************************************
REM autoguide
REM ************************************************
if condition$="autoguide" then
cutstr loop$ " " 2 autoguideonoroff$
if autoguideonoroff$="on" then
autoguide=TRUE
print "Autoguiding will be performed on each exposure"
else
autoguide=FALSE
endif
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto readnextline2:
endif

REM ************************************************
REM autorecenter
REM ************************************************
if condition$="recenterscope" then
cutstr loop$ " " 2 recenteronoroff$
if recenteronoroff$="on" then
scoperecentering=TRUE
print "The telescope will be recentered after each slewing to a new position"
else
scoperecentering=FALSE
endif
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto readnextline2:
endif

REM dayfrac is the fractional part of the day
dayfrac=((waitminute/60)+waithour)/24
now date
frac date datefrac
int date dateint
enddate=dateint+dayfrac
REM if we are before midnight and the time limit is the following day
if datefrac>0.5 then
if dayfrac<0.5 then
enddate=dateint+dayfrac+1
endif
endif

startwait:
now date
CONVERTDATETOJULIAN date JJdate
if JJdate REM waiting one minute
NOW year month day hour minute seconde ms
Delay 60000
Print "It is now " hour ":" minute " continue waiting..."
WaitForEndDelay
goto startwait:
else
print "Ooops, wait finished, continuing with the script"
endif
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto nextsequence:
endif

REM ************************************************
REM OBSERVETILL
REM ************************************************
if condition$="observetill" then
REM We read the time till which the sequence must be run and we observe it
cutstr loop$ " " 2 numberofhours$
val numberofhours$ numberofhours
cutstr loop$ " " 3 numberofminutes$
val numberofminutes$ numberofminutes
numberofstarsinloop=0
REM I take UT into account
dayfrac=((numberofminutes/60)+numberofhours)/24
REM CAUTION : if it is past midnight(UT) and the script ask to observe till 23h, it will.
print
print " We are going to observe the following sequence till " numberofhours$ ":" numberofminutes$

readloop:
ReadFileTxt scriptfile star$
REM here we read the lines following the loop instructions, till we encounter an empty line.

REM From the star name we get the RA and Dec
for j=1 numberofstarsintargetlist
if star[numberofstarsinloop]$=starname[j]$ then
print "Star number " numberofstarsinloop " found, it is " starname[j]$
RA[numberofstarsinloop]=starRA[j]
Dec[numberofstarsinloop]=starDec[j]
print "Star RA in decimal : " RA[numberofstarsinloop] " star Dec in decimal : " Dec[numberofstarsinloop]
goto readloop:
endif
next j
REM do something in case the star has not been found
print "No stars have been found, check either target list or script file"
endif

if dayfrac>24 then
dayfrac=dayfrac-24
endif

now date
frac date datefrac
int date dateint
enddate=dateint+dayfrac
REM if we are before midnight and the time limit is the following day
if datefrac>0.5 then
if dayfrac<0.5 then
enddate=dateint+dayfrac+1
Shoes Pompes Tie Xianshu Heel Pointed hauts Talons Bow Big Thin Women Single Vert endif
endif

REM Stopping autoguiding
if autoguide=TRUE then
StopGuide_Ex 2 1
endif
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto nextsequence:
endif

REM we found a loop where we are going to make a sequence numberofcycle times
if condition$="loop" then
REM We read the number of time the sequence must be made and we make it
cutstr loop$ " " 2 numberofcycles$
val numberofcycles$ numberofcycles
print "We will run the following cycle " numberofcycles " times"
REM we read the stars to be observed during this cycle and increment the number of stars
numberofstarsinloop=0
readloop2:
ReadFileTxt scriptfile star$
REM here we read the lines following the loop instructions, till we encounter an empty line.
if star$<>"" then
numberofstarsinloop=numberofstarsinloop+1
REM we read a star name, the exposure time and the filter
cutstr star$ " " 1 star[numberofstarsinloop]$
cutstr star$ " " 2 exposuretime[numberofstarsinloop]$
cutstr star$ " " 3 filter[numberofstarsinloop]$
val exposuretime[numberofstarsinloop]$ exposuretime[numberofstarsinloop]
print star[numberofstarsinloop]$ " " exposuretime[numberofstarsinloop] " seconds with " filter[numberofstarsinloop]$ " filter"
REM From the star name we get the RA and Dec
for j=1 numberofstarsintargetlist
print "star[numberofstarsinloop]$" star[numberofstarsinloop]$
print "starname[j]$" starname[j]$
if star[numberofstarsinloop]$=starname[j]$ then
print "star number " numberofstarsinloop " found, it is " star[numberofstarsinloop]$
RA[numberofstarsinloop]=starRA[j]
Dec[numberofstarsinloop]=starDec[j]
print "star RA in decimal : " RA[numberofstarsinloop] " star Dec in decimal : " Dec[numberofstarsinloop]
goto readloop2:
endif
next j
REM do something in case the star has not been found
endif
REM now we loop numberofcycles time, moving the telescope, exposing, saving the image, moving the telescope, etc...
for i=1 numberofcycles
gosub expose:
next i
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto nextsequence:
endif

REM now we loop through the cycle till the reference star is above or below the required altitude.
checkaltitude:
now date
GETHEIGHT radRAref radDecref Date Longitude Latitude heightref
degheightref=heightref*todeg
print
print star[numberofstarsinloop]$ " is at " degheightref " degrees of altitude"
if refstarabove=1 then
REM we check that the reference star is still above the reference height
if degheightref print "the reference star is now below the limit, moving to next sequence"
goto nextsequence:
endif
else
REM we check that the reference star is still below the reference height
if degheightref>limitheightdeg then
print "the reference star is now above the limit, moving to next sequence"
goto nextsequence:
endif
endif
gosub expose:
goto checkaltitude:
endif
REM we read the next empty line to be able to read the next instruction later
ReadFileTxt scriptfile loop$
goto nextsequence:
endif
Thin Single Pointed Big Heel Shoes Women Pompes Xianshu Tie hauts Talons Bow Vert

REM ************************************************
REM End of the night
REM ************************************************

if condition$="end" then
goto endprogram:
endif

endprogram:
gosub endnight:
end

REM ************************************************
REM all the subroutines used by the script
REM ************************************************

REM calculating the image name
REM the image name must be like name of the object, filter, exposure time and numberofimage
str exposure exp$
numberofimages[j]=numberofimages[j]+1
str numberofimages[j] numberofimages$
Nameimage$=star[j]$+"-"+filter[j]$+"-"+exp$+"s-"+numberofimages$

savefit img nightdirectory$+Nameimage$
print "Image " Nameimage$ " saved to disk"
close img
else
REM the star is too close from the moon
Distm=Distm*todeg
print
Print star[j]$ " is " Distm " degrees from the moon and can not be observed, we skip it"
endif
else
REM the star is too low
heightdeg=height*TODEG
print
Print star[j]$ " is now at " heightdeg " degrees above the horizon, therefore too low, we skip it"

endif
REM we check if we have arrived at the end of the night
timeleft=endofnighttime-date
frac timeleft time
observingtimeleft=time*24
observingtimeleftmin=observingtimeleft*60
if observingtimeleftmin<2 then
REM we have arrived at the end of the night, we go out of the loop and close the telescope
goto endnight:
endif
REM if there are several stars and if the autoguiding is working, we have to stop autoguiding between each repointing.
if autoguide=TRUE then
if numberofstarsinloop>1 then
StopGuide_Ex 2 1
endif
endif

next j

return

beginnighttime:
REM *******************************************************
REM Initialisation of the night
REM *******************************************************
REM we wait till the sun is 5 degrees below the horizon, then we initialize mount and camera

REM if we are running into this the first time
Now Date
GETRADECSUN Date AlphaS DeltaS sunelevation
Datetostr Date Date$
RAD_TO_DEC sunelevation ElevationS$
if sunelevation>0
position$="above"
else
position$="below"
endif
print "It is : " Date$ " the sun is at " ElevationS$ " degrees " position$ " the horizon"
if sunelevation>elevsunstartinitnight
Print "Waiting one minute..."
delay 60000
WAITFORENDDELAY
goto beginnighttime:
endif
print "The sun is now " ElevationS$ " degrees below horizon, starting up camera and mount"
REM in theory, it would be nice to check the temperature of the camera, either directly or by leaving a given amount of time after this step.
REM to be done later.

REM ***************************************************
REM Computing the end of night time.
REM ***************************************************
endnighttime:
REM first check if we are past noon or not.

now year month day hour minute second MS

REM if past noon we calculate the end of the following night
REM and we put the hours at 4 to start iteration

REM We initialize the guiding camera
REM in my system, the guiding camera is not cooled. If it were it would be better to modify the loop above to take both cameras into account
REM loop above means the loop starting by for i=1 to minutestogodowntotemp

REM *******************************************************
REM Here we measure the temperature (have to see how) and set focus accordingly
REM *******************************************************
REM this means we will have to determine an equation giving focus position versus ambient temperature
REM for now this function does nothing
checkfocus:
return

REM ************************************************
REM End of night, closing telescope, camera, etc...
REM ***********************************************
endnight:
REM We have to see how to bring the camera back to ambient temperature before closing it.
print "Observing is finished, so closing the telescope..."
Women Big Thin Pointed Pompes Vert Single Xianshu hauts Bow Heel Talons Shoes Tie REM saving the last preprocessed image, if any

SETCCDTEMPERATURE 1 0
Thin Bow Big Shoes Women Single hauts Heel Tie Pompes Talons Pointed Xianshu VertCLOSE_CCD_CAMERA_EX 1
REM in this script, the guiding camera is not cooled, so we don't go through a cooling sequence.
REM if you guiding camera is cooled, you have to modify the cooling sequence to work on both camera
CLOSE_CCD_CAMERA_EX 2

REM on the 135mm telephoto lens, the PC can not close the dome, it's done automatically by the C14 PC.

The first thing to do is to fill a targetlist, which contains, one star per line, its name, its RA and Dec, using the following format :
CDInd 21 16 -58 41
ASAS 22 43 +08 09
CCScl 00 58 -29 21
TTAri 02 06 +15 17
IMEri 01 37 -55 12

Read the script and modify the name and the location of the targetlist accordingly so that the sequencer can find it.

A single space character is used as a separator, so the name of the star must be in one word. Then HH MM SDD mm (hours and minutes of RA) and sign (+ is not mandatory) degrees of declination and minutes of declination

The second thing to do is to build a script file for the night.
The script contains first a condition, and eventually a list of stars to be observed in sequence while the condition is met.
Each sequence of the script is separated by an empty line
such a script could be :

Descriptions :
wait : Does not observe, waits till the HH MM time is passed. The time is local time

loop : Performs the sequence n times

observetill : Performs the sequence till HH MM hour. Time is local time

observetillstar star sub D : Performs the sequence till such star is above so many Degrees above the horizon

observetillstar star inf D : Performs the sequence till such star is below so many Degrees above the horizon

recenterscope : recalibrates the telescope position in the sky. This is done once on the first field of the sequence (of course it doesn't do anything before a wait or an end sequence, only for the commands taking images)

autoguide on/off starts or stops autoguiding.

end : end the sequences, and therefore parks the telescope, closes the dome, warms the CCD camera and turn everything off.. It might not be necessary to put this instruction if the program is sure to go past end of the twilight, in which case, the program will stop observations and close everything.

The script is rather shit in shit out, i.e. you goof in the target list or the script, it's very likely something interesting (or not) will occur.

So remember 1 space character is a separator (not 2), 1 empty line separates the sequences

The script can be edited with any text editor, notepad++ is preferred (to have line numbers).

It can be launched from prism, in the menu file either directly, or in debug mode, which allows to put break points and stop the running of the script at whatever point you want.

You are welcome to modify the script by yourself, you can change many parameters, the example the temperature and binning of the CCD camera, the times it takes to go down to the required temperature, the different directories where scripts and images are, the park position, etc... it's a good thing to read and understand vaguely what the script does.

Before anything, of course you should power telescope and camera etc… using the IP power switch.

Right now the first thing the script does is read the target list file (fixed directory, it can be modified by editing the script), then ask if the dome/telescope/camera is started or not, if it is not, when the sun is below enough (set at -5°), it opens the dome, connects to the telescope, connects to the camera and cools it down to the required temperature, then check that the sun is low enough (right now at -12°)then to take a test exposures, finds where it is in the sky, resynchronize the telescope, then go and observe. If the field is not found (most likely because the telescope was not parked correctly the last time it was used), the script pauses, i.e. you press a key on the keyboard to relaunch the script.

Things can be easily modified (mostly).

During the observing it checks whether the field is not too low (see the minimumheight variable), set at 15° right now, checks that the moon is not too close from the field (minimummoondistance variable set also at 15 degrees) and takes the exposure according to the required exposure time and filter.

Available filters are only L R G B H(Halpha). But can be modified easily.

At the end of each exposure, the script checks various conditions, such as end of the night, etc and decide what to do next.

At the end of the night or when the exposures are finished, the script parks the telescope, warms the camera, closes the dome, and disconnect.
The park is done at the position specified in prism
Good luck
Alain

REM here we read the lines following the loop instructions, till we encounter an empty line.
if star$<>"" then
...
endif
REM now we loop numberofcycles time, moving the telescope, exposing, saving the image, moving the telescope, etc...
for i=1 numberofcycles
gosub expose:
next i