示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     ASCOM.Utilities.Chooser chooser = new ASCOM.Utilities.Chooser();
     chooser.DeviceType         = "Focuser";
     myFocuser                  = new Focuser(chooser.Choose());
     myFocuser.Connected        = true;
     focuser_choose.BackColor   = Color.GreenYellow;
     focuser_step_value         = myFocuser.Position;
     current_focuser_value.Text = focuser_step_value.ToString();
     focuser_temp_worker.RunWorkerAsync();
     Disconnect_focuser.Enabled = true;
 }
示例#2
0
        // [STAThreadAttribute()]
        static void Main(string[] args)
        {
            // util.SerialTraceFile = string.Format(@"C:\Users\tpovl\OneDrive\Documents\ASCOM\SerialLogs\Serial.log", DateTime.Now);
            // util.SerialTrace = false;

            try
            {
#if UseChooser
                // Choose the s_Focuser
                string id = DriverAccess.Focuser.Choose("");
                if (string.IsNullOrEmpty(id))
                {
                    return;
                }

                // Create this focuser.
                s_Focuser = new DriverAccess.Focuser(id);
#else
                // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
                DriverAccess.Focuser s_Focuser = new DriverAccess.Focuser("FeatherTouchDH1.Focuser");
#endif
                // now run some tests, adding code to your driver so that the tests will pass.
                // these first tests are common to all drivers.
                Console.WriteLine("name " + s_Focuser.Name);
                Console.WriteLine("description " + s_Focuser.Description);
                Console.WriteLine("DriverInfo " + s_Focuser.DriverInfo);
                Console.WriteLine("driverVersion " + s_Focuser.DriverVersion);


                #region Focuser
                Console.WriteLine("{0}Focuser:"******"ASCOM.Simulator.Focuser");        // Pre-select simulator

                if (id != "")
                {
                    s_Focuser.Connected = true;
                    s_Focuser.Link      = true;

                    Console.WriteLine("Connected to {0}  Position is {1}", id, s_Focuser.Position);

                    // Verify the Halt method works.
                    // HaltTest();

                    // Verify we can move the focuser in and out.
                    MoveTest(1000, 10);

                    s_Focuser.Connected = false;
                    s_Focuser.Link      = false;
                    s_Focuser.Dispose();
                }
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught Exception! ");
                Console.WriteLine(ex);
            }

            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            // General information
            Console.WriteLine("This program is running in {0}-bit mode", (IntPtr.Size == 4) ? "32" : "64");
            Console.WriteLine();

            DriverAccess.Focuser device;
            //ASCOM.DeviceInterface.IFocuserV3 device = new ASCOM.Ardufocus.Focuser();

            try
            {
                // Select the driver
                device = new DriverAccess.Focuser("ASCOM.Ardufocus.Focuser.1");
            }
            catch (Exception)
            {
                Console.WriteLine("ASCOM.Ardufocus.Focuser driver not found.");
                Console.WriteLine("Press Enter to finish");
                Console.ReadLine();
                return;
            }

            // Basic driver information
            Console.WriteLine("          Name: " + device.Name);
            Console.WriteLine("   Description: " + device.Description);
            Console.WriteLine("   Driver Info: " + device.DriverInfo);
            Console.WriteLine("Driver Version: " + device.DriverVersion);
            Console.WriteLine();

#if USE_SETUP
            // Show the driver setup dialog
            device.SetupDialog();
#endif

            // Connect
            device.Connected = true;

            if (device.Connected)
            {
                // Driver tests
                Console.WriteLine("         Absolute: " + device.Absolute);
                Console.WriteLine("        Connected: " + device.Connected);
                Console.WriteLine("        Interface: " + device.InterfaceVersion);
                Console.WriteLine("         IsMoving: " + device.IsMoving);
                Console.WriteLine("             Link: " + device.Link);
                Console.WriteLine("     MaxIncrement: " + device.MaxIncrement);
                Console.WriteLine("          MaxStep: " + device.MaxStep);
                Console.WriteLine("         Position: " + device.Position);

                // This one throws an exception
                //Console.WriteLine("         StepSize: " + device.StepSize);

                Console.WriteLine(" SupportedActions: " + device.SupportedActions);
                Console.WriteLine("         TempComp: " + device.TempComp);
                Console.WriteLine("TempCompAvailable: " + device.TempCompAvailable);
                Console.WriteLine("      Temperature: " + device.Temperature);
                Console.WriteLine();

                // Finish
                Console.WriteLine("Press Enter to test movement");
                Console.ReadLine();

                int target = 1234;
                device.Move(target);
                Console.WriteLine("Moving focuser to position {0}", target);

                while (device.IsMoving)
                {
                    ;
                }
                Console.WriteLine("Focuser stopped moving, current position is {0}", device.Position);

                int home = 0;
                device.Move(home);
                Console.WriteLine("Moving focuser to position {0}", home);

                while (device.IsMoving)
                {
                    ;
                }
                Console.WriteLine("Focuser stopped moving, current position is {0}", device.Position);

                device.Connected = false;
            }

            // Finish
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }