예제 #1
0
 private void DoSetup()
 {
     this.Timer.Enabled = false;     // Stop the timer
     this.Visible       = false;     // May float over setup
     SimulatedHardware.DoSetup();    // Show the setup dialog
     this.Timer.Enabled = true;      // Restart form updates
     this.Visible       = true;      // Show ourself again
 }
예제 #2
0
        static void Main(string[] args)
        {
            //MessageBox.Show("wait");
            if (!LoadComObjectAssemblies())
            {
                return;                                                                         // Load served COM class assemblies, get types
            }
            if (!ProcessArguments(args))
            {
                return;                                                                         // Register/Unregister
            }
            // Initialize critical member variables.
            m_iObjsInUse              = 0;
            m_iServerLocks            = 0;
            m_uiMainThreadId          = GetCurrentThreadId();
            Thread.CurrentThread.Name = "Main Thread";

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            m_MainForm = new frmHandbox();
            m_MainForm.Show();
            // if (m_bComStart) m_MainForm.WindowState = FormWindowState.Minimized;
            // if (m_bComStart) m_MainForm.Visible = false;
            m_MainForm.Visible = true;

            // Initialize hardware layer
            SimulatedHardware.Initialize();

            // Register the class factories of the served objects
            RegisterClassFactories();

            // Start up the garbage collection thread.
            GarbageCollection GarbageCollector = new GarbageCollection(1000);
            Thread            GCThread         = new Thread(new ThreadStart(GarbageCollector.GCWatch));

            GCThread.Name = "Garbage Collection Thread";
            GCThread.Start();

            //
            // Start the message loop. This serializes incoming calls to our
            // served COM objects, making this act like the VB6 equivalent!
            //
            Application.Run(m_MainForm);

            // Revoke the class factories immediately.
            // Don't wait until the thread has stopped before
            // we perform revocation!!!
            RevokeClassFactories();

            // Now stop the Garbage Collector thread.
            GarbageCollector.StopThread();
            GarbageCollector.WaitForThreadToStop();
        }
예제 #3
0
        public frmHandbox()
        {
            InitializeComponent();
            this.BringToFront();

            ToolTip aTooltip = new ToolTip();

            aTooltip.SetToolTip(picASCOM, "Visit the ASCOM website");
            aTooltip.SetToolTip(btnTraffic, "Monitor ASCOM API traffic");
            aTooltip.SetToolTip(chkConnected, "Connect/Disconnect filterwheel");
            aTooltip.SetToolTip(btnPrev, "Move position to previous filter");
            aTooltip.SetToolTip(btnNext, "Move position to next filter");

            SimulatedHardware.Initialize();
            SimulatedHardware.TimerTickInverval = m_iTimerTickInterval;

            this.Timer.Enabled = true;
        }
예제 #4
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            SimulatedHardware.UpdateState();                    // Pump the machine
            //
            // Read the state of the Simulated hardware. No shortcuts, it's state
            // is also affected by ASCOM clients via the IFilterWheel interface!
            //

            this.chkConnected.Checked = SimulatedHardware.m_bConnected;
            this.btnNext.Enabled      = SimulatedHardware.m_bConnected;
            this.btnPrev.Enabled      = SimulatedHardware.m_bConnected;
            this.btnSetup.Enabled     = !SimulatedHardware.m_bConnected;

            if (SimulatedHardware.m_bConnected && !SimulatedHardware.Moving)
            { // Connected, not Moving
                this.lblPosition.Text    = SimulatedHardware.m_sPosition.ToString();
                this.lblName.Text        = SimulatedHardware.CurrFilterName.ToString();
                this.lblOffset.Text      = SimulatedHardware.CurrFilterOffset.ToString();
                this.picFilter.BackColor = SimulatedHardware.CurrFilterColour;
                this.picFilter.Image     = Properties.Resources.FilterStop;
                m_bMoveInProgress        = false;
                m_sTargetPosition        = SimulatedHardware.m_sPosition;
            }
            else if (SimulatedHardware.m_bConnected && SimulatedHardware.Moving)
            { // Conncted, Moving
                this.lblPosition.Text = "Moving";
                this.lblName.Text     = "-";
                this.lblOffset.Text   = "-";
                if (!m_bMoveInProgress)
                {
                    this.picFilter.Image = Properties.Resources.Filter_Next;
                    m_bMoveInProgress    = true;
                }
            }
            else
            { // Not connected
                this.lblPosition.Text    = "-";
                this.lblName.Text        = "-";
                this.lblOffset.Text      = "-";
                this.picFilter.BackColor = Color.DimGray;
                this.picFilter.Image     = Properties.Resources.FilterStop;
                m_bMoveInProgress        = false;
            }
        }
예제 #5
0
 private void btnSetup_Click(object sender, EventArgs e)
 {
     SimulatedHardware.DoSetup();
 }