Beispiel #1
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            int k = Dmc2210.d2210_read_inbit(Card.cardNo, Card.jiting);

            //int kk = PCI408.PCI408_check_done(Card.zhouhao);
            if (k == 0)
            {
                //if (kk == 0)
                //{
                //Dmc2210.d2210_write_outbit(Card.cardNo, Card.shusongdai, Card.Off);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off);
                //}
            }
            //else if (kk ==1 &&BtnStart.Enabled == false &&getup ==false )
            //{
            //    getup = true;
            //    Console.WriteLine("ssss");
            //    Thread.Sleep(5000);
            //    //Dmc2210.d2210_write_outbit(Card.cardNo, Card.shusongdai, Card.On);
            //    PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On);
            //    PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off);
            //    PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.On);
            //    getup = false;

            //}
        }
Beispiel #2
0
 public void cardInitial()//20170621
 {
     for (ushort i = 0; i < 32; i++)
     {
         PCI408.PCI408_write_outbit(Card.cardNo, (ushort)(Card.Out1 + i), Card.Off);
     }
 }
Beispiel #3
0
        private void MSStoptTimer_OnTime(object sender, EventArgs e)
        {
            //振动盘直震停止
            BtnStart.Enabled = true;
            //玻璃盘停止
            Turntable.Instance.Stop();
            MSStoptTimer.Enabled = false;
            for (int xjh = 0; xjh < Turntable.Instance.PosArray.Count(); xjh++)
            {
                PCI408.PCI408_compare_clear_points_Extern(0, (ushort)(xjh + 1));
                PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(xjh + 1), 1, Card.zhouhao, Turntable.Instance.IOs[xjh]);
                PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(xjh + 1), 20);
            }
            foreach (var c in ccameras)
            {
                if (c.isopen)
                {
                    c.StopGrabbing();
                    c.isfirst = false;
                }
            }
            Turntable.Instance.isStart = false;
            Turntable.Instance.chuchushuju();

            PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On);
            PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off);
            //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.Off);
        }
Beispiel #4
0
        void niuli()
        {
            if (Card.mathineTyple == MathineTyple.fendu)
            {
                int st1 = PCI408.PCI408_read_inbit(Card.cardNo, Card.servoAlarm);
                if (st1 == Card.Off)
                {
                    if (StrongPressEventHandler != null)
                    {
                        zhuanpanStateRuning = false;

                        zhuanPanIsRun = false;
                        StrongPressEventHandler();
                    }
                }
                int state = PCI408.PCI408_read_inbit(Card.cardNo, Card.zhizhenSensor);
                if (state != Card.Off && zhuanPanIsRun && zhuanpanStateRuning)
                {
                    lackStop();
                    zhuanpanStateRuning = false;
                }
                else if (state == Card.Off && zhuanPanIsRun && !zhizhenLowSensor.timer.IsRunning && !zhuanpanStateRuning)
                {
                    lackStart();
                }
            }
        }
Beispiel #5
0
 void wuliaotingzhiEventHandler()
 {
     if (InvokeRequired)
     {
         Invoke(new Turntable.StrongPress(wuliaotingzhiEventHandler));
         return;
     }
     if (MSStoptTimer.Enabled)
     {
         MSStoptTimer.Enabled = false;
     }
     Turntable.Instance.stopShakePan();
     Turntable.Instance.Stop();
     PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On);
     PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off);
     //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.Off);
     foreach (var c in ccameras)
     {
         if (c.isopen)
         {
             c.StopGrabbing();
             c.isfirst = false;
         }
     }
     BtnStart.Enabled = true;
 }
Beispiel #6
0
 public void stopShakePan()
 {
     //Turntable.Instance.cardInitial();
     PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off);
     //Thread.Sleep(4500);
     //isStart = false;
 }
