Exemple #1
0
        public void StartVideo(bool isContinue = true)
        {
            try
            {
                if (managedCamera != null && _videoMode == false)
                {
                    if (isContinue)
                    {
                        // Set acquisition mode to continuous
                        IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode");

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

                        iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic;
                    }
                    // Configure image events
                    imageEventListener = new ImageEventListener(imageQueue);
                    managedCamera.RegisterEvent(imageEventListener);

                    // Begin acquiring images
                    managedCamera.BeginAcquisition();

                    _videoMode = true;
                }
            }
            catch (SpinnakerException ex)
            {
                Debug.WriteLine("Error: {0}", ex.Message);
            }
        }
Exemple #2
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);
        }
Exemple #3
0
        private bool AppendEnumValue([NotNull] ConstantValue constantValue, [NotNull] IEnum enumType)
        {
            IList <IField> fields = CSharpEnumUtil.CalculateEnumMembers(constantValue, enumType);

            if (fields.Count == 0)
            {
                return(false);
            }

            string typeHighlighterId  = _useReSharperColors ? HighlightingAttributeIds.TYPE_ENUM_ATTRIBUTE : VsHighlightingAttributeIds.Enums;
            string valueHighlighterId = _useReSharperColors ? HighlightingAttributeIds.CONSTANT_IDENTIFIER_ATTRIBUTE : VsHighlightingAttributeIds.Identifier;

            var  orderedFields = fields.OrderBy(f => f.ShortName);
            bool addSeparator  = false;

            foreach (IField orderedField in orderedFields)
            {
                if (addSeparator)
                {
                    AppendText(" | ", VsHighlightingAttributeIds.Operator);
                }

                AppendText(enumType.ShortName, typeHighlighterId);
                AppendText(".", VsHighlightingAttributeIds.Operator);
                AppendText(orderedField.ShortName, valueHighlighterId);

                addSeparator = true;
            }
            return(true);
        }
Exemple #4
0
        public static IEnumVal AddValue(this IEnum enm, string name)
        {
            var enmVal = Noast.Create <IEnumVal>(name);

            enm.Values.Add(enmVal);
            return(enmVal);
        }
Exemple #5
0
        /// <summary>
        /// OldestFirst = 0,
        /// OldestFirstOverwrite = 1,
        /// NewestFirst = 2,
        /// NewestFirstOverwrite = 3,
        /// NUMSTREAMBUFFERHANDLINGMODE = 4
        /// </summary>
        /// <param name="strMode"></param>
        public override bool SetStreamBufferHandlingMode(string strMode)
        {
            bool ret = false;

            try
            {
                INodeMap sNodeMap = m_Camera.GetTLStreamNodeMap();
                IEnum    iStreamBufferHandlingMode = sNodeMap.GetNode <IEnum>("StreamBufferHandlingMode");
                if (iStreamBufferHandlingMode == null || !iStreamBufferHandlingMode.IsWritable)
                {
                    return(false);
                }
                IEnumEntry iMode = iStreamBufferHandlingMode.GetEntryByName(strMode);
                if (iMode == null || !iMode.IsReadable)
                {
                    return(false);
                }
                iStreamBufferHandlingMode.Value = iMode.Symbolic;

                ret = true;
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(ret);
        }
Exemple #6
0
        /// <summary>
        /// Reads the specified scanline.
        /// </summary>
        /// <param name="scanline">The scanline.</param>
        /// <param name="pixels">The pixels, where the colors should be stored in RGBA format.</param>
        /// <param name="header">The header, which contains information about the png file, like
        /// the width of the image and the height.</param>
        public void ReadScanline(byte[] scanline, byte[] pixels, PngHeader header)
        {
            int offset = 0;

            //byte[] newScanline = scanline.ToArrayByBitsLength(header.BitDepth);
            byte[] newScanline = IEnum.ToArrayByBitsLength(scanline, header.BitDepth);
            if (_useAlpha)
            {
                for (int x = 0; x < header.Width / 2; x++)
                {
                    offset = (_row * header.Width + x) * 4;

                    pixels[offset + 0] = newScanline[x * 2];
                    pixels[offset + 1] = newScanline[x * 2];
                    pixels[offset + 2] = newScanline[x * 2];
                    pixels[offset + 3] = newScanline[x * 2 + 1];
                }
            }
            else
            {
                for (int x = 0; x < header.Width; x++)
                {
                    offset = (_row * header.Width + x) * 4;

                    pixels[offset + 0] = newScanline[x];
                    pixels[offset + 1] = newScanline[x];
                    pixels[offset + 2] = newScanline[x];
                    pixels[offset + 3] = (byte)255;
                }
            }

            _row++;
        }
        private void AddEnumMessages(IEnum enumDefinition)
        {
            if (enumDefinition.Name == null)
            {
                // The enum name is missing: `enum {}`.
                this.AddError(
                    CompilerMessageId.EnumMustHaveAName,
                    enumDefinition.Node.ENUM().Symbol);
            }

            if (enumDefinition.Name != null &&
                enumDefinition.Parent.IsMemberNameAlreadyDeclared(
                    enumDefinition))
            {
                // Another type has already been declared with the same name:
                // ```
                // struct UserType {}
                // enum UserType {}
                // ```
                this.AddError(
                    CompilerMessageId.NameAlreadyDeclared,
                    enumDefinition.Node.name,
                    enumDefinition.Node.name.Text);
            }

            if (!enumDefinition.Members.Any())
            {
                var warningTarget = enumDefinition.Node.name ?? enumDefinition.Node.ENUM().Symbol;

                // The enum has no members. For example
                // `enum MyEnum {}`
                this.AddWarning(CompilerMessageId.EnumEmpty, warningTarget);
            }
        }
Exemple #8
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());
            }
        }
