private void listView_output_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listView_output.SelectedItems.Count == 1)
            {
                ListView.SelectedListViewItemCollection items = listView_output.SelectedItems;
                ListViewItem lvItem = items[0];

                int ind = Convert.ToInt32(lvItem.SubItems[0].Text);

                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                {
                    IONameSetting nameSetting = new IONameSetting();
                    nameSetting.IOIndex = ind;
                    nameSetting.IOName  = lvItem.SubItems[1].Text;
                    if (nameSetting.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        lvItem.SubItems[1].Text = nameSetting.IOName;
                        DIOBase io = (DIOBase)m_io;
                        io.ListOutputNames[ind] = nameSetting.IOName;
                    }
                }
                else if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    if (lvItem.Checked)
                    {
                        m_io.WriteOutBit(ind, 1);
                        lvItem.BackColor = Color.YellowGreen;
                    }
                    else
                    {
                        m_io.WriteOutBit(ind, 0);
                        lvItem.BackColor = Color.White;
                    }
                }
            }
        }
예제 #2
0
        private void ProcSequence()
        {
            if (m_mot != null && m_io != null)
            {
                int listSize = m_listSeq.Count;
                int i = 0, repeat = m_nSeqRepeat;

                while (m_bSequenceLive)
                {
                    SEQ_LIST curr = m_listSeq[i++];
                    try
                    {
                        switch (curr.seq)
                        {
                        case SEQUENCE.Delay:
                            int delay = (int)curr.data;
                            Thread.Sleep(delay);
                            break;

                        case SEQUENCE.IO:
                            SEQ_IO dataIO = (SEQ_IO)curr.data;
                            m_io.WriteOutBit(dataIO.nIoNum, Convert.ToUInt32(dataIO.bOn));
                            break;

                        case SEQUENCE.Motion:
                            SEQ_MOTION dataMot = (SEQ_MOTION)curr.data;
                            m_mot.AxisMove(dataMot.nAxisNum, dataMot.dPos, false);
                            while (m_mot.AxisIsBusy(dataMot.nAxisNum))
                            {
                                Thread.Sleep(1);
                            }
                            break;

                        case SEQUENCE.VisionSnap:

                            m_httpCam = HTTP_Cam.GetInstance();
                            if (!m_httpCam.IsInitialize)
                            {
                                m_httpCam.SetInit();
                            }
                            if (m_httpCam.IsInitialize)
                            {
                                string path   = m_httpCam.SavePath + "\\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + ".bmp";
                                Bitmap bitmap = m_httpCam.SnapShot();
                                bitmap.Save(path);
                            }

                            /*
                             * m_httpCam = HTTP_Cam.GetInstance();
                             * string path = m_httpCam.SavePath + "\\" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + ".bmp";
                             *
                             * m_rtspCam = RTSP_Cam.GetInstance();
                             * m_rtspCam.SnapShot();
                             * Bitmap bitmap = m_rtspCam.SnapShot();
                             * bitmap.Save(path);
                             */
                            break;
                        }
                    }
                    catch (Exception E)
                    {
                        LogFile.LogExceptionErr(E.ToString());
                    }

                    if (i >= listSize)
                    {
                        if (m_bSeqContinuous)
                        {
                            i = 0;
                        }
                        else
                        {
                            if (repeat > 1)
                            {
                                repeat--;
                                i = 0;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            m_bSeqContinuous = false;
            m_bSequenceLive  = false;
            m_thSequence     = null;

            return;
        }