Beispiel #7
0
        private void BtnPanCtrl_Click(object sender, EventArgs e)
        {
            if (!Panstart)
            {
                Turntable.Instance.Start();


                speed = speed < 1000 ? 1000 : speed;
                PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On);
                PCI408.PCI408_set_profile(Card.cardNo, 1000, speed, Card.acc, Card.acc);
                PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.On);
                BtnPanCtrl.Text = "停止运动";
            }
            else
            {
                Turntable.Instance.Stop();

                PCI408.PCI408_decel_stop(Card.cardNo, Card.acc);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.Off);
                Thread.Sleep(5000);
                BtnPanCtrl.Text = "转盘启动测试";
            }
            Panstart = !Panstart;
        }
Beispiel #8
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            BtnStart.Enabled = false;
            try
            {
                DataRowCollection drc = ds.Tables["detailTable"].Rows;

                foreach (CCamera c in ccameras)
                {
                    if (c.isfirst == true)
                    {
                        c.Open();
                        //c.isfirst = false;
                    }
                    //c.SetModeFeature("TriggerMode", "On");
                    if (c.isopen)
                    {
                        c.StartGrab();
                        int count     = 0;
                        int tempcount = c.goodcountlist.Count;
                        foreach (DataRow dr in drc)
                        {
                            if (dr[0].ToString() == c.logicName)
                            {
                                count++;
                                if (count > tempcount)
                                {
                                    c.goodcountlist.Add(0);
                                    c.badcountlist.Add(0);
                                }
                            }
                        }
                    }
                    else
                    {
                        ccameras.Remove(c);
                    }
                }
                //玻璃盘启动
                if (isfirstrun)
                {
                    PCI408.PCI408_set_encoder(0, 0);
                    Turntable.Instance.isStart = false;
                    isfirstrun = false;
                }
                timer1.Interval       = 1000;
                timer1.Enabled        = true;
                timer2.Interval       = 50;
                timer2.Enabled        = true;
                MSStartTimer.Interval = 5000;
                MSStartTimer.Start();
                Turntable.Instance.Start();
                //  PCI408.PCI408_write_outbit(Card.cardNo, 5, Card.On);
            }
            catch (Exception ex)
            {
                MyDebug.ShowMessage(ex, "start error");
            }
        }
Beispiel #9
0
 public void Stop()
 {
     SpeedTime.Enabled = false;
     //isStart=false;
     PCI408.PCI408_decel_stop(Card.cardNo, Card.acc);
     //PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.Off);
     zhuanPanIsRun = false;
     // PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.Off);
 }
Beispiel #10
0
        public void startShakePan()
        {
            int j = PCI408.PCI408_check_done(Card.cardNo);

            if (j == 0)
            {
                PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.On);
            }
        }
Beispiel #11
0
        void lackStop()
        {
            SpeedTime.Stop();
            SpeedTime.Enabled = false;

            PCI408.PCI408_decel_stop(Card.cardNo, Card.acc);
            //PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan,Card.Off);
            niulimax = Card.niulimax;
        }
Beispiel #12
0
 private void MSStartTimer_OnTime(object sender, EventArgs e)
 {
     //振动盘直震启动
     Turntable.Instance.startShakePan();
     MSStartTimer.Enabled = false;
     MSStartTimer.Enabled = false;
     PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off);
     PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On);
     //PCI408.PCI408_write_outbit(Card.cardNo, Card.ssd, Card.On);
 }
        static void Main()
        {
            //string productPath;
            try
            {
                bool runone;
                System.Threading.Mutex run = new System.Threading.Mutex(true, "xinbiao_a_test", out runone);
                if (runone)
                {
                    run.ReleaseMutex();
#if DEBUG
                    /* This is a special debug setting needed only for GigE cameras.
                     * See 'Building Applications with pylon' in the Programmer's Guide. */
                    Environment.SetEnvironmentVariable("PYLON_GIGE_HEARTBEAT", "300000" /*ms*/);
#endif
                    //Pylon.Initialize();
                    int cards = 0;

                    cards = PCI408.PCI408_card_init();
                    if (cards == 0)
                    {
                        MessageBox.Show("运动控制卡丢失");
                    }
                    else if (cards > 8)
                    {
                        MessageBox.Show("运动控制卡初始化错误 错误号: " + cards.ToString());
                    }
                    HOperatorSet.SetSystem("do_low_error", "false");
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    //Application.Run(new MainForm());
                    SplashWindow.LoadAndRun(new MainForm());
                    //Pylon.Terminate();
                }
                else
                {
                    MessageBox.Show("视觉软件已经打开。");
                }
            }
            catch (Exception ex)
            {
                var trace = new StackTrace(ex, true).GetFrame(0);
                //LOG log = new LOG();
                string s = string.Format("文件名:{0},行号:{1}, 函数名 :{2}", trace.GetFileName(), trace.GetFileLineNumber(), trace.GetMethod());
                //log.WriteLogFile(s);
                Debug.Print(ex.Message);
                Debug.Print(s);
            }
            finally
            {
                // Pylon.Terminate();
                PCI408.PCI408_board_close();
            }
        }
