Exemplo n.º 1
0
        public bool SetStreamBufferCount(long count)
        {
            try
            {
                // set to manual
                INodeMap sNodeMap             = managedCamera.GetTLStreamNodeMap();
                IEnum    sBufferCountSelector = sNodeMap.GetNode <IEnum>("StreamBufferCountMode");
                if (sBufferCountSelector == null || !sBufferCountSelector.IsWritable)
                {
                    return(false);
                }
                IEnumEntry iBufferCountManual = sBufferCountSelector.GetEntryByName("Manual");
                if (iBufferCountManual == null || !iBufferCountManual.IsReadable)
                {
                    return(false);
                }
                sBufferCountSelector.Value = iBufferCountManual.Symbolic;

                // set the value
                IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount");
                if (streamNode == null || !streamNode.IsWritable)
                {
                    return(false);
                }

                streamNode.Value = count;
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        //public float GetPropertyValue(PropertyType property, bool absolute, bool valueB = false)
        //{
        //    CameraProperty camProp = camera.GetProperty(property);

        //    return (absolute ? camProp.absValue : (!valueB ? camProp.valueA : camProp.valueB));
        //}
        public string GetPropertyValue(string property, bool valueB = false)
        {
            if (property == "Shutter")
            {
                IFloat node = nodeMap.GetNode <IFloat>("ExposureTime");
                return(node.Value.ToString());
            }
            else if (property == "DeviceTemperature")
            {
                IFloat node = nodeMap.GetNode <IFloat>("DeviceTemperature");
                return(node.Value.ToString());
            }
            else if (property == "WidthMax")
            {
                IInteger node = nodeMap.GetNode <IInteger>("WidthMax");
                return(node.Value.ToString());
            }
            else if (property == "HeightMax")
            {
                IInteger node = nodeMap.GetNode <IInteger>("HeightMax");
                return(node.Value.ToString());
            }
            else
            {
                IEnum node = nodeMap.GetNode <IEnum>(property);
                return(node.Value.ToString());
            }
        }
Exemplo n.º 3
0
        private bool SetImageOffset(int offsetx, int offsety)
        {
            bool rect = false;

            try
            {
                //
                // Apply minimum to offset X
                //
                // *** NOTES ***
                // Numeric nodes have both a minimum and maximum. A minimum is
                // retrieved with the method GetMin(). Sometimes it can be
                // important to check minimums to ensure that your desired value
                // is within range.
                //
                IInteger iOffsetX = m_NodeMap.GetNode <IInteger>("OffsetX");
                if (iOffsetX != null && iOffsetX.IsWritable)
                {
                    iOffsetX.Value = offsetx;
                    LogHelper.AppLoger.DebugFormat("Offset X set to {0}...", offsetx);
                }
                else
                {
                    LogHelper.AppLoger.Error("Offset X not available...");
                    return(rect);
                }

                //
                // Apply minimum to offset Y
                //
                // *** NOTES ***
                // It is often desirable to check the increment as well. The
                // increment is a number of which a desired value must be a
                // multiple. Certain nodes, such as those corresponding to
                // offsets X and Y, have an increment of 1, which basically
                // means that any value within range is appropriate. The
                // increment is retrieved with the method GetInc().
                //
                IInteger iOffsetY = m_NodeMap.GetNode <IInteger>("OffsetY");
                if (iOffsetY != null && iOffsetY.IsWritable)
                {
                    iOffsetY.Value = offsety;
                    LogHelper.AppLoger.DebugFormat("Offset Y set to {0}...", offsety);
                }
                else
                {
                    LogHelper.AppLoger.Error("Offset Y not available...");
                    return(rect);
                }

                rect = true;
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(rect);
        }
Exemplo n.º 4
0
        private bool SetImageWidth(int width, int height)
        {
            bool rect = false;

            try
            {
                //
                // Set maximum width
                //
                // *** NOTES ***
                // Other nodes, such as those corresponding to image width and
                // height, might have an increment other than 1. In these cases,
                // it can be important to check that the desired value is a
                // multiple of the increment. However, as these values are being
                // set to the maximum, there is no reason to check against the
                // increment.
                //
                IInteger iWidth = m_NodeMap.GetNode <IInteger>("Width");
                if (iWidth != null && iWidth.IsWritable)
                {
                    iWidth.Value = width;
                    LogHelper.AppLoger.DebugFormat("Width set to {0}...", width);
                }
                else
                {
                    LogHelper.AppLoger.Error("Width not available...");
                    return(rect);
                }

                //
                // Set maximum height
                //
                // *** NOTES ***
                // A maximum is retrieved with the method GetMax(). A node's
                // minimum and maximum should always be a multiple of its
                // increment.
                //
                IInteger iHeight = m_NodeMap.GetNode <IInteger>("Height");
                if (iHeight != null && iHeight.IsWritable)
                {
                    iHeight.Value = height;
                    LogHelper.AppLoger.DebugFormat("Height set to {0}......", height);
                }
                else
                {
                    LogHelper.AppLoger.Error("Height not available...");
                    return(rect);
                }
                rect = true;
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(rect);
        }
Exemplo n.º 5
0
        public override bool SetStreamBufferCount(int bufCount)
        {
            bool ret = false;

            try
            {
                INodeMap sNodeMap   = m_Camera.GetTLStreamNodeMap();
                IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount");
                streamNode.Value = bufCount;
                ret = true;
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(ret);
        }
Exemplo n.º 6
0
        public override bool SetRoi(int offsetx, int offsety, int width, int height)
        {
            bool     rect   = false;
            IInteger iWidth = m_NodeMap.GetNode <IInteger>("Width");

            if (iWidth.Max > width)
            {
                rect  = SetImageWidth(width, height);
                rect &= SetImageOffset(offsetx, offsety);
            }
            else
            {
                rect  = SetImageOffset(offsetx, offsety);
                rect &= SetImageWidth(width, height);
            }
            return(rect);
        }
Exemplo n.º 7
0
        public ulong GetImageTimeStamp()
        {
            try
            {
                ICommand iTimestampLatch = nodeMap.GetNode <ICommand>("TimestampLatch");
                iTimestampLatch.Execute();
                IInteger iTimestamp = nodeMap.GetNode <IInteger>("TimestampLatchValue");
                return(iTimestamp.Value < 0 ? 0 : (ulong)iTimestamp.Value);
            }
            catch (SpinnakerException ex)
            {
                Debug.WriteLine("Error: {0}", ex.Message);
            }
            finally
            {
            }

            return(0);
        }
Exemplo n.º 8
0
        private void PrintIntegerNode(INode node, int level, StreamWriter sw)
        {
            try
            {
                // Cast node as integer node
                IInteger iIntegerNode = (IInteger)node;

                // Retrieve display name
                string displayName = iIntegerNode.DisplayName;

                // Retrieve integer node value
                long value = iIntegerNode.Value;

                sw.WriteLine(Indent(level) + displayName + ":  " + value.ToString() + "  (Integer Node)");
            }
            catch (SpinnakerException ex)
            {
                Console.WriteLine("Error:   " + ex.ToString());
            }
        }
Exemplo n.º 9
0
        public bool SetStreamBufferCount(long count)
        {
            try
            {
                //StreamDefaultBufferCount is the number of images to buffer on PC
                //default is 10
                INodeMap sNodeMap   = managedCamera.GetTLStreamNodeMap();
                IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount");
                if (streamNode == null || !streamNode.IsWritable)
                {
                    return(false);
                }

                streamNode.Value = count;
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 10
0
 public RemoveText(IText source, IInteger lastIndexOf, IInteger lengthOf)
 {
     _source      = source;
     _lastIndexOf = lastIndexOf;
     _lengthOf    = lengthOf;
 }
Exemplo n.º 11
0
 public SampleService(IInteger integer)
 => Integer = integer;
Exemplo n.º 12
0
        bool configTrigger(TriggerMode triggerMode, TriggerType triggerType, uint count = 1)
        {
            bool result = false;

            if (triggerMode == TriggerMode.Off)
            {
                IEnum triMode = nodeMap.GetNode <IEnum>("TriggerMode");
                if (triMode == null || !triMode.IsWritable)
                {
                    Console.WriteLine("configTrigger: Unable to disable trigger mode (enum retrieval). Aborting...");
                    return(false);
                }

                IEnumEntry iTriggerModeOff = triMode.GetEntryByName("Off");
                if (iTriggerModeOff == null || !iTriggerModeOff.IsReadable)
                {
                    Console.WriteLine("configTrigger: Unable to disable trigger mode (entry retrieval). Aborting...");
                    return(false);
                }
                triMode.Value = iTriggerModeOff.Value;
                result        = true;
            }
            else if (triggerMode == TriggerMode.On)
            {
                IEnum triMode = nodeMap.GetNode <IEnum>("TriggerMode");
                if (triMode == null || !triMode.IsWritable)
                {
                    Console.WriteLine("configTrigger: Unable to enable trigger mode (enum retrieval). Aborting...");
                    return(false);
                }

                IEnumEntry iTriggerModeOn = triMode.GetEntryByName("On");
                if (iTriggerModeOn == null || !iTriggerModeOn.IsReadable)
                {
                    Console.WriteLine("configTrigger: Unable to enable trigger mode (entry retrieval). Aborting...");
                    return(false);
                }
                triMode.Value = iTriggerModeOn.Value;

                IEnum triggerSource = nodeMap.GetNode <IEnum>("TriggerSource");
                if (triggerType == TriggerType.Software)
                {
                    // Set trigger mode to software
                    IEnumEntry iTriggerSourceSoftware = triggerSource.GetEntryByName("Software");
                    if (iTriggerSourceSoftware == null || !iTriggerSourceSoftware.IsReadable)
                    {
                        Console.WriteLine("configTrigger: Unable to set software trigger mode (entry retrieval). Aborting...");
                        return(false);
                    }
                    triggerSource.Value = iTriggerSourceSoftware.Value;

                    Console.WriteLine("configTrigger: Trigger source set to software...");
                }
                else if (triggerType == TriggerType.Hardware)
                {
                    // Set trigger mode to hardware ('Line0')
                    IEnumEntry iTriggerSourceHardware = triggerSource.GetEntryByName("Line0");
                    if (iTriggerSourceHardware == null || !iTriggerSourceHardware.IsReadable)
                    {
                        Console.WriteLine("configTrigger: Unable to set hardware trigger mode (entry retrieval). Aborting...");
                        return(false);
                    }
                    triggerSource.Value = iTriggerSourceHardware.Value;

                    Console.WriteLine("configTrigger: Trigger source set to hardware...");
                }
                else
                {
                    Console.WriteLine("configTrigger: Trigger source Unknown");
                    return(false);
                }

                {
                    IEnum      triggerSelector  = nodeMap.GetNode <IEnum>("TriggerSelector");
                    IEnumEntry iTriggerSelector = triggerSelector.GetEntryByName("FrameStart");
                    if (iTriggerSelector == null || !iTriggerSelector.IsReadable)
                    {
                        Console.WriteLine("configTrigger: Unable to set trigger selector (entry retrieval). Aborting...");
                        return(false);
                    }
                    triggerSelector.Value = iTriggerSelector.Value;
                }
                {
                    IEnum triggerActivation = nodeMap.GetNode <IEnum>("TriggerActivation");
                    triggerActivation.Value = "RisingEdge";
                    IEnumEntry iTriggerActivation = triggerActivation.GetEntryByName("RisingEdge");
                    if (iTriggerActivation == null || !iTriggerActivation.IsReadable)
                    {
                        Console.WriteLine("configTrigger: Unable to set trigger activation (entry retrieval). Aborting...");
                        return(false);
                    }
                    triggerActivation.Value = iTriggerActivation.Value;
                }
                // multi frame
                if (count >= 1)
                {
                    IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode");

                    IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("MultiFrame");

                    iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic;

                    IInteger acquCount = nodeMap.GetNode <IInteger>("AcquisitionFrameCount");
                    acquCount.Value = count;

                    //single frame acquisition mode set to triggered
                    {
                        IEnum iSingleFrameAcquisitionMode = nodeMap.GetNode <IEnum>("SingleFrameAcquisitionMode");

                        IEnumEntry iSingleAcquisitionMode = iSingleFrameAcquisitionMode.GetEntryByName("Triggered");

                        iSingleFrameAcquisitionMode.Value = iSingleAcquisitionMode.Symbolic;
                    }
                }
                else
                {
                    IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode");

                    IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous");

                    iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic;
                }


                result = true;
            }
            return(result);
        }
Exemplo n.º 13
0
 public static IMonoid <T> GetMinMonoid(IInteger <T> integer, T upperBound)
 => new IntegerMinMonoid <T>(integer, upperBound);
Exemplo n.º 14
0
 public IntegerSumGroup(IInteger <T> integer) : base(integer)
 {
 }
Exemplo n.º 15
0
 public static IGroup <T> GetSumGroup(IInteger <T> integer)
 => new IntegerSumGroup <T>(integer);
Exemplo n.º 16
0
 public IntegerMaxMonoid(IInteger <T> integer, T lowerBound)
 {
     this.integer = integer;
     this.Mempty  = lowerBound;
 }
Exemplo n.º 17
0
 public IntegerMinMonoid(IInteger <T> integer, T upperBound)
 {
     this.integer = integer;
     this.Mempty  = upperBound;
 }
Exemplo n.º 18
0
 public IntegerSumMonoid(IInteger <T> integer)
 {
     this.integer = integer;
 }
Exemplo n.º 19
0
 public static IMonoid <T> GetMaxMonoid(IInteger <T> integer, T lowerBound)
 => new IntegerMaxMonoid <T>(integer, lowerBound);
Exemplo n.º 20
0
 public MyWrapper()
 {
     _Instance = new MyClass();
     Integer   = new _Integer(this);
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            try
            {
                using (CStApiAutoInit api = new CStApiAutoInit())

                    // =============================================================================================
                    // Note: Creating system will  generate a broadcast device scan.
                    using (CStSystem system = new CStSystem(eStSystemVendor.Sentech, eStInterfaceType.GigEVision))
                    {
                        // Input target IP address for scanning.
                        Console.Write("Please input camera IP address for unicast camera scanning: ");
                        string value = Console.ReadLine();

                        IPAddress ipaddr;

                        // Try parse the input address, if failed exit program.
                        if (!IPAddress.TryParse(value.Trim(), out ipaddr))
                        {
                            Console.WriteLine("IP address is not valid.");
                            Console.WriteLine("\r\nPress Enter to exit.");
                            Console.ReadLine();
                            Environment.Exit(0);
                        }

                        // Convert the IP address string to a 32-bit number.
                        byte[] bytes             = ipaddr.GetAddressBytes();
                        uint   uiTgtDevIPAddress = (uint)(IPAddress.NetworkToHostOrder(BitConverter.ToUInt32(bytes, 0)) >> 32);

                        // Acquire interface counts
                        uint uiCntInterface = system.InterfaceCount;

                        for (uint i = 0; i < uiCntInterface; i++)
                        {
                            IStInterface pInterface = system.GetIStInterface(i);
                            // Set Discovery Command Distination IP Address to enable the unicast camera scanning.
                            // *This is 255.255.255.255 in default for boradcast device scanning.
                            INodeMap nodeMapInterface        = pInterface.GetIStPort().GetINodeMap();
                            IInteger intDistiantionIPAddress = nodeMapInterface.GetNode <IInteger>("GevDeviceDiscoveryCommandDestinationIPAddress");
                            intDistiantionIPAddress.SetValue(uiTgtDevIPAddress, false);

                            // After setting distination IP, call update for actual scanning process.
                            // Unicast scanning package will be sent via this function.
                            pInterface.UpdateDeviceList();
                        }
                        using (CStDevice device = system.CreateFirstStDevice())
                        {
                            // Print out information of device if found and connected.
                            // Otherwise it will goes into exception handling.
                            Console.WriteLine("Device=" + device.GetIStDeviceInfo().DisplayName);
                            Console.WriteLine("Device found and connected.");
                        }
                    }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An exception occurred. \r\n" + e.Message);
            }
            finally
            {
                Console.WriteLine("\r\nPress Enter to exit.");
                Console.ReadLine();
            }
        }
Exemplo n.º 22
0
 public VerboseDiff(IInteger diff)
 {
     _diff = diff;
 }
Exemplo n.º 23
0
        public bool SetSingleSequence(int sequenceNumber, int finalSequenceNumber, double gain, double exposureTimeToSet)
        {
            bool result = false;

            try
            {
                //
                // Select the current sequence
                //
                // *** NOTES ***
                // Select the index of the sequence to be set.
                //
                // *** LATER ***
                // The next state - i.e. the state to be linked to -
                // also needs to be set before saving the current state.
                //
                IInteger iSequencerSetSelector = nodeMap.GetNode <IInteger>("SequencerSetSelector");
                if (iSequencerSetSelector == null || !iSequencerSetSelector.IsWritable)
                {
                    throw new Exception("Unable to select state. Aborting...\n");
                }

                iSequencerSetSelector.Value = sequenceNumber;


                //
                // Set desired settings for the current state
                //

                // Set exposure time; exposure time recorded in microseconds
                IFloat iExposureTime = nodeMap.GetNode <IFloat>("ExposureTime");
                if (iExposureTime == null || !iExposureTime.IsWritable)
                {
                    throw new Exception("Unable to set exposure time. Aborting...\n");
                }

                iExposureTime.Value = exposureTimeToSet;

                // TODO: set gain
                // Set gain; gain recorded in decibels
                IFloat iGain = nodeMap.GetNode <IFloat>("Gain");
                if (iGain == null || !iGain.IsWritable)
                {
                    throw new Exception("Unable to set gain. Aborting...\n");
                }

                iGain.Value = gain;

                //
                // Set the trigger type for the current state
                //
                // *** NOTES ***
                // It is a requirement of every state to have its trigger
                // source set. The trigger source refers to the moment when the
                // sequencer changes from one state to the next.
                //
                IEnum iSequencerTriggerSource = nodeMap.GetNode <IEnum>("SequencerTriggerSource");
                if (iSequencerTriggerSource == null || !iSequencerTriggerSource.IsWritable)
                {
                    throw new Exception("Unable to set trigger source (enum retrieval). Aborting...\n");
                }

                IEnumEntry iSequencerTriggerSourceFrameStart = iSequencerTriggerSource.GetEntryByName("FrameStart");
                if (iSequencerTriggerSourceFrameStart == null || iSequencerTriggerSourceFrameStart.IsWritable)
                {
                    throw new Exception("Unable to set trigger source (entry retrieval). Aborting...\n");
                }

                iSequencerTriggerSource.Value = iSequencerTriggerSourceFrameStart.Value;


                //
                // Set the next state in the sequence
                //


                IInteger iSequencerSetNext = nodeMap.GetNode <IInteger>("SequencerSetNext");
                if (iSequencerSetNext == null || !iSequencerSetNext.IsWritable)
                {
                    throw new Exception("Unable to set next state. Aborting...\n");
                }

                if (sequenceNumber == finalSequenceNumber)
                {
                    iSequencerSetNext.Value = 0;
                }
                else
                {
                    iSequencerSetNext.Value = sequenceNumber + 1;
                }


                //
                // Save current state
                //
                // *** NOTES ***
                // Once all appropriate settings have been configured, make
                // sure to save the state to the sequence. Notice that these
                // settings will be lost when the camera is power-cycled.
                //
                ICommand iSequencerSetSave = nodeMap.GetNode <ICommand>("SequencerSetSave");
                if (iSequencerSetSave == null || !iSequencerSetSave.IsWritable)
                {
                    throw new Exception("Unable to save state. Aborting...\n");
                }

                iSequencerSetSave.Execute();

                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
        static void Main(string[] args)
        {
            try
            {
                using (CStApiAutoInit api = new CStApiAutoInit())

                    using (CStSystem system = new CStSystem(eStSystemVendor.Sentech))

                        using (CStDevice device = system.CreateFirstStDevice())

                            using (CStImageDisplayWnd wnd = new CStImageDisplayWnd())

                                using (CStDataStream dataStream = device.CreateStDataStream(0))
                                {
                                    Console.WriteLine("Device=" + device.GetIStDeviceInfo().DisplayName);

                                    // ==============================================================================================================
                                    // Demostration of Setting Auto Gain Control with dedicated range.

                                    // Create NodeMap pointer for accessing parameters
                                    INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap();

                                    // Switch on Gain Auto(IEnumeration).
                                    IEnum enumGainAuto = nodeMap.GetNode <IEnum>("GainAuto");
                                    enumGainAuto.FromString("Continuous");

                                    // Get Node for Auto Luminance Target(IInteger)
                                    IInteger intAutoLuminTgt = nodeMap.GetNode <IInteger>("AutoLuminanceTarget");
                                    // Set Auto Luminance Target to 128
                                    intAutoLuminTgt.Value = 128;

                                    // For setting analog gain, gain selector need to be set to AnalogAll to access analog gain.
                                    IEnum enumGainSelector = nodeMap.GetNode <IEnum>("GainSelector");
                                    enumGainSelector.FromString("AnalogAll");

                                    // Get Node for GainAutoLimitMin(IFloat).
                                    IFloat floatGainAutoMin = nodeMap.GetNode <IFloat>("GainAutoLimitMin");
                                    // Set Auto Gain Min to 0 dB (0).
                                    floatGainAutoMin.Value = 20;

                                    // Get Node for GainAutoLimitMax(IFloat).
                                    IFloat floatGainAutoMax = nodeMap.GetNode <IFloat>("GainAutoLimitMax");
                                    // Set Auto Gain Max to 10 dB (100).
                                    floatGainAutoMax.Value = 100;

                                    // ==============================================================================================================

                                    dataStream.StartAcquisition(nCountOfImagesToGrab);

                                    device.AcquisitionStart();

                                    while (dataStream.IsGrabbing)
                                    {
                                        using (CStStreamBuffer streamBuffer = dataStream.RetrieveBuffer(5000))
                                        {
                                            if (streamBuffer.GetIStStreamBufferInfo().IsImagePresent)
                                            {
                                                IStImage stImage = streamBuffer.GetIStImage();
                                                string   strText = device.GetIStDeviceInfo().DisplayName + " ";
                                                strText += stImage.ImageWidth + " x " + stImage.ImageHeight + " ";
                                                strText += string.Format("{0:F2}[fps]", dataStream.CurrentFPS);
                                                wnd.SetUserStatusBarText(strText);

                                                if (!wnd.IsVisible)
                                                {
                                                    wnd.SetPosition(0, 0, (int)stImage.ImageWidth, (int)stImage.ImageHeight);

                                                    wnd.Show(eStWindowMode.ModalessOnNewThread);
                                                }

                                                wnd.RegisterIStImage(stImage);
                                            }
                                            else
                                            {
                                                Console.WriteLine("Image data does not exist.");
                                            }
                                        }
                                    }

                                    device.AcquisitionStop();

                                    dataStream.StopAcquisition();
                                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An exception occurred. \r\n" + e.Message);
            }
            finally
            {
                Console.WriteLine("\r\nPress Enter to exit.");
                Console.ReadLine();
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            try
            {
                using (CStApiAutoInit api = new CStApiAutoInit())

                    using (CStSystem system = new CStSystem(eStSystemVendor.Sentech))

                        using (CStDevice device = system.CreateFirstStDevice())

                            using (CStImageDisplayWnd wnd = new CStImageDisplayWnd())

                                using (CStDataStream dataStream = device.CreateStDataStream(0))
                                {
                                    Console.WriteLine("Device=" + device.GetIStDeviceInfo().DisplayName);

                                    // ==============================================================================================================
                                    // Demostration of setting ROI to 640 x 480 with offset (100, 200).

                                    // Create NodeMap pointer for accessing parameters
                                    INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap();

                                    // Get Node for Width
                                    IInteger intWidth = nodeMap.GetNode <IInteger>("Width");
                                    // Set Width to 640
                                    intWidth.Value = 640;

                                    // Get Node for Height
                                    IInteger intHeight = nodeMap.GetNode <IInteger>("Height");
                                    // Set Height to 480
                                    intHeight.Value = 480;

                                    // Get Node for Offset X
                                    IInteger intOffsetX = nodeMap.GetNode <IInteger>("OffsetX");
                                    // Set Offset X to 100
                                    intOffsetX.Value = 100;

                                    // Get Node for Offset Y
                                    IInteger intOffsetY = nodeMap.GetNode <IInteger>("OffsetY");
                                    // Set Offset Y to 200
                                    intOffsetY.Value = 200;

                                    // ==============================================================================================================

                                    dataStream.StartAcquisition(nCountOfImagesToGrab);

                                    device.AcquisitionStart();

                                    while (dataStream.IsGrabbing)
                                    {
                                        using (CStStreamBuffer streamBuffer = dataStream.RetrieveBuffer(5000))
                                        {
                                            if (streamBuffer.GetIStStreamBufferInfo().IsImagePresent)
                                            {
                                                IStImage stImage = streamBuffer.GetIStImage();
                                                string   strText = device.GetIStDeviceInfo().DisplayName + " ";
                                                strText += stImage.ImageWidth + " x " + stImage.ImageHeight + " ";
                                                strText += string.Format("{0:F2}[fps]", dataStream.CurrentFPS);
                                                wnd.SetUserStatusBarText(strText);

                                                if (!wnd.IsVisible)
                                                {
                                                    wnd.SetPosition(0, 0, (int)stImage.ImageWidth, (int)stImage.ImageHeight);

                                                    wnd.Show(eStWindowMode.ModalessOnNewThread);
                                                }

                                                wnd.RegisterIStImage(stImage);
                                            }
                                            else
                                            {
                                                Console.WriteLine("Image data does not exist.");
                                            }
                                        }
                                    }

                                    device.AcquisitionStop();

                                    dataStream.StopAcquisition();
                                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An exception occurred. \r\n" + e.Message);
            }
            finally
            {
                Console.WriteLine("\r\nPress Enter to exit.");
                Console.ReadLine();
            }
        }
Exemplo n.º 26
0
        //void SetCameraVideoModeAndFrameRate(VideoMode newVideoMode, FrameRate newFrameRate)
        //{
        //    bool restartCapture = true;
        //    try
        //    {
        //        camera.StopCapture();
        //    }
        //    catch (FC2Exception ex)
        //    {
        //        if (ex.Type != ErrorType.IsochNotStarted)
        //        {
        //            throw;
        //        }
        //        else
        //            restartCapture = false;
        //    }

        //    try
        //    {
        //        camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate);
        //    }
        //    catch (FC2Exception /*ex*/)
        //    {
        //        throw;
        //    }

        //    if (restartCapture)
        //    {
        //        camera.StartCapture();
        //    }
        //}


        //void SetAbsolutePropertyValue(PropertyType property, float newValue)
        //{
        //    CameraProperty camProp = camera.GetProperty(property);
        //    CameraPropertyInfo propInfo = camera.GetPropertyInfo(property);

        //    if (!camProp.autoManualMode && propInfo.manualSupported && propInfo.absValSupported)
        //    {
        //        float difference = camProp.absValue - newValue;
        //        if (difference != 0)
        //        {
        //            // The brightness abs register sometimes starts drifting
        //            // due to a rounding error between the camera and the
        //            // actual value being held by the adjustment. To prevent
        //            // this, only apply the change to the camera if the
        //            // difference is greater than a specified amount.

        //            // Check if the difference is greater than 0.005f.
        //            if (property != PropertyType.Brightness ||
        //                Math.Abs(difference) > 0.005f)
        //            {
        //                camProp.absControl = true;
        //                camProp.absValue = newValue;
        //                camera.SetProperty(camProp);
        //            }
        //        }
        //    }
        //    else
        //    {
        //        throw new ApplicationException("Trying to set a property that cannot be adjusted");
        //    }
        //}
        public void SetAbsolutePropertyValue(string property, string newValue)
        {
            try
            {
                if (property == "Hue")
                {
                    IFloat hue = nodeMap.GetNode <IFloat>("Hue");
                    hue.Value = Convert.ToDouble(newValue);
                }
                else if (property == "Gamma")
                {
                    IFloat gamma = nodeMap.GetNode <IFloat>("Gamma");
                    gamma.Value = Convert.ToDouble(newValue);
                }
                else if (property == "Width")
                {
                    IInteger width = nodeMap.GetNode <IInteger>("Width");
                    width.Value = Convert.ToInt32(newValue);
                }
                else if (property == "Height")
                {
                    IInteger height = nodeMap.GetNode <IInteger>("Height");
                    height.Value = Convert.ToInt32(newValue);
                }
                else if (property == "Gain")
                {
                    IEnum gainAuto = nodeMap.GetNode <IEnum>("GainAuto");
                    gainAuto.Value = "Off";

                    IFloat gainValue = nodeMap.GetNode <IFloat>("Gain");
                    gainValue.Value = Convert.ToDouble(newValue);
                }
                else if (property == "Saturation")
                {
                    IEnum saturationAuto = nodeMap.GetNode <IEnum>("SaturationAuto");
                    saturationAuto.Value = "Off";

                    IFloat saturationValue = nodeMap.GetNode <IFloat>("Saturation");
                    saturationValue.Value = Convert.ToDouble(newValue);
                }
                else if (property == "Binning")
                {
                    IInteger binningValue = nodeMap.GetNode <IInteger>("BinningVertical");
                    binningValue.Value = Convert.ToInt32(newValue);
                }
                else if (property == "FrameRate")
                {
                    IEnum frameRateAuto = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto");
                    frameRateAuto.Value = "Off";

                    IFloat frameRateValue = nodeMap.GetNode <IFloat>("AcquisitionFrameRate");
                    frameRateValue.Value = Convert.ToDouble(newValue);
                }
                else if (property == "PixelFormat")
                {
                    IEnum      pixelFormat     = nodeMap.GetNode <IEnum>("PixelFormat");
                    IEnumEntry pixelFormatItem = pixelFormat.GetEntryByName(newValue);

                    if (pixelFormatItem?.IsReadable == true)
                    {
                        pixelFormat.Value = pixelFormatItem.Symbolic;
                    }
                }
                else if (property == "VideoMode")
                {
                    IEnum acquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode");
                    if (acquisitionMode?.IsWritable == true)
                    {
                        IEnumEntry acquisitionModeItem = acquisitionMode.GetEntryByName(newValue);
                        if (acquisitionModeItem?.IsReadable == true)
                        {
                            acquisitionMode.Value = acquisitionModeItem.Symbolic;
                        }
                        else
                        {
                            Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                    }
                }
                else if (property == "ShutterMode")
                {
                    IEnum exposureMode = nodeMap.GetNode <IEnum>("ExposureMode");
                    if (exposureMode?.IsWritable == true)
                    {
                        IEnumEntry exposureModeItem = exposureMode.GetEntryByName(newValue);
                        if (exposureModeItem?.IsReadable == true)
                        {
                            exposureMode.Value = exposureModeItem.Symbolic;
                        }
                        else
                        {
                            Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                    }
                }
                else if (property == "StreamBufferMode")
                {
                    INodeMap nodeMapStream = camera.GetTLStreamNodeMap();
                    IEnum    bufferMode    = nodeMapStream.GetNode <IEnum>("StreamBufferHandlingMode");
                    if (bufferMode?.IsWritable == true)
                    {
                        IEnumEntry bufferModeItem = bufferMode.GetEntryByName(newValue);
                        if (bufferModeItem?.IsReadable == true)
                        {
                            bufferMode.Value = bufferModeItem.Symbolic;
                        }
                        else
                        {
                            Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property);
                    }
                }
                else if (property == "ExposureCompensation")
                {
                    IFloat expoCompensation = nodeMap.GetNode <IFloat>("pgrExposureCompensation");
                    expoCompensation.Value = Convert.ToDouble(newValue);
                }
                else
                {
                    Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " not implemented.");
                }
            }
            catch (SpinnakerException e)
            {
                Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " exceptoin: " + e.Message);
            }
        }
Exemplo n.º 27
0
        private void SetSetting(Util.SettingInfo item)
        {
            string settingName = item._SettingName.ToString();

            Util.NodeType nodeType = item._NodeType;
            Util.NodeMap  nodeMap  = item._NodeMap;
            string        value    = item._Value;

            if (nodeType == Util.NodeType.String)
            {
                IString iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <IString>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <IString>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <IString>(settingName);
                }

                string currentValue = string.Copy(iNode.Value.ToString());
                iNode.Value = value;
                string newValue = string.Copy(iNode.Value.ToString());
                printSettingChangeInfo(currentValue, newValue);
            }

            else if (nodeType == Util.NodeType.Integer)
            {
                IInteger iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <IInteger>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <IInteger>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <IInteger>(settingName);
                }

                string currentValue = string.Copy(iNode.Value.ToString());
                iNode.Value = int.Parse(value);
                string newValue = string.Copy(iNode.Value.ToString());
                printSettingChangeInfo(currentValue, newValue);
            }

            else if (nodeType == Util.NodeType.Float)
            {
                IFloat iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <IFloat>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <IFloat>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <IFloat>(settingName);
                }

                string currentValue = string.Copy(iNode.Value.ToString());
                iNode.Value = float.Parse(value, CultureInfo.InvariantCulture.NumberFormat);
                string newValue = string.Copy(iNode.Value.ToString());
                printSettingChangeInfo(currentValue, newValue);
            }

            else if (nodeType == Util.NodeType.Bool)
            {
                IBool iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <IBool>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <IBool>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <IBool>(settingName);
                }

                string currentValue = string.Copy(iNode.Value.ToString());
                iNode.Value = bool.Parse(value);
                string newValue = string.Copy(iNode.Value.ToString());
                printSettingChangeInfo(currentValue, newValue);
            }

            else if (nodeType == Util.NodeType.Command)
            {
                ICommand iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <ICommand>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <ICommand>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <ICommand>(settingName);
                }

                Console.WriteLine("Command to be executed: {0}: ", settingName);
                iNode.Execute();
            }

            else if (nodeType == Util.NodeType.Enumeration)
            {
                IEnum iNode = null;
                if (nodeMap == Util.NodeMap.GenICam)
                {
                    iNode = cam.nodeMap.GetNode <IEnum>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLDevice)
                {
                    iNode = cam.nodeMapTLDevice.GetNode <IEnum>(settingName);
                }
                else if (nodeMap == Util.NodeMap.TLStream)
                {
                    iNode = cam.nodeMapTLStream.GetNode <IEnum>(settingName);
                }

                string     currentValue = string.Copy(iNode.Value);
                IEnumEntry iEntry       = iNode.GetEntryByName(value);
                iNode.Value = iEntry.Symbolic;
                string newValue = string.Copy(iEntry.Symbolic);
                printSettingChangeInfo(currentValue, newValue);
            }



            void printSettingChangeInfo(string _currentValue, string _newValue, bool suppress = true)
            {
                if (!suppress)
                {
                    Console.WriteLine("{0} ({1}) changed from {2} to {3}", settingName, nodeType, _currentValue, _newValue);
                }
            }
        }
Exemplo n.º 28
0
 public static IMonoid <T> GetSumMonoid(IInteger <T> integer)
 => new IntegerSumMonoid <T>(integer);
Exemplo n.º 29
0
 public InsertText(IText source, IInteger index, IText target)
 {
     _source = source;
     _index  = index;
     _target = target;
 }
Exemplo n.º 30
0
Plus(
    this IInteger   dis,
    IInteger        that
)
{
    NonNull.CheckParameter( dis, "dis" );
    NonNull.CheckParameter( that, "that" );
    return ((IReal)dis).Plus( that ).Truncate();
}
Exemplo n.º 31
0
RemainderWhenDividedBy(
    this IInteger   dis,
    IInteger        that
)
{
    // TODO
    throw new NotImplementedException();
}
 override public void createSlices()
 {
     base.createSlices();
     this.Vec_size = (IInteger)BackEnd.createSlice(this, UID, "size", "integer", new Type[] {});
     this.Data     = (T)BackEnd.createSlice(this, UID, "element", "double", new Type[] {});
 }