Esempio n. 1
0
            public FunctionViewInfo(PropertyInfo propertyInfo)
            {
                _propertyInfo = propertyInfo;

                object[] objs = propertyInfo.GetCustomAttributes(false);
                foreach (object obj in objs)
                {
                    if (obj is FunctionAttribute)
                    {
                        FunctionAttribute fattr = (FunctionAttribute)obj;
                        _name   = fattr.FunctionName;
                        _order  = fattr.Order;
                        _error |= ~FlagsError.NotFunctionView;
                    }
                    else if (obj is FunctionColorAttribute)
                    {
                        FunctionColorAttribute fattr = obj as FunctionColorAttribute;
                        _color = fattr.FunctionColor;
                    }
                    else if (obj is FunctionStyleAttribute)
                    {
                        FunctionStyleAttribute fattr = obj as FunctionStyleAttribute;
                        _style = fattr.Style;
                        _width = fattr.Width;
                    }
                }
            }
Esempio n. 2
0
        public ConversionViewModel(SignalViewModel first)
        {
            firstSignalViewModel  = first;
            secondSignalViewModel = new SignalViewModel();

            SamplingFrequency  = new FunctionAttribute <int>(10, false, 1, 5000, "SAMPLING FREQUENCY");
            QuantizationBits   = new FunctionAttribute <int>(3, false, 2, 10, "QUANTIZATION BITS");
            QuantizationLevels = new FunctionAttribute <int>(8, false, 2, 1024, "QUANTIZATION LEVELS");

            AttributesBinding.BindAttributesTwoWay(QuantizationLevels, QuantizationBits, new LogarithmConverter());
            NumberOfSamples = new FunctionAttribute <int>(5, false, 2, 500, "NUMBER OF SAMPLES");

            AnalogToDigitalConversionOperations = new List <string> {
                "UNIFORM SAMPLING", "UNIFORM QUANTIZATION"
            };
            DigitalToAnalogConversionOperations = new List <string> {
                "ZERO-ORDER HOLD", "SINC RECONSTRUCTION"
            };
            Operation = string.Empty;

            MaximumDifference      = new Parameter(0.0d, "MAXIMUM DIFFERENCE");
            SignalToNoiseRatio     = new Parameter(0, "SIGNAL TO NOISE RATIO");
            MeanSquaredError       = new Parameter(0, "MEAN SQUARED ERROR");
            PeakSignalToNoiseRatio = new Parameter(0, "PEAK SIGNAL TO NOISE RATIO");


            Attributes = new List <FunctionAttribute <int> >(
                new[] { SamplingFrequency, QuantizationLevels, QuantizationBits, NumberOfSamples });
            ConversionMetrics = new List <Parameter>(new[]
                                                     { MeanSquaredError, MaximumDifference, SignalToNoiseRatio, PeakSignalToNoiseRatio });

            FirstSignalData.Continuous.PropertyChanged += (sender, args) => OnPropertyChanged(nameof(IsSignalAnalog));
        }
Esempio n. 3
0
        public Function(MethodInfo method, FunctionAttribute functionAttribute, Type messageType)
        {
            method.Verify(nameof(method)).IsNotNull();
            functionAttribute.Verify(nameof(functionAttribute)).IsNotNull();
            messageType.Verify(nameof(messageType)).IsNotNull();

            MethodInfo        = method;
            FunctionAttribute = functionAttribute;
            MessageType       = messageType;
        }
Esempio n. 4
0
        public static void BindAttributesOneWay <T>(
            FunctionAttribute <T> source,
            FunctionAttribute <T> target,
            IValueConverter converter = null)
            where T : struct
        {
            ConverterMethods(converter, out var convert, out var convertBack);

            BindAttributes(source, target, convert);
        }
Esempio n. 5
0
        public FunctionBuilder <TFunction> GetFunctionBuilder <TFunction>()
        {
            var function = FunctionAttribute.GetAttribute <TFunction>();

            if (function == null)
            {
                throw new Exception("Invalid TFunction required a Function Attribute");
            }
            return(new FunctionBuilder <TFunction>(Address, GetFunctionAbi(function.Name)));
        }
