Libraries.Science.Astronomy.Skynet Documentation

This class is used to send instructions to the Skynet robotic telescope network using the internet and the token from you skynet account. If you don't have an account, contact Skynet (https://skynet.unc.edu/help/contact) for information.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
use Libraries.Network.NetworkResponseEvent
use Libraries.Science.Astronomy.Skynet
use Libraries.Science.Astronomy.SkynetListener

class DriverCode is SkynetListener
    text token = "your security token goes here"
    Skynet skynet

    action Main
        skynet:AddListener(me)
        skynet:SetRightAscension("11:12:20.1")
        skynet:SetDeclination("-04:18:57")
        skynet:SetName("2018 CY1")
        skynet:SetAccountKey(token)
        skynet:SetMaxSun(-14)
        skynet:SetMinElevation(30.0)
        skynet:SetTimeAccount(555)
        skynet:AddTelescope("CTIO-1.0m")
        skynet:AddFilter("Open")
        skynet:SetNumberOfExposures(1)
        skynet:SetExposureLength(1.0)
        skynet:SubmitObservationByCoordinates()
    end

    action ResponseReceived(NetworkResponseEvent response)
        // do something with the response
    end
end

Inherits from: Libraries.Network.NetworkRequestListener, Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
AddFilter(text filter)This method is used to add the name of the filter to your Skynet request object.
AddListener(Libraries.Science.Astronomy.SkynetListener listener)This method is used to add the listener to the Skynet object.
AddTelescope(text telescope)This method is used to add the name of the telescope to your Skynet request object.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
DownloadProgress(integer length, integer read)This action allows us to obtain the progress of any file download as the network is processing it.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetExposureParameters()This method is used internally by the class to return the exposure parameters set in the object.
GetFilterList()This method is used internally by the class to return the filter list set in the object.
GetHashCode()This action gets the hash code for an object.
GetListenerIterator()This method is used to get an iterator to the set of listeners attached to the Skynet object.
GetObservationParametersByCoordinates()This method is used internally by the class to return the observation parameters by coordinates set in the object.
GetObservationParametersByName()This method is used internally by the class to return the observation parameters by name set in the object.
GetSkynetHeaders()This method is used internally by the class to return the skynet headers set in the object.
GetTelescopeList()This method is used internally by the class to return the telescope list set in the object.
Notify(Libraries.Network.NetworkResponseEvent response)This method notifies all the listerners that a NetworkResponseEvent has been receied by the Skynet Object.
RemoveListener(Libraries.Science.Astronomy.SkynetListener listener)This method is used to remove the listener to the Skynet object.
ResponseReceived(Libraries.Network.NetworkResponseEvent response)This method is the callback for the NetworkResponseEvent object.
SetAccountKey(text AccountKey)This method is used to set the security token of your Skynet request object.
SetAstronomicalType(text type)This method is used to set the astronomical type value your Skynet request object.
SetBinning(integer binningRequested)This method is used to set the binning value of your Skynet request object.
SetDeclination(text declination)This method is used to set the declination value of your Skynet request object.
SetExposureLength(number expLength)This method is used to set the exposure length value of your Skynet request object.
SetIsToo(boolean value)This method is used to set the isToo value of your Skynet request object.
SetMaxSun(integer maxSun)This method is used to set the MaxSun value of your Skynet request object.
SetMinElevation(number minElevation)This method is used to set the Minimum Elevation value of your Skynet request object.
SetMode(integer value)This method is used to set the mode value of your Skynet request object.
SetName(text name)This method is used to set the name of your Skynet request object if you are going to request an observation by name.
SetNumberOfExposures(integer expNum)This method is used to set the number of exposures for your Skynet request object.
SetPriority(integer priority)This method is used to set the priority value your Skynet request object.
SetRightAscension(text rightAscension)This method is used to set the right ascension value your Skynet request object.
SetTimeAccount(integer timeAccount)This method is used to set the time account value your Skynet request object.
SubmitExposureRequest()This method is used internally by the class to submit the exposure parameters after an observation id has been obtained.
SubmitObservationByCoordinates()This method is used to submit the request using the coordinates method.
SubmitObservationByName()This method is used to submit the request using the names method.

Actions Documentation

AddFilter(text filter)

This method is used to add the name of the filter to your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:AddFilter("Open")
        end
    end

Parameters

AddListener(Libraries.Science.Astronomy.SkynetListener listener)

This method is used to add the listener to the Skynet object. Attribute parameter listener The SkynetListener object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
        end
    end

Parameters

AddTelescope(text telescope)

This method is used to add the name of the telescope to your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:AddTelescope("CTIO-1.0m")
        end
    end

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