Exemple #9
0
        public bool SetWhiteBalanceBlue(double wbBlue)
        {
            bool result = false;

            try
            {
                //camera.BalanceRatioSelector.Value = BalanceRatioSelectorEnums.Blue.ToString();
                //camera.BalanceRatio.Value = wbBlue;
                //result = true;

                IEnum balanceWhiteAuto = nodeMap.GetNode <IEnum>("BalanceWhiteAuto");
                balanceWhiteAuto.Value = "Off";

                IEnum balanceRatioSelector = nodeMap.GetNode <IEnum>("BalanceRatioSelector");
                balanceRatioSelector.Value = "Blue";

                IFloat balanceRatio = nodeMap.GetNode <IFloat>("BalanceRatio");
                balanceRatio.Value = wbBlue;

                result = true;
            }
            catch (SpinnakerException ex)
            {
                Debug.WriteLine("Error: {0}", ex.Message);
                result = false;
            }


            return(result);
        }
Exemple #10
0
        private bool AppendEnumValue([NotNull] ConstantValue constantValue, [NotNull] IEnum enumType)
        {
            IList <IField> fields = CSharpEnumUtil.CalculateEnumMembers(constantValue, enumType);

            if (fields.Count == 0)
            {
                return(false);
            }

            string typeHighlighterId  = _highlighterIdProvider.Enum;
            string valueHighlighterId = _highlighterIdProvider.Constant;

            var  orderedFields = fields.OrderBy(f => f.ShortName);
            bool addSeparator  = false;

            foreach (IField orderedField in orderedFields)
            {
                if (addSeparator)
                {
                    AppendText(" | ", _highlighterIdProvider.Operator);
                }

                AppendText(enumType.ShortName, typeHighlighterId);
                AppendText(".", _highlighterIdProvider.Operator);
                AppendText(orderedField.ShortName, valueHighlighterId);

                addSeparator = true;
            }
            return(true);
        }