Esempio n. 6
0
        public static void LoadType([NotNull] Type type, [NotNull] FunctionAttribute functionAttribute)
        {
            Assert.ArgumentNotNull(type, nameof(type));
            Assert.ArgumentNotNull(functionAttribute, nameof(functionAttribute));

            var instance = Activator.CreateInstance(type) as IFunction;

            var functionDescriptor = new FunctionDescriptor(instance, functionAttribute);

            functionDescriptors.Add(functionDescriptor);
        }
Esempio n. 7
0
        public SensorSignal(double startingTime = 0)
        {
            FirstPeriod       = new FunctionAttribute <double>(2d, true, 1.0d, 100.0d, "PERIOD OF FIRST COMPONENT");
            SecondPeriod      = new FunctionAttribute <double>(3d, true, 1.0d, 100.0d, "PERIOD OF SECOND COMPONENT");
            SamplingFrequency = new FunctionAttribute <double>(10.0d, true, 0.5d, 50.0d, "SAMPLING FREQUENCY");
            NumberOfSamples   = new FunctionAttribute <int>(100, true, 50, 300, "NUMBER OF SAMPLES");
            SignalSpeed       = new FunctionAttribute <double>(10.0d, true, 10.0d, 5000.0d, "SPEED OF SIGNAL");
            ReportPeriod      = new FunctionAttribute <double>(1.0d, true, 1.0d, 5.0d, "SENSOR REPORTING PERIOD");

            Attributes = new List <object>(new object[]
                                           { FirstPeriod, SecondPeriod, SamplingFrequency, NumberOfSamples, SignalSpeed, ReportPeriod });
        }
Esempio n. 8
0
        /// <summary>
        /// Scans a given <see cref="Type" /> for functions.
        /// </summary>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// valid set of funtions; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForFunctions(Type type, Task task) {
            try {
                FunctionSetAttribute functionSetAttribute = (FunctionSetAttribute) 
                    Attribute.GetCustomAttribute(type, typeof(FunctionSetAttribute));
                if (functionSetAttribute == null) {
                    // specified type does not represent a valid functionset
                    return false;
                }

                bool acceptType = (type == typeof(ExpressionEvaluator));
                
                if (type.IsSubclassOf(typeof(FunctionSetBase)) && !type.IsAbstract) {
                    acceptType = true;
                }

                if (acceptType) {
                    string prefix = functionSetAttribute.Prefix;
                    if (prefix != null && prefix != String.Empty) {
                        prefix += "::";
                    } else {
                        task.Log(Level.Warning, "Ignoring functions in type \"{0}\":"
                            + " no prefix was set.", type.AssemblyQualifiedName);

                        // specified type does not represent a valid functionset
                        return false;
                    }

                    //
                    // add public static/instance methods
                    // 
                    foreach (MethodInfo info in type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) {
                        FunctionAttribute functionAttribute = (FunctionAttribute)
                            Attribute.GetCustomAttribute(info, typeof(FunctionAttribute));
                        if (functionAttribute != null)
                            RegisterFunction(prefix + functionAttribute.Name, info);
                    }

                    // specified type represents a valid functionset
                    return true;
                } else {
                    // specified type does not represent a valid functionset
                    return false;
                }
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for functions.", 
                    type.AssemblyQualifiedName);
                throw;
            }
        }