DownloadProgress(integer length, integer read)

This action allows us to obtain the progress of any file download as the network is processing it.

Example Code

use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkRequestListener

    class Main is NetworkRequestListener
        action Main
            NetworkConnection conn
            conn:AddListener(me)
            File myFile
            myFile:SetPath("logo.png")
            NetworkRequest request
            request:SetRequestTypeToGet()
            request:SetWebAddress("https://quorumlanguage.com/media/QuorumLogo.png")
            request:SetDownloadFile(myFile)
        end

        action ResponseReceived(NetworkResponseEvent response)
            output response:GetResponseText()
        end

        action DownloadProgress(integer length, integer read)
            output read + " of " + length + " bytes read." 
        end
    end

Parameters

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GetExposureParameters()

This method is used internally by the class to return the exposure parameters set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action SubmitExposureRequest
        NetworkRequest request
        request:SetParameters(GetExposureParameters())
    end

Return

Libraries.Data.Formats.JavaScriptObjectNotation: a JavaScriptObjectNotation object with the parameters.

GetFilterList()

This method is used internally by the class to return the filter list set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action GetExposureParameters returns JavaScriptObjectNotation
        JavaScriptObjectNotation params
        params:Add("filterRequested", me:GetFilterList())
        return params
    end

Return

text: The list of filters as text.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetListenerIterator()

This method is used to get an iterator to the set of listeners attached to the Skynet object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener
    use Libraries.Containers.Iterator

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            Iterator<NetworkRequestListener> iterator
            iterator = skynet:GetListenerIterator()
        end
    end

Return

Libraries.Containers.Iterator: An iterator of NetworkRequestListeners

GetObservationParametersByCoordinates()

This method is used internally by the class to return the observation parameters by coordinates set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action SubmitObservationByCoordinates
        NetworkRequest request
        request:SetParameters(GetObservationParametersByCoordinates())
    end

Return

Libraries.Data.Formats.JavaScriptObjectNotation: a JavaScriptObjectNotation object with the parameters.

GetObservationParametersByName()

This method is used internally by the class to return the observation parameters by name set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action SubmitObservationByName
        NetworkRequest request
        request:SetParameters(GetObservationParametersByName())
    end

Return

Libraries.Data.Formats.JavaScriptObjectNotation: a JavaScriptObjectNotation object with the parameters.

GetSkynetHeaders()

This method is used internally by the class to return the skynet headers set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action SubmitObservationByCoordinates
        NetworkRequest request
        request:SetHeaders(GetSkynetHeaders())
    end

Return

Libraries.Containers.HashTable: a HashTable object with the headers.

GetTelescopeList()

This method is used internally by the class to return the telescope list set in the object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action GetExposureParameters returns JavaScriptObjectNotation
        JavaScriptObjectNotation params
        params:Add("telescope", me:GetTelescopeList())
        return params
    end

Return

text: The list of telescopes as text.

Notify(Libraries.Network.NetworkResponseEvent response)

This method notifies all the listerners that a NetworkResponseEvent has been receied by the Skynet Object.

Example Code

use Libraries.Network.NetworkResponseEvent
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action ResponseReceived(NetworkResponseEvent response)
        JavaScriptObjectNotation json
        json:Read(response:GetResponseText())
        if status = STATUS_WAITING_FOR_OBSERVATIONID
            observationID = cast(integer, json:GetValue("id"))
            status = STATUS_OBSERVATIONID_RECEIVED
            SubmitExposureRequest()
        elseif status = STATUS_OBSERVATIONID_RECEIVED
            status = STATUS_NO_REQUEST_MADE
            Notify(response)
        end
    end

Parameters

RemoveListener(Libraries.Science.Astronomy.SkynetListener listener)

This method is used to remove the listener to the Skynet object. Attribute parameter listener The SkynetListener object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:RemoveListener(me)
        end
    end

Parameters

ResponseReceived(Libraries.Network.NetworkResponseEvent response)

This method is the callback for the NetworkResponseEvent object.

Example Code

use Libraries.Network.NetworkRequest
    use Libraries.Network.NetworkConnection
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Network.NetworkResponseListener

    class Skynet is NetworkResponseListener
        action Submit
            NetworkRequest request
            request:SetRequestTypeToPost()
            NetworkConnection http
            http:AddListener(me)
            http:SendRequest(request)
        end

        action ResponseReceived(NetworkResponseEvent response)
            // do something with the response
        end
    end

Parameters

SetAccountKey(text AccountKey)

This method is used to set the security token of your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetAccountKey(token)
        end
    end

Parameters