Exemple #11
0
        public bool SetSequencerConfigurationMode(bool enable)
        {
            bool result = false;

            try
            {
                IEnum iSequencerConfigurationMode = nodeMap.GetNode <IEnum>("SequencerConfigurationMode");
                if (iSequencerConfigurationMode == null || !iSequencerConfigurationMode.IsWritable)
                {
                    throw new Exception("node - SequencerConfigurationMode");
                }

                if (enable)
                {
                    //
                    // Turn configuration mode on
                    //
                    // *** NOTES ***
                    // Once sequencer mode is off, enabling sequencer configuration
                    // mode allows for the setting of individual sequences.
                    //
                    // *** LATER ***
                    // Before sequencer mode is turned back on, sequencer
                    // configuration mode must be turned off.
                    //
                    IEnumEntry iSequencerConfigurationModeOn = iSequencerConfigurationMode.GetEntryByName("On");
                    if (iSequencerConfigurationModeOn == null || !iSequencerConfigurationModeOn.IsReadable)
                    {
                        throw new Exception("entry - SequencerConfigurationMode 'On'");
                    }

                    iSequencerConfigurationMode.Value = iSequencerConfigurationModeOn.Value;
                }
                else
                {
                    //
                    // Turn configuration mode off
                    //
                    // *** NOTES ***
                    // Once all desired states have been set, turn sequencer
                    // configuration mode off in order to turn sequencer mode on.
                    //
                    IEnumEntry iSequencerConfigurationModeOff = iSequencerConfigurationMode.GetEntryByName("Off");
                    if (iSequencerConfigurationModeOff == null || !iSequencerConfigurationModeOff.IsReadable)
                    {
                        throw new Exception("entry - SequencerConfigurationMode 'Off'");
                    }

                    iSequencerConfigurationMode.Value = iSequencerConfigurationModeOff.Value;
                }
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
Exemple #12
0
        public static IEnumerable <ValidationResult> ValidateEnum(this IEnum @enum, ValidationContext validationContext)
        {
            ValidationResult[] results =
            {
                ((IValidatableObject)@enum).Is(v => string.IsNullOrWhiteSpace(v), @enum.Name, "Name")
            };

            return(results);
        }
        // Disables heartbeat on GEV cameras so debugging does not incur timeout errors
        static int DisableHeartbeat(IManagedCamera cam, INodeMap nodeMap, INodeMap nodeMapTLDevice)
        {
            Console.WriteLine("Checking device type to see if we need to disable the camera's heartbeat...\n\n");

            //
            // Write to boolean node controlling the camera's heartbeat
            //
            // *** NOTES ***
            // This applies only to GEV cameras and only applies when in DEBUG mode.
            // GEV cameras have a heartbeat built in, but when debugging applications the
            // camera may time out due to its heartbeat. Disabling the heartbeat prevents
            // this timeout from occurring, enabling us to continue with any necessary debugging.
            // This procedure does not affect other types of cameras and will prematurely exit
            // if it determines the device in question is not a GEV camera.
            //
            // *** LATER ***
            // Since we only disable the heartbeat on GEV cameras during debug mode, it is better
            // to power cycle the camera after debugging. A power cycle will reset the camera
            // to its default settings.
            //
            IEnum      iDeviceType    = nodeMapTLDevice.GetNode <IEnum>("DeviceType");
            IEnumEntry iDeviceTypeGEV = iDeviceType.GetEntryByName("GigEVision");

            // We first need to confirm that we're working with a GEV camera
            if (iDeviceType != null && iDeviceType.IsReadable)
            {
                if (iDeviceType.Value == iDeviceTypeGEV.Value)
                {
                    Console.WriteLine(
                        "Working with a GigE camera. Attempting to disable heartbeat before continuing...\n\n");
                    IBool iGEVHeartbeatDisable = nodeMap.GetNode <IBool>("GevGVCPHeartbeatDisable");
                    if (iGEVHeartbeatDisable == null || !iGEVHeartbeatDisable.IsWritable)
                    {
                        Console.WriteLine(
                            "Unable to disable heartbeat on camera. Continuing with execution as this may be non-fatal...");
                    }
                    else
                    {
                        iGEVHeartbeatDisable.Value = true;
                        Console.WriteLine("WARNING: Heartbeat on GigE camera disabled for the rest of Debug Mode.");
                        Console.WriteLine(
                            "         Power cycle camera when done debugging to re-enable the heartbeat...");
                    }
                }
                else
                {
                    Console.WriteLine("Camera does not use GigE interface. Resuming normal execution...\n\n");
                }
            }
            else
            {
                Console.WriteLine("Unable to access TL device nodemap. Aborting...");
                return(-1);
            }

            return(0);
        }
        protected override TEnum parseNodeValue(IEnum node)
        {
            TEnum value;

            if (!Enum.TryParse(node.Value, out value))
            {
                throw new SpinnakerException("Unable to parse enum '" + NodeName + "' from node value: '" + node.Value + "'");
            }

            return(value);
        }
        public void Copy(IEnum from, IEnum to)
        {
            var properties = from.GetType().GetProperties();

            foreach (var property in properties)
            {
                var value = property.GetValue(from, null);
                if (property.CanWrite)
                    property.SetValue(to, value, null);
            }
        }
Exemple #16
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            enumValue  = property.GetValue <IEnum>();
            enumValues = enumValue.GetValues();
            enumNames  = enumValue.GetNames().Convert(name => name.Replace('_', '/'));
            isFlag     = enumValue is IEnumFlag;

            return(16f);
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            base.GetPropertyHeight(property, label);

            enumValue = property.GetValue<IEnum>();
            enumValues = enumValue.GetValues();
            enumNames = enumValue.GetNames().Convert(name => name.Replace('_', '/'));
            isFlag = enumValue is IEnumFlag;

            return 16f;
        }
Exemple #18
0
        public static string GetEnumName(IEnum enumeration)
        {
            //check if there is a source Enum. In that case we use the source enum
            var enumToUse = enumeration.SourceElement as IEnum;

            if (enumToUse == null)
            {
                enumToUse = enumeration;
            }
            return(enumToUse.Name);
        }
Exemple #19
0
        private void AppendConstantValue([NotNull] ConstantValue constantValue)
        {
            if (constantValue.IsBadValue())
            {
                AppendText("bad value", null);
                return;
            }

            IEnum enumType = constantValue.Type.GetEnumType();

            if (enumType != null && AppendEnumValue(constantValue, enumType))
            {
                return;
            }

            string presentation = constantValue.GetPresentation(CSharpLanguage.Instance);

            if (presentation != null && CSharpLexer.IsKeyword(presentation))
            {
                AppendText(presentation, VsHighlightingAttributeIds.Keyword);
                return;
            }

            IType type = constantValue.Type;

            if (type != null && type.IsNullable())
            {
                type = type.GetNullableUnderlyingType();
            }

            if (type == null)
            {
                AppendText(presentation, null);
                return;
            }

            if (type.IsString())
            {
                AppendText(presentation, VsHighlightingAttributeIds.String);
            }
            else if (type.IsChar())
            {
                AppendText(presentation, VsHighlightingAttributeIds.String);
            }
            else if (type.IsPredefinedNumeric())
            {
                AppendText(presentation, VsHighlightingAttributeIds.Number);
            }
            else
            {
                AppendText(presentation, null);
            }
        }
Exemple #20
0
        /// <summary>
        /// AcquisitionMode: Continuous/SingleFrame/MutipleFrame
        /// </summary>
        /// <param name="strMode"></param>
        public override bool SetAcquisitionMode(string strMode)
        {
            bool ret = false;

            try
            {
                IEnum iAcquisitionMode = m_NodeMap.GetNode <IEnum>("AcquisitionMode");
                if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable)
                {
                    return(ret);
                }

                IEnumEntry iAcquisitionModeContinuous;
                switch (strMode)
                {
                case "Continuous":
                    // Retrieve entry node from enumeration node
                    iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous");
                    if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable)
                    {
                        return(ret);
                    }
                    break;

                case "SingleFrame":
                    iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("SingleFrame");
                    if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable)
                    {
                        return(ret);
                    }
                    break;

                case "MutipleFrame":
                    iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("MutipleFrame");
                    if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable)
                    {
                        return(ret);
                    }
                    break;

                default:
                    return(ret);
                }
                // Set symbolic from entry node as new value for enumeration node
                iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic;
                ret = true;
            }
            catch (Exception ex)
            {
                LogHelper.AppLoger.Error(ex);
            }
            return(ret);
        }
