Esempio n. 1
0
 //连接ASCOM驱动接口,启动ASA自带控制程序
 public void ConnectDevice()
 {
     try
     {
         if (m_focuser == null)
         {
             //从配置文件获取Focuser ID
             //TBD
             m_deviceID = "ACCServer.Focuser";
             if (m_deviceID == "")
             {
                 m_deviceID = Focuser.Choose("ACCServer.Focuser");
                 if (m_deviceID == null || m_deviceID == "")
                 {
                     m_focParams.errMsg = "Can not find \'ACCServer.Focuser\' in ASCOM driver";
                     Debug.Write(m_focParams.errMsg);
                 }
                 else
                 {
                     //保存调焦器名称到配置文件
                     //TBD
                     m_focuser             = new Focuser(m_deviceID);
                     m_focParams.connected = true;
                 }
             }
             else
             {
                 m_focuser             = new Focuser(m_deviceID);
                 m_focParams.connected = true;
             }
         }
         //else if (m_focuser.Dispose())
         //{
         //    //断开后再连接
         //    m_focuser = new Focuser(m_deviceID);
         //    m_focParams.connected = true;
         //}
     }
     catch (System.Exception ex)
     {
         m_focParams.connected = false;
         m_focParams.errMsg    = ex.Message;
     }
 }
