Git Product home page Git Product logo

phd2client's Introduction

phd2client

Sample client code for PHD2 server API - C++, C#, and python versions. If you need a different language binding please let me know.

C++

dependencies:

#include "guider.h"

// instantiate a guider object that will connect to PHD2 running on "localhost"
Guider guider("localhost");

// connect to PHD2
bool ok = guider.Connect();
if (!ok)
    std::cerr << "could not connect to phd2: " << guider.LastError() << std::endl;

// connect gear in the equipment profile named Simulator
ok = guider.ConnectEquipment("Simulator");
if (!ok)
    std::cerr << "could not connect equipment: " << guider.LastError() << std::endl;

// start guiding with settle tolerance of 2.0 pixels, 10 second settle time, 100-second timeout
ok = guider.Guide(2.0, 10.0, 100.0);

See phd2client.cpp for a more complete example.

C# (.NET)

using guider;

...
    using (Guider guider = Guider.Factory("localhost"))
    {
        try
        {
            // connect to PHD2
            guider.Connect();

            // connect equipment in profile "Simulator"
            guider.ConnectEquipment("Simulator");

            // start guiding with settle tolerance of 2.0 pixels, 10 second settle time, 100-second timeout
            guider.Guide(2.0, 10.0, 100.0);
         }
         catch (GuiderException ex)
         {
             // Guider exception
             Console.WriteLine("Guider Error: {0}", ex.Message);
         }
    }

See SampleClient.cs for a more complete example.

python

from guider import Guider, GuiderException

...
    with Guider("localhost") as guider:
        try:
            # connect to PHD2
            guider.Connect()

            # connect equipment in profile "Simulator"
            guider.ConnectEquipment("Simulator")

            # start guiding with settle tolerance of 2.0 pixels, 10 second settle time, 100-second timeout
            guider.Guide(2.0, 10.0, 100.0)
        except GuiderException as ex:
            print(f"Guider Error: {ex}")

See phd2client.py for a more complete example.

phd2client's People

Contributors

agalasso avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

phd2client's Issues

allow calling Guide or Dither again without calling CheckSettling

calling Guide or Dither after a prior call to Guide or Dither without an intervening call of CheckSettling throws an exception "cannot guide while settling" even if settling has completed; it should be possible to call Guide or Dither again without throwing the exception if settling has completed.

add method to call set_lock_position server API

request from David C

My goal is to select several targets for a night and check if the telescope can manage automatically to place them in the slit and acquire spectra. I think it is doable using Adjust Lock Position and Sticky Lock. I have tried it manually and it works, but i do not know how to send numbers, with a script, to the Adjust Lock Position. 

 

The procedure would run roughly this way:

 

-send the telescope to RA, DEC.

-start guiding

-acquire and save an image with PHD2

-plate solve calculating the center (RA, DEC) of the image

-calculate the offset in pixels (Δx, Δy) from the target to the center of the slit

-add that offset to Adjust Lock Position numbers

-wait a few minutes and recheck with a new plate solve

-recenter if necessary (working manually i hardly never need a recenter, it normally works the first time if the offset is calculated correctly!)

-start acquiring spectra

 ```

我发现了一个bug

我尝试使用c++示例库中的程序,但是连接设备这个一部分总是不行,无法连接上设备,是不是代码有错误,我已尝试了许多次,好像python也有相同的情况。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.