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

Actions Documentation

AddFilter(text filter)

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

Parameters

  • text filter: The name of the filter.

Example

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

AddListener(Libraries.Science.Astronomy.SkynetListener listener)

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

Parameters

Example

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

AddTelescope(text telescope)

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

Parameters

  • text telescope: The name of the telescope.

Example

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

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.

Parameters

Return

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

Example

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

DownloadProgress(integer length, integer read)

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

Parameters

  • integer length: The amount of data the server claims it is sending
  • integer read: the amount of data that has been processed so far

Example



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

Equals(Libraries.Language.Object object)

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

Parameters

Return

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

Example

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

GetExposureParameters()

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

Return

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

Example

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

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

GetFilterList()

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

Return

text: The list of filters as text.

Example

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

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

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetListenerIterator()

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

Return

Libraries.Containers.Iterator: An iterator of NetworkRequestListeners

Example

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

GetObservationParametersByCoordinates()

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

Return

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

Example

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

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

GetObservationParametersByName()

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

Return

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

Example

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

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

GetSkynetHeaders()

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

Return

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

Example

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

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

GetTelescopeList()

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

Return

text: The list of telescopes as text.

Example

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

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

Notify(Libraries.Network.NetworkResponseEvent response)

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

Parameters

Example

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

RemoveListener(Libraries.Science.Astronomy.SkynetListener listener)

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

Parameters

Example

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

ResponseReceived(Libraries.Network.NetworkResponseEvent response)

This method is the callback for the NetworkResponseEvent object.

Parameters

Example

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

SetAccountKey(text AccountKey)

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

Parameters

  • text AccountKey: The security token for your account.

Example

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

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.

Parameters

  • text type: The astronomical type of the object.

Example

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

SetBinning(integer binningRequested)

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

Parameters

  • integer binningRequested: The binning value for your request.

Example

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

SetDeclination(text declination)

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

Parameters

  • text declination: The declination value for the request.

Example

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

SetExposureLength(number expLength)

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

Parameters

  • number expLength: The exposure length for your request.

Example

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

SetIsToo(boolean value)

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

Parameters

  • boolean value: The boolean value of IsToo.

Example

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

SetMaxSun(integer maxSun)

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

Parameters

  • integer maxSun: The maxSun value for you request.

Example

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

SetMinElevation(number minElevation)

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

Parameters

  • number minElevation: The minimum elevation value for your request.

Example

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

SetMode(integer value)

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

Parameters

  • integer value: The mode value for your request.

Example

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

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.

Parameters

  • text name: The name of the object for your request.

Example

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

SetNumberOfExposures(integer expNum)

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

Parameters

  • integer expNum: The number of exposures to take.

Example

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

SetPriority(integer priority)

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

Parameters

  • integer priority: The priority for you request.

Example

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

SetRightAscension(text rightAscension)

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

Parameters

  • text rightAscension

Example

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

SetTimeAccount(integer timeAccount)

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

Parameters

  • integer timeAccount: The timeAccount value for your request.

Example

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

SubmitExposureRequest()

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

Example

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

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

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