Exemple #21
0
        public void HandleGetSize(TypeHandlingContext context)
        {
            IEnum enumType = context.Type.GetEnumType();

            if (enumType == null)
            {
                throw new NotSupportedException();
            }

            IType baseType = enumType.GetUnderlyingType();

            context.Builder.AppendFormat("{1} += sizeof({0});", baseType.GetPresentableName(context.PresentationLanguage), context.GetSizeVariableName());
        }
Exemple #22
0
        public void AddComponent(byte id, byte factorHorizontal, byte factorVertical,
                                 byte quantizationID, byte colorMode)
        {
            JpegComponent component = new JpegComponent(this,
                                                        id, factorHorizontal, factorVertical, quantizationID, colorMode);

            components.Add(component);

            // Defined in Annex A
            //maxH = components.Max(x => x.factorH);
            //maxV = components.Max(x => x.factorV);
            maxH = IEnum.Max(components, x => x.factorH); // components.Max(x => x.factorH);
            maxV = IEnum.Max(components, x => x.factorV); //components.Max(x => x.factorV);
        }
Exemple #23
0
        bool RestoreDefaultSettings()
        {
            bool result = false;

            try
            {
                for (int i = 0; i < 3; i++)
                {
                    try
                    {
                        managedCamera.UserSetSelector.Value = UserSetSelectorEnums.Default.ToString();
                        managedCamera.UserSetLoad.Execute();
                        result = true;
                        break;
                    }
                    catch (SpinnakerException s)
                    {
                        managedCamera.AcquisitionMode.Value = AcquisitionModeEnums.Continuous.ToString();
                        managedCamera.BeginAcquisition();
                        System.Threading.Thread.Sleep(500);
                        managedCamera.EndAcquisition();
                    }
                }

                //TODO: stream buffer default count mode to manual
                // Set stream buffer Count Mode to manual
                // Retrieve Stream Parameters device nodemap
                INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap();
                IEnum    streamBufferCountMode = sNodeMap.GetNode <IEnum>("StreamBufferCountMode");
                if (streamBufferCountMode == null || !streamBufferCountMode.IsWritable)
                {
                    return(false);
                }

                IEnumEntry streamBufferCountModeManual = streamBufferCountMode.GetEntryByName("Manual");
                if (streamBufferCountModeManual == null || !streamBufferCountModeManual.IsReadable)
                {
                    return(false);
                }

                streamBufferCountMode.Value = streamBufferCountModeManual.Value;
            }
            catch (Exception ex)
            {
                result = false;
            }

            return(result);
        }
