Beispiel #1
0
        /// <summary>
        /// Terminates the operation.
        /// </summary>
        public void TerminateOperation()
        {
            daqCard.StopAcq();
            // Wait for that ai_done_cbfunc() is complete
            Console.WriteLine("AI_Done event is set");
            // motionCard to Start Point
            motionCard.ToStartPositoin();

            do
            {
                System.Threading.Thread.Sleep(1);
            } while (listHandler.updatedCount != listHandler.ai_dataList.Count);
            UiUpdateTimer.Stop();

            //FindPeak(1.95, 2.05, 1.90, 2.00);
            config_para.is_operation_started = false;
            this.btn_find_return_pt.Invoke((MethodInvoker) delegate { this.btn_find_return_pt.Text = "Find Return Point"; this.btn_find_return_pt.Enabled = true; });
            this.btn_general_op.Invoke((MethodInvoker) delegate { this.btn_general_op.Text = "Start Operation"; this.btn_general_op.Enabled = true; });
            this.btn_device_open.Invoke((MethodInvoker) delegate { this.btn_device_open.Enabled = true; });
        }
Beispiel #2
0
        /// <summary>
        /// Handles the Click event of the btn_find_return_pt control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btn_find_return_pt_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                Button tmp_btn_find_rtnPt = (Button)sender;
                this.Cursor = Cursors.WaitCursor;

                if (config_para.is_operation_started == false)
                {
                    //
                    // Start operation - configure all necessary settings
                    //
                    config_para.curve_index++;
                    if (config_para.curve_index % 10 == 0)
                    {
                        this.btn_clear_chart.PerformClick();
                    }



                    //For load cell's offset calibration
                    config_para.load_cell_offset = daqCard.GetLoadCellOffset();

                    UiUpdateTimer.Tick   += new EventHandler(UiUpdateTimerTick);
                    UiUpdateTimer.Enabled = true;
                    UiUpdateTimer.Start();

                    //reset list for storing data
                    listHandler.resetStoredList();

                    daqCard.Config(ai_buf_ready_callback_for_find_rtn_pt, null);

                    //  motion card's config
                    //Setup Interrupt 0's parameters. After reach pressure limit, we want it returning (using interrupt)
                    int factor = 8;       //Motion Done Interrupt 12. Command stop 8.
                    InterruptForVelocityMove interrFun = motionCard.VelocityMove;
                    object[] arg = { 0 }; //Function parameter for interrFun (mcard.VelocityMove)

                    motionCard.SetupInterrupt(factor, interrFun, arg, ref motionCard.interruptsetup[0]);
                    Thread thread1 = new Thread(new ParameterizedThreadStart(motionCard.CreateInterrupt));
                    thread1.Start(motionCard.interruptsetup[0]);
                    Returned_event.Reset();

                    // Setup threadforCheckervoReturned. This thread is checking if servo returning to start point (by checking encoder)
                    // threadforCheckervoReturned wait for an event.
                    // This event is set when Motion Card's end of returning, determined by 9524 encoder's position.
                    // After event is set, AsyncClear is going to be called to end 9524's double bf acquisition and trigger DASK.AIEnd.
                    // When DASK.AIEnd is signaled, function ai_done_cbdel will be called back.

                    Thread threadforCheckervoReturned = new Thread(CheckServoReturnedForFindRtnPtOperation);
                    threadforCheckervoReturned.Start();

                    //Start pressing movement
                    motionCard.VelocityMove(1);

                    daqCard.StartAcq();

                    config_para.is_operation_started = true;
                    this.btn_device_open.Enabled     = false;
                    this.btn_general_op.Enabled      = false;
                    tmp_btn_find_rtnPt.Text          = "Stop Operation";
                }
                else
                {
                    Thread threadforTerminateOperation = new Thread(TerminateOperation);
                    threadforTerminateOperation.Start();
                }
                this.Cursor = Cursors.Default;
            }
        }