SetAstronomicalType(text type)

This method is used to set the astronomical type value your Skynet request object. Allowable values include: sidereal, planet, asteroids, comet or nothing.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetPriority(1)
        end
    end

Parameters

SetBinning(integer binningRequested)

This method is used to set the binning value of your Skynet request object. The default value is 1.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetBinning(2)
        end
    end

Parameters

SetDeclination(text declination)

This method is used to set the declination value of your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetDeclination("-04:18:57")
        end
    end

Parameters

SetExposureLength(number expLength)

This method is used to set the exposure length value of your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetExposureLength(1.0)
        end
    end

Parameters

SetIsToo(boolean value)

This method is used to set the isToo value of your Skynet request object. The default value is false.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetIsToo(false)
        end
    end

Parameters

SetMaxSun(integer maxSun)

This method is used to set the MaxSun value of your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetMaxSun(-14)
        end
    end

Parameters

SetMinElevation(number minElevation)

This method is used to set the Minimum Elevation value of your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetMinElevation(30.0)
        end
    end

Parameters

SetMode(integer value)

This method is used to set the mode value of your Skynet request object. The default value is 0.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetMode(0)
        end
    end

Parameters

SetName(text name)

This method is used to set the name of your Skynet request object if you are going to request an observation by name.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetName("2018 CY1")
        end
    end

Parameters

SetNumberOfExposures(integer expNum)

This method is used to set the number of exposures for your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetNumberOfExposures(1)
        end
    end

Parameters

SetPriority(integer priority)

This method is used to set the priority value your Skynet request object. The default value is 1.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetPriority(1)
        end
    end

Parameters

SetRightAscension(text rightAscension)

This method is used to set the right ascension value your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetRightAscension("11:12:20.1")
        end
    end

Parameters

SetTimeAccount(integer timeAccount)

This method is used to set the time account value your Skynet request object.

Example Code

use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        integer account = 555
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetTimeAccount(account)
        end
    end

Parameters

SubmitExposureRequest()

This method is used internally by the class to submit the exposure parameters after an observation id has been obtained.

Example Code

use Libraries.Network.NetworkResponseEvent
    use Libraries.Data.Formats.JavaScriptObjectNotation

    action ResponseReceived(NetworkResponseEvent response)
        JavaScriptObjectNotation json
        json:Read(response:GetResponseText())
        if status = STATUS_WAITING_FOR_OBSERVATIONID
            observationID = cast(integer, json:GetValue("id"))
            status = STATUS_OBSERVATIONID_RECEIVED
            SubmitExposureRequest()
        elseif status = STATUS_OBSERVATIONID_RECEIVED
            status = STATUS_NO_REQUEST_MADE
            Notify(response)
        end
    end

SubmitObservationByCoordinates()

This method is used to submit the request using the coordinates method.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener
    use Libraries.System.File
    use Libraries.Containers.HashTable
    use Libraries.Containers.Iterator

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetRightAscension("11:12:20.1")
            skynet:SetDeclination("-04:18:57")
            skynet:SetName("2018 CY1")
            skynet:SetAccountKey(token)
            skynet:SetMaxSun(-14)
            skynet:SetMinElevation(30.0)
            skynet:SetTimeAccount(555)
            skynet:AddTelescope("CTIO-1.0m")
            skynet:AddFilter("Open")
            skynet:SetNumberOfExposures(1)
            skynet:SetExposureLength(1.0)
            skynet:SubmitObservationByCoordinates()
        end

        action ResponseReceived(NetworkResponseEvent response)
            // do something with the response
        end
    end

SubmitObservationByName()

This method is used to submit the request using the names method.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Network.NetworkResponseEvent
    use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Science.Astronomy.Skynet
    use Libraries.Science.Astronomy.SkynetListener
    use Libraries.System.File
    use Libraries.Containers.HashTable
    use Libraries.Containers.Iterator

    class DriverCode is SkynetListener
        text token = "your security token goes here"
        Skynet skynet

        action Main
            skynet:AddListener(me)
            skynet:SetAstronomicalType("asteroid")
            skynet:SetName("tylerlinder")
            skynet:SetAccountKey(token)
            skynet:SetMaxSun(-14)
            skynet:SetMinElevation(30.0)
            skynet:SetTimeAccount(555)
            skynet:AddTelescope("CTIO-1.0m")
            skynet:AddFilter("Open")
            skynet:SetNumberOfExposures(1)
            skynet:SetExposureLength(1.0)
            skynet:skynet:SubmitObservationByName()
        end

        action ResponseReceived(NetworkResponseEvent response)
            // do something with the response
        end
    end