示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DRIVER_NAME = "ASCOM.Astrosib_Shutters.Switch";
            //DRIVER_NAME = "ASCOM.Simulator.Switch";

            txtInfo.Text += (SHUTTER_DIR ? "OPENING" : "CLOSING") + " CONFIGURATION" + Environment.NewLine;
            txtInfo.Text += "Using driver:  " + DRIVER_NAME + "" + Environment.NewLine;
            txtInfo.Text += "----------------------------------------" + Environment.NewLine;


            //Connect
            try
            {
                objSwitch = new ASCOM.DriverAccess.Switch(DRIVER_NAME);
                objSwitch.Connected = true;
                txtInfo.Text += "Driver [" + DRIVER_NAME + "] is connected" + Environment.NewLine;
            }
            catch (Exception Ex)
            {
                txtInfo.Text += Ex.ToString() + Environment.NewLine;
            }

            //Opening
            txtInfo.Text += "Starting auto run..." + Environment.NewLine;
            backgroundWorker_Open.RunWorkerAsync();

        }
示例#2
0
        private void LoadSwitches()
        {
            this.switchIds.Items.Clear();

            string switchDriverId = settings.Get("switchDriverId");

            if (switchDriverId.Length == 0)
            {
                return;
            }

            using (ASCOM.DriverAccess.Switch sw = new ASCOM.DriverAccess.Switch(switchDriverId))
            {
                sw.Connected = true;
                for (short n = 0; n < sw.MaxSwitch; n++)
                {
                    string name = sw.GetSwitchName(n);
                    this.switchIds.Items.Add(name);
                }
            }

            short switchId = 0;

            Int16.TryParse(settings.Get("switchId", "0"), out switchId);
            this.switchIds.SelectedIndex = switchId;
        }
示例#3
0
        /// <summary>
        /// Wrapper to reset telescope driver
        /// Later system would reinitiate it itself
        /// </summary>
        public void Reset()
        {
            Connected_flag = false;

            Telescope_power_flag = null;
            Camera_power_flag    = null;
            _Focuser_power_flag  = null;
            _Roof_power_flag     = null;

            objSwitch = null;
        }
示例#4
0
 private void buttonConnect_Click(object sender, EventArgs e)
 {
     if (IsConnected)
     {
         driver.Connected = false;
     }
     else
     {
         driver           = new ASCOM.DriverAccess.Switch(Properties.Settings.Default.DriverId);
         driver.Connected = true;
     }
     SetUIState();
 }
示例#5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     numericUpDown1.Value = timer1.Interval / 100;
     try
     {
         driver = new ASCOM.DriverAccess.Switch(DriverId);
     }
     catch (Exception ex)
     {
         toolStripStatusLabel1.Text = "Couldn't connect to default device [" + DriverId + "] at startup";
         txtLog.AppendText(toolStripStatusLabel1.Text + Environment.NewLine);
     }
     SetUIState_ConnectedDisconnected();
 }
示例#6
0
        public static void FreeMount()
        {
            lock (lockObject)
            {
                Debug.Assert(MountUseCnt == 0);

                if (s_mount != null)
                {
                    s_mount.Dispose();
                    s_mount = null;
                }

                if (s_switch != null)
                {
                    s_switch.Dispose();
                    s_switch = null;
                }
            }
        }
示例#7
0
        private void buttonChoose_Click(object sender, EventArgs e)
        {
            string st = ASCOM.DriverAccess.Switch.Choose(DriverId);

            if (!string.IsNullOrEmpty(st))
            {
                Properties.Settings.Default.DriverId = st;
                DriverId = st;
                try
                {
                    driver = new ASCOM.DriverAccess.Switch(DriverId);
                    Properties.Settings.Default.Save();
                }
                catch (Exception ex)
                {
                    toolStripStatusLabel1.Text = "Couldn't connect to choosed device [" + DriverId + "] at " + DateTime.Now;
                    txtLog.AppendText(toolStripStatusLabel1.Text + Environment.NewLine);
                }
                SetUIState_ConnectedDisconnected();
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            // Uncomment the code that's required
#if UseChooser
            // choose the device

            string id = ASCOM.DriverAccess.Switch.Choose("ASCOM.StroblCap.Switch");
            //string id = ASCOM.DriverAccess.ObservingConditions.Choose("ASCOM.StroblCap.ObservingConditions");
            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // create this device
            ASCOM.DriverAccess.Switch device = new ASCOM.DriverAccess.Switch(id);
#else
            // this can be replaced by this code, it avoids the chooser and creates the driver class directly.
            ASCOM.DriverAccess.Switch device = new ASCOM.DriverAccess.Switch("ASCOM.StroblCap.Switch");
#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 " + device.Name);
            Console.WriteLine("description " + device.Description);
            Console.WriteLine("DriverInfo " + device.DriverInfo);
            Console.WriteLine("driverVersion " + device.DriverVersion);

            // TODO add more code to test the driver.
            device.Connected = true;

            while (true)
            {
                Thread.Sleep(100);
            }
            device.Connected = false;
            Console.WriteLine("Press Enter to finish");
            Console.ReadLine();
        }
示例#9
0
        private static void InstantiateMount()
        {
            string mountDriverId, switchDriverId;
            short  switchIdx;

            GetMountDriverIds(out mountDriverId, out switchDriverId, out switchIdx);

            if (mountDriverId.Length == 0)
            {
                throw new InvalidOperationException("Missing mount selection");
            }

            ASCOM.DriverAccess.Telescope mount = null;
            ASCOM.DriverAccess.Switch    sw    = null;
            try
            {
                mount = new ASCOM.DriverAccess.Telescope(mountDriverId);
                if (switchDriverId.Length > 0)
                {
                    sw = new ASCOM.DriverAccess.Switch(switchDriverId);
                }
            }
            catch (Exception)
            {
                mount.Dispose();
                if (sw != null)
                {
                    sw.Dispose();
                }
                throw;
            }

            s_mount     = mount;
            s_switch    = sw;
            s_switchIdx = switchIdx;
        }