Esempio n. 2
0
 private void btnSelectFocuser_Click(object sender, EventArgs e)
 {
     // 选择支持ASCOM的调焦器
     try
     {
         string progID1 = param_.GetValue("Instrument", "Focuser", "");
         string progID2 = Focuser.Choose("ACCServer.Focuser");
         if (progID2 == null || progID2 == "")
         {
             MessageBox.Show("Could not find \'ACCServer.Focuser\'");
         }
         else if (progID1 != progID2)
         {
             param_.SetValue("Instrument", "Focuser", progID2);
         }
     }
     catch (COMException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string progID;

            Util U = new Util();

            #region Focuser
            Console.WriteLine("\r\nFocuser:"******"ASCOM.Simulator.Focuser");     // Pre-select simulator (typ.)
            if (progID != "")
            {
                Focuser F = new Focuser(progID);
                F.Link = true;
                Console.WriteLine("  Connected to " + progID);
                Console.WriteLine("  Current position is " + F.Position);
                int nfp = (int)(0.7 * F.Position);
                Console.Write("  Moving to " + nfp);
                F.Move(nfp);
                while (F.IsMoving)
                {
                    Console.Write(".");
                    U.WaitForMilliseconds(333);
                }
                Console.WriteLine("\r\n  Move complete. New position is " + F.Position.ToString());
                F.Link = false;
                F.Dispose();                                    // Release this now, not at exit (typ.)
            }
            #endregion

            #region FilterWheel
            Console.WriteLine("\r\nFilterWheel:");
            progID = FilterWheel.Choose("ASCOM.Simulator.FilterWheel");
            if (progID != "")
            {
                FilterWheel fw = new FilterWheel(progID);
                fw.Connected = true;
                Console.WriteLine("  Position = " + fw.Position);
                string[] names = fw.Names;
                Console.WriteLine("  There are " + names.Length + " filters:\r\n  ");
                for (int i = 0; i < names.Length; i++)
                {
                    Console.Write(names[i] + " ");
                }
                Console.WriteLine("");
                fw.Connected = false;
                fw.Dispose();
            }
            #endregion

            #region Rotator
            Console.WriteLine("\r\nRotator:");
            progID = Rotator.Choose("ASCOM.Simulator.Rotator");
            if (progID != "")
            {
                Rotator R = new Rotator(progID);
                R.Connected = true;
                Console.WriteLine("  Position = " + R.Position);
                float np = R.Position + 60;
                if (np >= 360)
                {
                    np -= 360;
                }
                Console.Write("  Rotating to " + np.ToString("0"));
                R.MoveAbsolute(np);
                while (R.IsMoving)
                {
                    Console.Write(".");
                    U.WaitForMilliseconds(300);
                }
                Console.WriteLine("\r\n  Rotation complete.");
                R.Connected = false;
                R.Dispose();
            }
            #endregion

            #region Dome

            /*
             *          Console.WriteLine("\r\nDome:");
             *          progID = Dome.Choose("ASCOM.Simulator.Dome");
             *          if (progID != "")
             *          {
             *              Dome D = new Dome(progID);
             *              D.Connected = true;
             *              Console.WriteLine("  Description = " + D.Description);
             *              Console.WriteLine("  Name = " + D.Name);
             *              if (D.CanSetAzimuth)
             *              {
             *                  Console.WriteLine("  This is a rotatable dome");
             *                  Console.WriteLine("  Current slit azimuth = " + D.Azimuth.ToString("0.0"));
             *                  double z = D.Azimuth + 60;
             *                  if (z >= 360) z -= 360;
             *                  D.SlewToAzimuth(z);
             *                  Console.Write("  Rotating to azimuth " + z.ToString("0"));
             *                  while (D.Slewing)
             *                  {
             *                      Console.Write(".");
             *                      U.WaitForMilliseconds(300);
             *                  }
             *                  Console.WriteLine("\r\n  Rotation complete.");
             *              }
             *              if (D.CanSetShutter)
             *              {
             *                  if (D.CanSetAzimuth)
             *                      Console.WriteLine("  This dome has a controllable shutter");
             *                  else
             *                      Console.WriteLine("  This is a roll-off roof");
             *                  Console.WriteLine("  It is currently " + D.ShutterStatus.ToString());
             *                  switch (D.ShutterStatus)
             *                  {
             *                      case ShutterState.shutterClosed:
             *                          Console.Write("  Opening");
             *                          D.OpenShutter();
             *                          while (D.ShutterStatus != ShutterState.shutterOpen &&
             *                                  D.ShutterStatus != ShutterState.shutterError)
             *                          {
             *                              Console.Write(".");
             *                              U.WaitForMilliseconds(300);
             *                          }
             *                          Console.WriteLine("\r\n  It is now " + D.ShutterStatus.ToString());
             *                          break;
             *                      case ShutterState.shutterOpen:
             *                          Console.Write("  Closing");
             *                          D.CloseShutter();
             *                          while (D.ShutterStatus != ShutterState.shutterClosed &&
             *                                  D.ShutterStatus != ShutterState.shutterError)
             *                          {
             *                              Console.Write(".");
             *                              U.WaitForMilliseconds(300);
             *                          }
             *                          Console.WriteLine("\r\n  It is now " + D.ShutterStatus.ToString());
             *                          break;
             *                      case ShutterState.shutterError:
             *                          Console.WriteLine("  ** cannot do anything right now **");
             *                          break;
             *                      default:
             *                          Console.WriteLine("  ** it's moving so can't do anythjing else  now **");
             *                          break;
             *                  }
             *              }
             *              D.Connected = false;
             *              D.Dispose();
             *          }
             */
            #endregion

            #region Telescope

            /*
             *          Console.WriteLine("\r\nTelescope:");
             *          progID = Telescope.Choose("ASCOM.Simulator.Telescope");
             *          if (progID != "")
             *          {
             *              Telescope T = new Telescope(progID);
             *              T.Connected = true;
             *              Console.WriteLine("  Connected to " + progID);
             *              Console.WriteLine("  Current LST = " + U.HoursToHMS(T.SiderealTime));
             *              Console.WriteLine("  Current RA  = " + U.HoursToHMS(T.RightAscension));
             *              Console.WriteLine("  Current DEC = " + U.DegreesToDMS(T.Declination));
             *              Console.WriteLine("  CanSetTracking = " + T.CanSetTracking);
             *              if (T.CanSetTracking)
             *              {
             *                  Console.WriteLine("  Turning Tracking off...");
             *                  T.Tracking = false;
             *                  Console.WriteLine("  Tracking is now " + (T.Tracking ? "on" : "off") + ".");
             *                  Console.WriteLine("  Wait 5 seconds...");
             *                  U.WaitForMilliseconds(5000);
             *                  Console.WriteLine("  Turning Tracking back on...");
             *                  T.Tracking = true;
             *              }
             *              Console.WriteLine("  Latitude = " + U.DegreesToDMS(T.SiteLatitude));
             *              Console.WriteLine("  Longitude = " + U.DegreesToDMS(T.SiteLongitude));
             *              Console.Write("  Slewing to point 1");
             *              T.SlewToCoordinatesAsync(T.SiderealTime - 2, (T.SiteLatitude > 0 ? +55 : -55));
             *              while (T.Slewing)
             *              {
             *                  Console.Write(".");
             *                  U.WaitForMilliseconds(300);
             *              }
             *              Console.WriteLine("\r\n  Slew complete.");
             *              Console.Write("  Slewing to point 2");
             *              T.SlewToCoordinatesAsync(T.SiderealTime + 2, (T.SiteLatitude > 0 ? +35 : -35));
             *              while (T.Slewing)
             *              {
             *                  Console.Write(".");
             *                  U.WaitForMilliseconds(300);
             *              }
             *              Console.WriteLine("\r\n  Slew complete.");
             *              IAxisRates AxR = T.AxisRates(TelescopeAxes.axisPrimary);
             *              Console.WriteLine("  " + AxR.Count + " rates");
             *              if (AxR.Count == 0)
             *                  Console.WriteLine("  Empty AxisRates");
             *              else
             *                  foreach (IRate r in AxR)
             *                      Console.WriteLine("  Max=" + r.Maximum + " Min=" + r.Minimum);
             *              ITrackingRates TrR = T.TrackingRates;
             *              if (TrR.Count == 0)
             *                  Console.WriteLine("  Empty TrackingRates!");
             *              else
             *                  foreach (DriveRates dr in TrR)
             *                      Console.WriteLine("  DriveRate=" + dr);
             *              T.Connected = false;
             *              T.Dispose();
             *          }
             */
            #endregion

            #region Camera

            /*
             *          Console.WriteLine("\r\nCamera:");
             *          progID = Camera.Choose("ASCOM.Simulator.Camera");
             *          if (progID != "")
             *          {
             *              Camera C = new Camera(progID);
             *              C.Connected = true;
             *              Console.WriteLine("  Connected to " + progID);
             *              Console.WriteLine("  Description = " + C.Description);
             *              Console.WriteLine("  Pixel size = " + C.PixelSizeX + " * " + C.PixelSizeY);
             *              Console.WriteLine("  Camera size = " + C.CameraXSize + " * " + C.CameraYSize);
             *              Console.WriteLine("  Max Bin = " + C.MaxBinX + " * " + C.MaxBinY);
             *              Console.WriteLine("  Bin = " + C.BinX + " * " + C.BinY);
             *              Console.WriteLine("  MaxADU = " + C.MaxADU);
             *              Console.WriteLine("  CameraState = " + C.CameraState.ToString());
             *              Console.WriteLine("  CanAbortExposure = " + C.CanAbortExposure);
             *              Console.WriteLine("  CanAsymmetricBin = " + C.CanAsymmetricBin);
             *              Console.WriteLine("  CanGetCoolerPower = " + C.CanGetCoolerPower);
             *              Console.WriteLine("  CanPulseGuide = " + C.CanPulseGuide);
             *              Console.WriteLine("  CanSetCCDTemperature = " + C.CanSetCCDTemperature);
             *              Console.WriteLine("  CanStopExposure = " + C.CanStopExposure);
             *              Console.WriteLine("  CCDTemperature = " + C.CCDTemperature);
             *              if (C.CanGetCoolerPower)
             *                  Console.WriteLine("  CoolerPower = " + C.CoolerPower);
             *              Console.WriteLine("  ElectronsPerADU = " + C.ElectronsPerADU);
             *              Console.WriteLine("  FullWellCapacity = " + C.FullWellCapacity);
             *              Console.WriteLine("  HasShutter = " + C.HasShutter);
             *              Console.WriteLine("  HeatSinkTemperature = " + C.HeatSinkTemperature);
             *              if (C.CanPulseGuide)
             *                  Console.WriteLine("  IsPulseGuiding = " + C.IsPulseGuiding);
             *              Console.Write("  Take 15 second image");
             *              C.StartExposure(15.0, true);
             *              while (!C.ImageReady)
             *              {
             *                  Console.Write(".");
             *                  U.WaitForMilliseconds(300);
             *              }
             *              Console.WriteLine("\r\n  Exposure complete, ready for download.");
             *              Console.WriteLine("  CameraState = " + C.CameraState.ToString());
             *              Console.WriteLine("  LastExposureDuration = " + C.LastExposureDuration);
             *              Console.WriteLine("  LastExposureStartTime = " + C.LastExposureStartTime);
             *              int[,] imgArray = (int[,])C.ImageArray;
             *              Console.WriteLine("  Array is " + (imgArray.GetUpperBound(0) + 1) + " by " + (imgArray.GetUpperBound(1) + 1));
             *              C.Connected = false;
             *              C.Dispose();
             *          }
             */
            #endregion

            Console.Write("\r\nPress enter to quit...");
            Console.ReadLine();
        }