Esempio n. 9
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterSingleton <PageManager>();
            containerRegistry.RegisterSingleton <UserControlManager>();
            Type[] pages       = AppDomainAllAssemblyFinder.FindAll <Page>();
            var    pageManager = containerRegistry.GetContainer().Resolve <PageManager>();

            Type[] array = pages;
            foreach (Type item in array)
            {
                containerRegistry.RegisterForNavigation(item, item.FullName);
                FunctionAttribute function = item.GetAttribute <FunctionAttribute>();
                if (function != null)
                {
                    pageManager.Add(function.UniqueName, item);
                }
            }
            Type[] controls       = AppDomainAllAssemblyFinder.FindAll <UserControl>();
            var    controlManager = containerRegistry.GetContainer().Resolve <UserControlManager>();

            Type[] array2 = controls;
            foreach (Type item2 in array2)
            {
                containerRegistry.RegisterForNavigation(item2, item2.FullName);
                QueryLocatorAttribute locator = item2.GetAttribute <QueryLocatorAttribute>();
                if (locator != null)
                {
                    controlManager.Add(item2.FullName, new ControlMapping
                    {
                        ControlType = item2,
                        RegionName  = locator.RegionName,
                        TargetType  = locator.Target
                    });
                }
            }
            containerRegistry.RegisterDialog <AlertDialog, AlertDialogViewModel>();
            containerRegistry.RegisterDialog <ConfirmDialog, ConfirmDialogViewModel>();
            containerRegistry.RegisterDialog <ErrorDialog, ErrorDialogViewModel>();
            containerRegistry.RegisterDialog <SuccessDialog, SuccessDialogViewModel>();
            containerRegistry.RegisterDialog <WarningDialog, WarningDialogViewModel>();
            containerRegistry.Register(typeof(IDialogWindow), typeof(Views.Dialogs.DialogWindow), "dialog");
            containerRegistry.RegisterDialog <CommonDialogPage, CommonDialogPageViewModel>();
        }