Beispiel #14
0
        void zhizhenLowSensor_OnTimerEvent(object sender, EventArgs e)
        {
            int state = PCI408.PCI408_read_inbit(Card.cardNo, Card.zhizhenSensor);

            if (state != Card.On)
            {
                SpeedTime.Start();
                PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On);
                PCI408.PCI408_set_profile(Card.cardNo, Card.minspeed, Card.maxspeed, Card.acc, Card.acc);
                PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.On);
                zhuanpanStateRuning = true;
                zhizhenLowSensor.timer.Stop();
            }
        }
Beispiel #15
0
 public void Start()
 {
     if (!isStart)
     {
         for (int i = 0; i < IOs.Count; i++)
         {
             PCI408.PCI408_write_outbit(Card.cardNo, IOs[i], Card.Off);
         }
         thread = new Thread(Run);
         thread.IsBackground = true;
         thread.Priority     = ThreadPriority.Highest;
         thread.Start();
         isStart = true;
     }
     SpeedTime.Start();
     //PCI408.PCI408_write_SEVON_PIN(Card.cardNo, Card.On);
     PCI408.PCI408_set_profile(Card.cardNo, Card.minspeed, Card.maxspeed, Card.acc, Card.acc);
     PCI408.PCI408_vmove(Card.cardNo, 0, Card.maxspeed);
     zhuanPanIsRun = true;
 }