Exemple #24
0
        public static BaseListSyntax GetBaseList(IEnum item)
        {
            if (item.UnderlyingType != null)
            {
                var underlyingTypeSyntax = (TypeSyntax)RDom.CSharp.GetSyntaxNode(item.UnderlyingType);
                underlyingTypeSyntax = BuildSyntaxHelpers.AttachWhitespace(
                    underlyingTypeSyntax, item.UnderlyingType.Whitespace2Set, whitespaceLookup);

                var colonToken = SyntaxFactory.Token(SyntaxKind.ColonToken);
                colonToken = BuildSyntaxHelpers.AttachWhitespaceToToken(colonToken, item.Whitespace2Set[LanguageElement.BaseListPrefix]);
                return(SyntaxFactory.BaseList(colonToken,
                                              SyntaxFactory.SingletonSeparatedList <BaseTypeSyntax>(SyntaxFactory.SimpleBaseType(underlyingTypeSyntax))));
            }
            return(null);
        }
            public static EnumContractInfo TryCreate([CanBeNull] IEnum enumType)
            {
                if (enumType != null && enumType.HasAttributeInstance(PredefinedType.FLAGS_ATTRIBUTE_CLASS, false))
                {
                    var numericTypeInfo = CSharpNumericTypeInfo.TryCreate(enumType.GetUnderlyingType());
                    if (numericTypeInfo != null)
                    {
                        Debug.Assert(enumType.EnumMembers != null);

                        return(numericTypeInfo.TryCreateEnumFlags(enumType.EnumMembers));
                    }
                }

                return(null);
            }
        protected override void setNodeValue(IEnum node, TEnum value)
        {
            IEnumEntry entry = node.GetEntryByName(value.ToString());

            if (entry == null)
            {
                throw new SpinnakerException("Could not find entry '" + value.ToString() + "' for the node '" + value + "'.");
            }
            if (!entry.IsReadable)
            {
                throw new SpinnakerException("The entry '" + value.ToString() + "' for the node '" + value + "' is not readable.");
            }

            node.Value = entry.Value;
        }
            public static EnumContractInfo TryCreate(IEnum enumType)
            {
                if (enumType != null && enumType.HasAttributeInstance(PredefinedType.FLAGS_ATTRIBUTE_CLASS, false))
                {
                    var numericTypeInfo = CSharpNumericTypeInfo.TryCreate(enumType.GetUnderlyingType());
                    if (numericTypeInfo != null)
                    {
                        Debug.Assert(enumType.EnumMembers != null);

                        return numericTypeInfo.TryCreateEnumFlags(enumType.EnumMembers);
                    }
                }

                return null;
            }
Exemple #28
0
        public void SetCameraVideoModeAndFrameRate(double newFrameRate)
        {
            bool restartCapture = true;

            try
            {
                StopCapture();
            }
            catch (SpinnakerException)
            {
                throw;
            }

            try
            {
                //camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate);
                // Set acquisition mode to continuous
                IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode");
                if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable)
                {
                    Console.WriteLine("Unable to set acquisition mode to continuous (node retrieval). Aborting...\n");
                    restartCapture = false;
                }

                IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous");
                if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable)
                {
                    Console.WriteLine("Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n");
                    restartCapture = false;
                }

                iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic;
            }
            catch (SpinnakerException /*ex*/)
            {
                throw;
            }

            if (!SetFrameRate(newFrameRate))
            {
                restartCapture = false;
            }

            if (restartCapture)
            {
                StartCapture();
            }
        }
