示例#1
0
        //public SpyderCamera Instance
        //{
        //    get
        //    {
        //        lock (padlock)
        //        {
        //            if (SpyderCamera.instance == null)
        //            {
        //                instance = new SpyderCamera();
        //            }
        //            return instance;
        //        }
        //    }
        //}

        // Call Create method
        public bool Initialize()
        {
            // define on-line object
            m_Acquisition = new SapAcquisition(m_ServerLocation, m_ConfigFileName);
            if (SapBuffer.IsBufferTypeSupported(m_ServerLocation, SapBuffer.MemoryType.ScatterGather))
            {
                m_Buffers = new SapBufferWithTrash(2, m_Acquisition, SapBuffer.MemoryType.ScatterGather);
            }
            else
            {
                m_Buffers = new SapBufferWithTrash(2, m_Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
            }
            m_Xfer = new SapAcqToBuf(m_Acquisition, m_Buffers);
            m_View = new SapView(m_Buffers);


            //event for view
            m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
            m_Xfer.XferNotify        += new SapXferNotifyHandler(XferNotify);
            m_Xfer.XferNotifyContext  = this;

            // event for signal status
            m_Acquisition.SignalNotify       += new SapSignalNotifyHandler(GetSignalStatus);
            m_Acquisition.SignalNotifyContext = this;


            return(true);
        }
示例#2
0
        public BufferDlg(SapBuffer buffer, SapDisplay display, bool Online)
        {
            InitializeComponent();
            m_isXfer     = Online;
            m_sapDisplay = display;

            textBox1_Count.Text      = buffer.Count.ToString();
            textBox1_Width.Text      = buffer.Width.ToString();
            textBox1_Height.Text     = buffer.Height.ToString();
            textBox1_PixelDepth.Text = buffer.PixelDepth.ToString();

            m_Count             = buffer.Count;
            m_Width             = buffer.Width;
            m_Height            = buffer.Height;
            m_pixelDepth        = buffer.PixelDepth;
            m_format            = buffer.Format;
            m_type              = buffer.Type;
            m_ScatterGatherType = SapBuffer.MemoryType.ScatterGather;

            // For acquisition hardware with DMA transfers using 32-bit addresses in 64-bit Windows (e.g., X64-CL iPro)
            if (buffer.SrcNode != null)
            {
                if (!SapBuffer.IsBufferTypeSupported(buffer.SrcNode.Location, SapBuffer.MemoryType.ScatterGather))
                {
                    m_ScatterGatherType = SapBuffer.MemoryType.ScatterGatherPhysical;
                }
            }

            Initialize_Format_Combo();
            Initialize_Type_Flags();
            EnableControls();
        }
示例#3
0
        private IDalsaTDICam Initialize()
        {
            try
            {
                ServerLocation = new SapLocation(ServerName, ResourceIndex);
                Acquisition    = new SapAcquisition(ServerLocation, ConfigFile);

                if (SapBuffer.IsBufferTypeSupported(ServerLocation, SapBuffer.MemoryType.ScatterGather))
                {
                    Buffers = new SapBufferWithTrash(2, Acquisition, SapBuffer.MemoryType.ScatterGather);
                }
                else
                {
                    Buffers = new SapBufferWithTrash(2, Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
                }

                Acquisition.Create();

                Xfer = new SapAcqToBuf(Acquisition, Buffers);
                Xfer.Pairs [0].EventType = SapXferPair.XferEventType.EndOfFrame;
                return(this);
            }
            catch (Exception)
            {
                MessageBox.Show("Camera initialization is fail");
                return(null);
            }
        }
示例#4
0
        public bool CreateNewObjects(SapLocation location, string fileName, bool Restore)
        {
            if (Online)
            {
                if (!Restore)
                {
                    Location = location;
                }

                if (!SapManager.IsResourceAvailable(location, SapManager.ResourceType.Acq))
                {
                    Debug.WriteLine(fileName + "available");
                    return(false);
                }

                Acquisition = new SapAcquisition(Location, fileName);
                if (SapBuffer.IsBufferTypeSupported(Location, SapBuffer.MemoryType.ScatterGather))
                {
                    Buffers = new SapBufferWithTrash(4, Acquisition, SapBuffer.MemoryType.ScatterGather);
                }
                else
                {
                    Buffers = new SapBufferWithTrash(4, Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
                }
                Xfer   = new SapAcqToBuf(Acquisition, Buffers);
                m_View = new SapView(Buffers);

                Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
                Xfer.XferNotify        += xfer_XferNotify;
                Xfer.XferNotifyContext  = this;
            }
            else
            {
                Buffers = new SapBuffer();
            }

            if (!CreateObjects())
            {
                DisposeObjects();
                return(false);
            }

            return(true);
        }
示例#5
0
        public bool CreateNewObjects(SapLocation ServerLocation, string ConfigFile)
        {
            m_Acquisition = new SapAcquisition(m_ServerLocation, ConfigFile);
            if (SapBuffer.IsBufferTypeSupported(m_ServerLocation, SapBuffer.MemoryType.ScatterGather))
            {
                m_Buffers = new SapBufferWithTrash(2, m_Acquisition, SapBuffer.MemoryType.ScatterGather);
            }
            else
            {
                m_Buffers = new SapBufferWithTrash(2, m_Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
            }
            m_Xfer = new SapAcqToBuf(m_Acquisition, m_Buffers);


            //event for view
            m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
            m_Xfer.XferNotify        += new SapXferNotifyHandler(xfer_XferNotify);

            return(true);
        }
示例#6
0
        protected override bool?CreateCamObj()
        {
            ServerLocation = new SapLocation(ServerName, ResourceIndex);
            Acquisition    = new SapAcquisition(ServerLocation, ConfigFile);

            if (SapBuffer.IsBufferTypeSupported(ServerLocation, SapBuffer.MemoryType.ScatterGather))
            {
                Buffers = new SapBufferWithTrash(2, Acquisition, SapBuffer.MemoryType.ScatterGather);
            }
            else
            {
                Buffers = new SapBufferWithTrash(2, Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
            }

            Acquisition.Create();

            Xfer = new SapAcqToBuf(Acquisition, Buffers);
            Xfer.Pairs [0].EventType = SapXferPair.XferEventType.EndOfFrame;

            View = new SapView(Buffers);
            return(true);
        }
示例#7
0
        bool CreateDeviceMana(IConnection connectModule)
        {
            try
            {
                DalsaMemObj.ServerLocation = new SapLocation(connectModule.ServerName, connectModule.ResourceIndex);
                DalsaMemObj.Acquisition    = new SapAcquisition(DalsaMemObj.ServerLocation, connectModule.ConfigFile);

                if (SapBuffer.IsBufferTypeSupported(DalsaMemObj.ServerLocation, SapBuffer.MemoryType.ScatterGather))
                {
                    DalsaMemObj.Buffers = new SapBufferWithTrash(2, DalsaMemObj.Acquisition, SapBuffer.MemoryType.ScatterGather);
                }
                else
                {
                    DalsaMemObj.Buffers = new SapBufferWithTrash(2, DalsaMemObj.Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
                }

                var objSetting = new ObjectSetting();
                objSetting.AcqusitionSetting(DalsaMemObj.Acquisition);

                DalsaMemObj.Xfer = new SapAcqToBuf(DalsaMemObj.Acquisition, DalsaMemObj.Buffers);
                DalsaMemObj.Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;

                DalsaMemObj.View = new SapView(DalsaMemObj.Buffers);

                DalsaMemObj.Xfer.XferNotify       += new SapXferNotifyHandler(GrabDoneEventMethod);
                DalsaMemObj.Xfer.XferNotifyContext = DalsaMemObj.View;

                var creatobject = new CreatesObjects();
                creatobject.CreatEndSqObject(DalsaMemObj.Buffers, DalsaMemObj.Xfer, DalsaMemObj.View);
                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
示例#8
0
        /// <summary>
        /// 初始化设备
        /// </summary>
        /// <param name="acConfigDlg"></param>
        /// <param name="Restore"></param>
        /// <returns></returns>
        public bool CreateNewObjects(AcqConfigDlg acConfigDlg, bool Restore)
        {
            if (!Restore)
            {
                m_ServerLocation = acConfigDlg.ServerLocation;
                m_ConfigFileName = acConfigDlg.ConfigFile;
            }
            m_AcqDevice = new SapAcqDevice(m_ServerLocation, m_ConfigFileName);
            if (SapBuffer.IsBufferTypeSupported(m_ServerLocation, SapBuffer.MemoryType.ScatterGather))
            {
                m_Buffers = new SapBufferWithTrash(2, m_AcqDevice, SapBuffer.MemoryType.ScatterGather);
            }
            else
            {
                m_Buffers = new SapBufferWithTrash(2, m_AcqDevice, SapBuffer.MemoryType.ScatterGatherPhysical);
            }
            m_Xfer          = new SapAcqDeviceToBuf(m_AcqDevice, m_Buffers);
            m_View          = new SapView(m_Buffers);
            m_ImageBox.View = m_View;

            m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
            m_Xfer.XferNotify        += new SapXferNotifyHandler(xfer_XferNotify);
            m_Xfer.XferNotifyContext  = this;
            StatusLabelInfo.Text      = "Online... Waiting grabbed images";

            if (!CreateObjects())
            {
                DisposeObjects();
                return(false);
            }

            // Resize ImagBox to take into account the size of created sapview
            m_ImageBox.OnSize();
            UpdateControls();
            return(true);
        }
示例#9
0
        public override bool DoInit()
        {
            int DalsaCardCount = SapManager.GetServerCount(); //获取图像采集卡的数量

            for (int i = 0; i < DalsaCardCount; i++)
            {
                bool bAcq       = false;
                bool bAcqDevice = false;
                if (SapManager.GetResourceCount(i, SapManager.ResourceType.Acq) > 0)
                {
                    bAcq = true;                                                                     //卡的数量大于0
                }
                if (SapManager.GetResourceCount(i, SapManager.ResourceType.AcqDevice) > 0)
                {
                    bAcqDevice = true;                                                                    //相机数量大于0
                }
                if (bAcq)
                {
                    string ServerName = SapManager.GetServerName(i);
                    if (this.myCamPara.ServerName == ServerName)
                    {
                        bServerFound = true; //发现图像采集卡
                        string DeviceName = SapManager.GetResourceName(ServerName, SapManager.ResourceType.Acq, 0);
                        if (this.myCamPara.DeviceName != DeviceName)
                        {
                            Logger.PopError("采集卡上找到的相机名字和campara里的名字不同");
                            return(false);
                        }
                    }
                }
                else if (bAcqDevice) //没有采集卡,相机直接传给电脑
                {
                    CameraIsFound = true;
                    string serverName = SapManager.GetServerName(i);
                }
            }
            if (!bServerFound && !CameraIsFound)  //至少需要一张采集卡,或者相机装置
            {
                m_Buffers = new SapBuffer();
                return(false);
            }
            else
            {
                SapLocation location = new SapLocation(this.myCamPara.ServerName, 0);
                if (SapManager.GetResourceCount(this.myCamPara.ServerName, SapManager.ResourceType.Acq) > 0)
                {
                    m_Acquisition = new SapAcquisition(location, System.Windows.Forms.Application.StartupPath + "\\ccf\\" + this.myCamPara.CcfPath + ".ccf");
                    //m_AcqDevice = new SapAcqDevice(location, System.Windows.Forms.Application.StartupPath + "\\ccf\\" + this.myCamPara.CcfPath + ".ccf");
                    if (SapBuffer.IsBufferTypeSupported(location, SapBuffer.MemoryType.ScatterGather))
                    {
                        m_Buffers = new SapBuffer(m_RingBufCount, m_Acquisition, SapBuffer.MemoryType.ScatterGather); //buffer里有10段内存,用来循环存储从相机采集的图片
                    }
                    else
                    {
                        m_Buffers = new SapBufferWithTrash(m_RingBufCount, m_Acquisition, SapBuffer.MemoryType.ScatterGatherPhysical);
                    }
                    m_Xfer = new SapAcqToBuf(m_Acquisition, m_Buffers);
                    m_Xfer.Pairs[0].EventType = SapXferPair.XferEventType.EndOfFrame;
                    m_Xfer.XferNotify        += new SapXferNotifyHandler(AcqCallback1);
                    m_Xfer.XferNotifyContext  = this;
                    // event for signal status
                    if (!SeparaInterface_CreateObjects())
                    {
                        Logger.PopError(" 创建 相关的采集、传输、缓存对象失败");
                        this.SeparaInterface_DisposeObjects();
                        return(false);
                    }
                    this.FrameImgHei = this.SeparaInterface_GetImageHeight();
                    this.FrameImgWid = this.SeparaInterface_GetImageWidth();
                    return(true);
                }
            }
            return(false);
        }