Beispiel #16
0
        void Run()
        {
            //将当前线程绑定到指定的cpu核心上
            GetCpu.SetThreadAffinityMask(GetCpu.GetCurrentThread(), new UIntPtr(0x4));

            kzwbmlt12 = DateTime.Now;
            string   path = PathHelper.currentProductPath + @"\" + "spd" + ".txt";
            DateTime t1;
            int      xjfwi;

            spd = Card.maxspeed;
            int preSignal = 0, signal = 0;

            PCI408.PCI408_counter_config(0, 3);
            PCI408.PCI408_set_encoder(0, 0);
            int  fwjs1 = 0, fwjs2 = 0; sdkz3 = 100000;
            long cuowu = PCI408.PCI408_compare_set_filter_Extern(Card.cardNo, 100000);

            PCI408.PCI408_config_latch_mode(Card.cardNo, Card.zhouhao);
            sdkzt1 = DateTime.Now; sdkzt2 = DateTime.Now; sdkzt4 = DateTime.Now; sdkzt3 = DateTime.Now;
            long jcqbz;

            for (int xjh = 0; xjh < PosArray.Count(); xjh++)
            {
                PCI408.PCI408_compare_clear_points_Extern(0, (ushort)(xjh + 1));
                PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(xjh + 1), 1, Card.zhouhao, IOs[xjh]);
                PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(xjh + 1), 20);
            }
            PCI408.PCI408_reset_latch_flag(Card.cardNo);
            long s5;

            currentPos = (int)PCI408.PCI408_get_encoder(Card.cardNo);
            int[] sigci = new int[5], psigci = new int[5];
            for (int sigfi = 0; sigfi < 5; sigfi++)
            {
                sigci[sigfi]  = 0;
                psigci[sigfi] = 0;
            }

            //?
            int zdwy = 40000;

            while (isStart)
            {
                try
                {
                    //    for (xjfwi = 1; xjfwi < cameraCount + 1; xjfwi++)
                    //{
                    //    xjfws[xjfwi].t2 = DateTime.Now;
                    //    //if (xjfws[xjfwi].tsc() > 200000 && copos[xjfwi].pos.Count() > 0)
                    //   //if (xjfws[xjfwi].tsc() > 200000)
                    //   // {
                    //   //     //copos[0].pos.Clear();
                    //   //     //copos[1].pos.Clear();
                    //   //     //copos[2].pos.Clear();
                    //   //     //copos[3].pos.Clear();
                    //   //     //copos[4].pos.Clear();
                    //   //     //copos[5].pos.Clear();
                    //   //     //copos[6].pos.Clear();
                    //   //     nutqueue.Clear();
                    //   //     xjfws.Initialize();
                    //   //     copos.Initialize();
                    //   //     timers.Initialize();
                    //   //     xjfws = new xjfw[7];
                    //   //     //for (xjfwi = 0; xjfwi < 5; xjfwi++)
                    //   //     //{
                    //   //     //    xjfws[xjfwi] = new xjfw();
                    //   //     //    xjfws[xjfwi].ID = xjfwi;
                    //   //     //    xjfws[xjfwi].t1 = DateTime.Now;
                    //   //     //    xjfws[xjfwi].t2 = DateTime.Now;
                    //   //     //}
                    //   //     copos = new coppos[7];
                    //   //     //for (int k = 0; k < 5; k++)
                    //   //     //{
                    //   //     //    copos[k] = new coppos();
                    //   //     //    copos[k].ID = k;
                    //   //     //    //copos[k].onwrite = false;
                    //   //     //}
                    //   //     timers = new MyTimer[7];
                    //   //     //for (int i = 0; i < timers.Length; i++)
                    //   //     //{
                    //   //     //    timers[i] = new MyTimer();
                    //   //     //    timers[i].ID = i;
                    //   //     //    //timers[i].OnTimerEvent += new MyTimer.OnTimerEventHandler(OnTimer);
                    //   //     //}
                    //   //     //Thread.Sleep(1000);
                    //   // }
                    //}
                    //    t1 = DateTime.Now;
                    currentPos = (int)PCI408.PCI408_get_encoder(Card.zhouhao);
                    for (int sr = 0; sr < cameraCount; sr++)
                    {
                        sigci[sr] = PCI408.PCI408_read_inbit(Card.cardNo, (ushort)xjzsr[sr]);
                        if (sigci[sr] == 0 && psigci[sr] == 1)
                        {
                            int length1 = dpdl[sr].Count(), jr = 200, jr1 = 5000;
                            for (int listi = 0; listi < length1; listi++)
                            {
                                int ssg = Math.Abs(dpdl[sr][listi] + PosArray[sr] - currentPos);
                                if (ssg < jr1)
                                {
                                    jr1 = ssg;
                                    jr  = listi;
                                }
                            }
                            if (jr != 200 && jr1 < 5000)
                            {
                                copos[sr].pos.Add(dpdl[sr][jr]);
                                //   Console.WriteLine("trun " + DateTime.Now.ToString("mm-ss-fff"));
                                dpdl[sr].RemoveAt(jr);
                            }
                        }
                        psigci[sr] = sigci[sr];
                    }
                    for (int sr1 = 0; sr1 < cameraCount; sr1++)
                    {
                        int length2 = dpdl[sr1].Count();
                        for (int listi1 = 0; listi1 < length2; listi1++)
                        {
                            if (Math.Abs(currentPos - dpdl[sr1][listi1]) > zdwy)
                            {
                                dpdl[sr1].RemoveAt(listi1);
                            }
                        }
                    }
                    jcqbz = PCI408.PCI408_get_latch_flag(Card.cardNo);    //读取锁存器状态
                    if ((jcqbz & 0xf00) > 0)
                    {
                        PCI408.PCI408_reset_latch_flag(Card.cardNo);
                        signal = PCI408.PCI408_get_latch_value(Card.zhouhao);
                    }
                    if (fwjs1 - fwjs2 > 4000)
                    {
                        fwjs1 = fwjs2;
                        for (int sr = 0; sr < cameraCount; sr++)
                        {
                            sigci[sr]  = 0;
                            psigci[sr] = 0;
                            dpdl[sr].Clear();
                            copos[sr].pos.Clear();
                        }
                        for (int xjh = 0; xjh < PosArray.Count(); xjh++)
                        {
                            PCI408.PCI408_set_encoder(0, 0);
                            PCI408.PCI408_compare_clear_points_Extern(0, (ushort)(xjh + 1));
                            PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(xjh + 1), 1, Card.zhouhao, IOs[xjh]);
                            PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(xjh + 1), 5);
                        }
                        for (int xjs = 0; xjs < cameraCount; xjs++)
                        {
                            jcqdls[xjs].clear();
                            //File.AppendAllText(path,signal.ToString()+"  ", Encoding.Default);
                        }
                        PCI408.PCI408_reset_latch_flag(Card.cardNo);
                        preSignal = signal;
                        if (isStart)
                        {
                            nutqueue.Clear();
                        }
                    }
                    if (signal != preSignal)
                    {
                        kzwbmlt12 = DateTime.Now;
                        s5        = PCI408.PCI408_compare_get_points_remained_Extern(0, 1);
                        if (s5 > cameraCount + 3)
                        {
                            Nut nut = new Nut();
                            fwjs1         += 1;
                            nut.initialPos = signal;
                            nutqueue.Add(nut);
                            nut.cas = cameraCount;
                            pn.totalCount++;
                            speedTemp++;
                            ss = pn.totalCount;
                            for (int xjs = 0; xjs < cameraCount; xjs++)
                            {
                                PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(xjs + 1), 1, Card.zhouhao, 1);
                                PCI408.PCI408_compare_add_point_Extern(Card.cardNo, (ushort)(xjs + 1), PosArray[xjs] + (int)signal, 1, 9, IOs[xjs]);

                                // copos[nut.posNo + 1].pos.Add (nut.initialPos);
                                // copos[nut.posNo + 1].onwrite = true;
                                dpdl[xjs].Add(signal);
                                // Console.WriteLine("ss" + signal);
                                //File.AppendAllText(path,signal.ToString()+"  ", Encoding.Default);
                            }
                        }
                    }
                    niuli();

                    for (int i = nutqueue.Count - 1; i > -1; i--)
                    {
                        Nut nutc = new Nut();
                        nutc = nutqueue[i];
                        //if (currentPos < nutc.initialPos)
                        //{
                        //    nutqueue.Remove(nutc);
                        //    break;
                        //}
                        if (currentPos - nutc.initialPos > PosArray[cameraCount] - 1000)
                        {
                            int a = nutc.getTheHole();
                            switch (a.ToString())
                            {
                            case "1":
                                //pn.mnum++;
                                //Console.WriteLine("cipin" + pn.mnum);
                                PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(cameraCount + 1), 1, Card.zhouhao, 1);
                                PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(cameraCount + 1), 10);
                                PCI408.PCI408_compare_add_point_Extern(Card.cardNo, (ushort)(cameraCount + 1), PosArray[cameraCount] + (int)nutc.initialPos, 1, 9, IOs[cameraCount]);
                                break;

                            //case "3":
                            //pn.nnum++;
                            //Console.WriteLine("未识别" + pn.nnum);
                            //PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(cameraCount + 1), 1, Card.zhouhao, 1);
                            //PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(cameraCount + 1), 20);
                            //PCI408.PCI408_compare_add_point_Extern(Card.cardNo, (ushort)(cameraCount + 1), PosArray[cameraCount] + (int)nutc.initialPos, 1, 9, IOs[cameraCount]);
                            //break;
                            case "2":
                                pn.goodNum++;
                                fwjs2 = fwjs1;
                                PCI408.PCI408_compare_config_Extern(Card.cardNo, (ushort)(cameraCount + 2), 1, Card.zhouhao, 1);
                                PCI408.PCI408_compare_set_pulsetimes_Extern(0, (ushort)(cameraCount + 2), 10);
                                PCI408.PCI408_compare_add_point_Extern(Card.cardNo, (ushort)(cameraCount + 2), PosArray[cameraCount + 1] + (int)nutc.initialPos, 1, 9, IOs[cameraCount + 1]);
                                break;
                            }
                            jcjg2 = nutc.jiance;
                            Thread ccjcjg = new Thread(cunchujiancejieguo);
                            ccjcjg.Start();
                            nutqueue.Remove(nutc);
                            pn.badNum = pn.totalCount - pn.goodNum;
                        }
                    }
                    preSignal = signal;
                    kongzhiwaibu();
                    sdkzt1 = DateTime.Now;
                    sdkzt4 = DateTime.Now;
                    if (Card.sjc(sdkzt3, sdkzt4) < sdkz3)
                    {
                        sdkz3 = Card.sjc(sdkzt3, sdkzt4);
                    }
                    sdkzt3 = DateTime.Now;
                    //if (Card.sjc(sdkzt2, sdkzt1) > 60000)
                    //{
                    //    sdkzt2 = DateTime.Now;
                    //    if (sdkz3 < 10)
                    //    {
                    //        spd = spd + 100;
                    //        PCI408.PCI408_change_speed(Card.cardNo, spd);
                    //        File.AppendAllText(path, spd.ToString() + "  ", Encoding.Default);
                    //    }
                    //}
                }
                catch (Exception e)
                {
                    MyDebug.ShowMessage(e, "运动控制出错");
                }
                finally
                {
                    //MyDebug.ShowMessage(nutqueue.Count.ToString());
                }
            }
        }