Esempio n. 10
0
File: CPU.cs Progetto: silky/KOS
        private void LoadFunctions()
        {
            _functions = new Dictionary <string, FunctionBase>();

            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                FunctionAttribute attr = (FunctionAttribute)type.GetCustomAttributes(typeof(FunctionAttribute), true).FirstOrDefault();
                if (attr != null)
                {
                    object functionObject = Activator.CreateInstance(type);
                    foreach (string functionName in attr.Names)
                    {
                        if (functionName != string.Empty)
                        {
                            _functions.Add(functionName, (FunctionBase)functionObject);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public ConvolutionFiltrationCorrelationViewModel(SignalViewModel first)
        {
            firstSignalViewModel = first;
            SecondSignalData     = new FunctionData();
            filter = new Filter();

            filters = new Dictionary <FilterType, string>();
            filters.Add(FilterType.LowPassFilter, "LOW-PASS FILTER");
            filters.Add(FilterType.HighPassFilter, "HIGH-PASS FILTER");

            selectedFilter = FilterType.LowPassFilter;
            window         = new RectangularWindow();
            windows        = new List <IWindow>(new IWindow[]
                                                { new RectangularWindow(), new HanningWindow() /*, new HammingWindow(), new BlackmanWindow()*/ });

            filterOrder     = new FunctionAttribute <int>(5, true, 1, 500, "FILTER ORDER");
            cutoffFrequency = new FunctionAttribute <double>(400.0d, true, 10.0d, 25000.0d, "CUTOFF FREQUENCY");

            Attributes = new List <object>(new[] { filterOrder, (object)cutoffFrequency });

            firstSignalViewModel.SignalGenerated += (sender, args) => FilterCommand.RaiseCanExecuteChanged();
        }
Esempio n. 12
0
        private static void BindAttributes <T>(
            FunctionAttribute <T> source,
            FunctionAttribute <T> target,
            Func <object, Type, object, CultureInfo, object> convert)
            where T : struct
        {
            source.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName.Equals(nameof(source.Value)))
                {
                    target.Value = (T)(convert(
                                           source.Value,
                                           target.Value.GetType(),
                                           null,
                                           CultureInfo.InvariantCulture) ?? target.Value);
                    return;
                }

                if (args.PropertyName.Equals(nameof(source.Visibility)))
                {
                    target.Visibility = source.Visibility;
                }
            };
        }
Esempio n. 13
0
 public IntPtr CreateNativeWrapperX86 <TFunction>(IntPtr functionAddress, IFunctionAttribute fromConvention) => X86.Wrapper.Create <TFunction>(functionAddress, fromConvention, FunctionAttribute.GetAttribute <TFunction>().GetEquivalent(Misc.TryGetAttributeOrDefault <TFunction, UnmanagedFunctionPointerAttribute>()));
Esempio n. 14
0
 public TrackedObject()
 {
     Position   = new Parameter(0.0d, "POSITION");
     Velocity   = new FunctionAttribute <double>(1.0d, true, 0.5d, 20.0d, "VELOCITY");
     Attributes = new List <FunctionAttribute <double> >(new[] { Velocity });
 }
Esempio n. 15
0
        private string resolveFunctionName(Type targetType)
        {
            FunctionAttribute typeFunctionAttribute = targetType.GetCustomAttribute <FunctionAttribute>();

            return(typeFunctionAttribute?.FunctionName);
        }
 public AttributedMetaFunction(MethodInfo method, FunctionAttribute attribute)
 {
     functionAttribute = attribute;
     methodInfo        = method;
 }
Esempio n. 17
0
        public override string ToString()
        {
            FunctionAttribute a = this.getAttr();

            return(a == null?"???":a.Title);
        }
Esempio n. 18
0
 public static extern CuResult FuncSetAttribute(CuFunction hfunc, FunctionAttribute attrib, int value);
Esempio n. 19
0
 public static extern CuResult FuncGetAttribute(out int pi, FunctionAttribute attrib, CuFunction hfunc);
        /// <summary>
        /// Gets the <see cref="OpenApiOperation"/> instance.
        /// </summary>
        /// <param name="helper"><see cref="IDocumentHelper"/> instance.</param>
        /// <param name="element"><see cref="MethodInfo"/> instance.</param>
        /// <param name="function"><see cref="FunctionAttribute"/> instance.</param>
        /// <param name="verb"><see cref="OperationType"/> value.</param>
        /// <returns><see cref="OpenApiOperation"/> instance.</returns>
        public static OpenApiOperation GetOpenApiOperation(this IDocumentHelper helper, MethodInfo element, FunctionAttribute function, OperationType verb)
        {
            var op = element.GetOpenApiOperation();

            if (op.IsNullOrDefault())
            {
                return(null);
            }

            var operation = new OpenApiOperation()
            {
                OperationId = string.IsNullOrWhiteSpace(op.OperationId) ? $"{function.Name}_{verb}" : op.OperationId,
                Tags        = op.Tags.Select(p => new OpenApiTag()
                {
                    Name = p
                }).ToList(),
                Summary     = op.Summary,
                Description = op.Description,
                Deprecated  = op.Deprecated
            };

            if (op.Visibility != OpenApiVisibilityType.Undefined)
            {
                var visibility = new OpenApiString(op.Visibility.ToDisplayName());

                operation.Extensions.Add("x-ms-visibility", visibility);
            }

            return(operation);
        }
        /// <summary>
        /// Gets the HTTP trigger endpoint.
        /// </summary>
        /// <param name="helper"><see cref="IDocumentHelper"/> instance.</param>
        /// <param name="function"><see cref="FunctionAttribute"/> instance.</param>
        /// <param name="trigger"><see cref="HttpTriggerAttribute"/> instance.</param>
        /// <returns>Function HTTP endpoint.</returns>
        public static string GetHttpEndpoint(this IDocumentHelper helper, FunctionAttribute function, HttpTriggerAttribute trigger)
        {
            var endpoint = $"/{(string.IsNullOrWhiteSpace(trigger.Route) ? function.Name : helper.FilterRouteConstraints(trigger.Route)).Trim('/')}";

            return(endpoint);
        }
Esempio n. 22
0
 public FunctionDescriptor(IFunction function, FunctionAttribute attribute)
 {
     Attribute = attribute;
     Function  = function;
 }
Esempio n. 23
0
        public IntPtr CreateNativeWrapperX86 <
#if NET5_0_OR_GREATER
            [DynamicallyAccessedMembers(Trimming.ReloadedAttributeTypes)]
#endif
            TFunction>(IntPtr functionAddress, IFunctionAttribute fromConvention) => X86.Wrapper.Create <TFunction>(functionAddress.ToUnsigned(), fromConvention, FunctionAttribute.GetAttribute <TFunction>().GetEquivalent(Misc.TryGetAttributeOrDefault <TFunction, UnmanagedFunctionPointerAttribute>())).ToSigned();