Exemple #29
0
            public void addCodeListentries(IEnum enumeration)
            {
                //if the enum doesn't contain any values that means that all values are allowed and thus all values of the source enum should be used.
                var enumToUse = enumeration.CodelistEntries.Any() && (enumeration.SourceElement as IEnum) != null ?
                                enumeration :
                                enumeration.SourceElement as IEnum;

                //do not add duplicates
                foreach (var codeListentry in enumToUse.CodelistEntries)
                {
                    if (!this.codelistEntries.Any(x => x.Name == codeListentry.Name))
                    {
                        this.codelistEntries.Add(codeListentry);
                    }
                }
            }
Exemple #30
0
        private void frameRateManualDisable()
        {
            IEnum iAcquisitionFrameRateAuto = cam.GetNodeMap().GetNode <IEnum>("AcquisitionFrameRateAuto");

            if (iAcquisitionFrameRateAuto == null || !iAcquisitionFrameRateAuto.IsWritable)
            {
                Console.WriteLine("无法设置帧率模式\n");
                return;
            }

            IEnumEntry iAcquisitionFrameRateAutoOff = iAcquisitionFrameRateAuto.GetEntryByName("Continuous");

            if (iAcquisitionFrameRateAutoOff == null || !iAcquisitionFrameRateAutoOff.IsReadable)
            {
                Console.WriteLine("无法设置启用帧率自动模式\n");
                return;
            }
            // Set symbolic from entry node as new value for enumeration node
            iAcquisitionFrameRateAuto.Value = iAcquisitionFrameRateAutoOff.Symbolic;
        }
Exemple #31
0
        public void HandleWrite(TypeHandlingContext context)
        {
            IEnum enumType = context.Type.GetEnumType();

            if (enumType == null)
            {
                throw new NotSupportedException();
            }

            IType baseType = enumType.GetUnderlyingType();
            IEnumBaseTypeHandler handler =
                TypeHandlers.EnumBaseTypeHandlers.SingleOrDefault(h => h.CanHandle(context.WithType(baseType)));

            if (handler == null)
            {
                throw new NotImplementedException();
            }

            handler.HandleEnumWrite(context.TypeOwner, context.Builder, context.Args);
        }
Exemple #32
0
        public bool SetVideoMode(int mode)
        {
            try
            {
                IEnum iVideoMode = nodeMap.GetNode <IEnum>("VideoMode");
                if (iVideoMode == null || !iVideoMode.IsWritable)
                {
                    return(false);
                }

                IEnumEntry iVideoMode0 = iVideoMode.GetEntryByName("Mode0");
                if (iVideoMode0 == null || !iVideoMode0.IsReadable)
                {
                    return(false);
                }
                IEnumEntry iVideoMode1 = iVideoMode.GetEntryByName("Mode1");
                if (iVideoMode1 == null || !iVideoMode1.IsReadable)
                {
                    return(false);
                }

                if (mode == 0)
                {
                    iVideoMode.Value = iVideoMode0.Symbolic;
                }
                else if (mode == 1)
                {
                    iVideoMode.Value = iVideoMode1.Symbolic;
                }
                else
                {
                    return(false);
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #33
-1
        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);

                                    // ==============================================================================================================
                                    // Saving current setting to UserSet1 of camera, with setting it as default when camera power on.
                                    // Please notice the UserSet saving can be only avaliable when camera is not in acquiring.

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

                                    // Select which UserSet to save the setting (UserSet1)
                                    IEnum enumUserSetSelector = nodeMap.GetNode <IEnum>("UserSetSelector");
                                    enumUserSetSelector.FromString("UserSet1");

                                    // Acquire and execute saving setting to UserSet
                                    ICommand cmdSaveToUserSet = nodeMap.GetNode <ICommand>("UserSetSave");
                                    cmdSaveToUserSet.Execute();

                                    Console.WriteLine("Save Current setting to UserSet1 succeed.");

                                    // Set UserSetDefault to UsetSet1 for using this setting when camera power on.
                                    IEnum enumUserSetDefault = nodeMap.GetNode <IEnum>("UserSetDefault");
                                    enumUserSetDefault.FromString("UserSet1");

                                    Console.WriteLine("Set UserSetDefault to UserSet1 succeed.");

                                    // ==============================================================================================================
                                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An exception occurred. \r\n" + e.Message);
            }
            finally
            {
                Console.WriteLine("\r\nPress Enter to exit.");
                Console.ReadLine();
            }
        }