Beispiel #17
0
 public Turntable()
 {
     wkb      = new HSSFWorkbook();
     sheet    = wkb.CreateSheet("检测结果(Measure Data)");
     tjcjg    = DateTime.Now;
     sheetrr  = sheet.CreateRow(sheetr);
     xjzsr[0] = 2;
     xjzsr[1] = 34;
     xjzsr[2] = 30; //31
     xjzsr[3] = 3;  //21
     xjzsr[4] = 4;  //32
     sheetcc  = sheetrr.CreateCell(sheetc);
     watchdog.OnTimerEvent         += new MyTimer.OnTimerEventHandler(watchdog_OnTimerEvent);
     zhuanPanIsRun                  = false;
     zhizhenLowSensor               = new MyTimer();
     StartDelay.OnTimerEvent       += new MyTimer.OnTimerEventHandler(StartDelay_OnTimerEvent);
     zhizhenLowSensor.OnTimerEvent += new MyTimer.OnTimerEventHandler(zhizhenLowSensor_OnTimerEvent);
     MySerialPort = new SerialPort();
     MySerialPort.DataReceived += new SerialDataReceivedEventHandler(MySerialPort_DataReceived);
     isbussy  = false;
     nutqueue = new List <Nut>();
     isStart  = false;
     jcqdls   = new jcqdl[5];
     bjgd     = new long[5];
     for (int jcqdlsl = 0; jcqdlsl < 5; jcqdlsl++)
     {
         jcqdls[jcqdlsl]         = new jcqdl();
         jcqdls[jcqdlsl].xjjcqdl = new Queue <long>();
         bjgd[jcqdlsl]           = 0;
     }
     xjfws = new xjfw[7];
     for (int xjfwi = 0; xjfwi < 5; xjfwi++)
     {
         xjfws[xjfwi]    = new xjfw();
         xjfws[xjfwi].ID = xjfwi;
         xjfws[xjfwi].t1 = DateTime.Now;
         xjfws[xjfwi].t2 = DateTime.Now;
     }
     copos = new coppos[7];
     for (int k = 0; k < 5; k++)
     {
         copos[k]    = new coppos();
         copos[k].ID = k;
         //  copos[k].onwrite = false;
     }
     timers = new MyTimer[7];
     for (int i = 0; i < timers.Length; i++)
     {
         timers[i]    = new MyTimer();
         timers[i].ID = i;
         //timers[i].OnTimerEvent += new MyTimer.OnTimerEventHandler(OnTimer);
     }
     dpdl = new List <int> [5];
     for (int i = 0; i < 5; i++)
     {
         dpdl[i] = new List <int>();
     }
     for (ushort i = 0; i < 9; i++)
     {
         PCI408.PCI408_write_outbit(Card.cardNo, (ushort)(Card.Out1 + i), Card.Off);
     }
     PCI408.PCI408_set_position(Card.cardNo, 0);
     PCI408.PCI408_set_pulse_outmode(Card.cardNo, 0);
     //SpeedTime.Tick += new EventHandler(SpeedTime_OnTime);
     SpeedTime.Enabled   = true;
     SpeedTime.Interval  = 5000;
     zhuanpanStateRuning = false;
     //if (!MySerialPort.IsOpen)
     //{
     //    MySerialPort.BaudRate = 9600;
     //    MySerialPort.StopBits = StopBits.One;
     //    MySerialPort.Parity = Parity.None;
     //    MySerialPort.PortName = "COM1";
     //    MySerialPort.DataBits = 8;
     //    MySerialPort.ReceivedBytesThreshold = 21;
     //    MySerialPort.ReadBufferSize = 512;
     //    MySerialPort.Open();
     //}
 }
Beispiel #18
0
        private void kongzhiwaibu()
        {
            kzwbmlt11 = DateTime.Now;
            kzwbmlts  = kzwbmlt11 - kzwbmlt12;
            int kzwbml;

            kzwbml = kzwbmlts.Days * 86400 + kzwbmlts.Hours * 3600 + kzwbmlts.Minutes * 60 + kzwbmlts.Seconds;
            if (kzwbml > 240)
            {
                Onwuliao();
                baojing = new Thread(bjzx);
                baojing.Start();
                isStart = false;
            }
            djzt = PCI408.PCI408_check_done(Card.cardNo);
            if (djzt == 1)
            {
                if (kzwbhdzt == 1)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.On);
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.shakePan, Card.Off);
                    kzwbhdzt = 0;
                }
                if (kzwbldzt == 1)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.Off);
                    kzwbldzt = 1;
                }
            }
            else
            {
                if (kzwbldzt == 1)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.ld, Card.On);
                    kzwbldzt = 0;
                }
                if (kzwbhdzt == 0)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.hd, Card.Off);
                    kzwbhdzt = 1;
                }
            }
            if (sc == 1)
            {
                s4 = PCI408.PCI408_read_inbit(Card.cardNo, Card.jsqm);
                if (s4 == 0)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.jsqqg, Card.Off);
                    sc = 0;
                }
            }
            if (sc == 0)
            {
                s5 = PCI408.PCI408_read_inbit(Card.cardNo, Card.jsqfw);
                if (s5 == 0)
                {
                    PCI408.PCI408_write_outbit(Card.cardNo, Card.jsqqg, Card.On);
                    sc    = 1;
                    lmxh2 = DateTime.Now;
                }
            }
            lmxhts = lmxh1 - lmxh2;//20170622
            lmxh1  = DateTime.Now;
            int lmxh;

            lmxh = lmxhts.Days * 86400 + lmxhts.Hours * 3600 + lmxhts.Minutes * 60 + lmxhts.Seconds;
            if (lmxh > 60 && sc == 1)
            {
                //baojing = new Thread(bjzx);
                //baojing.Start();
                //isStart = false;
                //lackStop();
                ////zhuanpanStateRuning = false;
                //SpeedTime.Stop();
                //Turntable.Instance.Stop();
                //zhuanpanStateRuning = false;
                ////zhizhenLowSensor.timer.Start();
                //SpeedTime.Enabled = false;
                PCI408.PCI408_decel_stop(Card.cardNo, Card.acc);
                PCI408.PCI408_write_outbit(Card.cardNo, Card.chuiqizongkaiguan, Card.Off);
                //zhuanPanIsRun = false;
                //zhizhenLowSensor.timer.Stop();
            }
        }
Beispiel #19
0
 public void servoAlarmClear()
 {
     PCI408.PCI408_write_outbit(Card.cardNo, Card.servoRes, Card.On);
     Thread.Sleep(100);
     PCI408.PCI408_write_outbit(Card.cardNo, Card.servoRes, Card.Off);
 }