예제 #1
0
        private void ComputeSubFeatures()
        {
            //DateTime d = DateTime.Now;
            List <double> CurrentData;

            CurrentData = this.SubData.Peek(SubWindowLength);
            this.SubData.Delete(SubWindowShift);
            DataProvider.Data = CurrentData;

            List <double> ComputedFeatures = new List <double>();

            foreach (IFeature f in SubFeatures)
            {
                f.Compute();
                SubResults[f].Enqueue(f.Feature);
                ComputedFeatures.Add(f.Feature);
            }
            //TimeSpan ts = DateTime.Now - d;
            //int ms = ts.Milliseconds;
            //SubFeaturesComputedEventArgs e = new SubFeaturesComputedEventArgs();
            //e.ComputedFeatures = ComputedFeatures;
            //SubFeaturesComputed.Invoke(this, e);

            if (SubResults.First().Value.Count > SuperWindowLength)
            {
                ComputeSuperFeatures();
            }

            if (this.SubData.Count > SubWindowLength)
            {
                ComputeSubFeatures();
            }
        }
예제 #2
0
        private void ComputeSuperFeatures()
        {
            foreach (IFeature f in SubFeatures)
            {
                FastQueue <double> CurrentQueue = SubResults[f];
                List <double>      CurrentData  = CurrentQueue.Peek(SuperWindowLength);
                CurrentQueue.Delete(SuperWindowShift);
                DataProvider.Data = CurrentData;

                List <IFeature> CurrentSuperFeatures = SuperFeatures[f];
                foreach (IFeature superf in CurrentSuperFeatures)
                {
                    superf.Compute();
                    FinalFeatures.Add(superf.Feature);
                }
            }

            if (SuperFeaturesComputed != null)
            {
                SubFeaturesComputedEventArgs e = new SubFeaturesComputedEventArgs();
                e.ComputedFeatures = FinalFeatures;
                SuperFeaturesComputed.Invoke(this, e);
            }
            Classify();
            AllFeatures.Add(new List <double>(FinalFeatures));
            FinalFeatures.Clear();
            if (SubResults.First().Value.Count > SuperWindowLength)
            {
                ComputeSuperFeatures();
            }
        }
            public bool IsValid(IList <string> locatedProperties)
            {
                switch (ConditionType)
                {
                case SchemaConditionType.AllOf:
                    return(SubResults.All(r => r.IsValid(locatedProperties)));

                case SchemaConditionType.AnyOf:
                    return(SubResults.Any(r => r.IsValid(locatedProperties)));

                case SchemaConditionType.OneOf:
                    return(SubResults.Count(r => r.IsValid(locatedProperties)) == 1);

                case SchemaConditionType.NotOf:
                    return(!((Messages == null || Messages.Count == 0) &&
                             SubResults.All(r => r.IsValid(locatedProperties))));

                case SchemaConditionType.Dependency:
                    return(!locatedProperties.Contains(ConditionalPropertyName, StringComparer.Ordinal) ||
                           ((Messages == null || Messages.Count == 0) &&
                            SubResults.All(r => r.IsValid(locatedProperties))));

                default:
                    return((Messages == null || Messages.Count == 0) &&
                           SubResults.All(r => r.IsValid(locatedProperties)));
                }
            }
예제 #4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="VerificationResult" /> struct for a branch node.
        /// </summary>
        /// <param name="description">The description of the verification node.</param>
        /// <param name="subResults">A list of verification nodes who together build up to this node.</param>
        public VerificationResult(string description, IEnumerable <VerificationResult> subResults)
        {
            Description = description;

            VerificationResult[] array = subResults?.ToArray() ?? EmptyVerificationResultArray;

            if (array.Length == 0)
            {
                SubResults = EmptyVerificationResultArray;
            }
            else
            {
                SubResults = new ReadOnlyCollection <VerificationResult>(array);
            }

            Success = SubResults.All(sr => sr.Success);
        }
예제 #5
0
        public List <SubResults> GetData(string TableName, string Data2Get, string Where = "")
        {
            List <SubResults> Results = new List <SubResults>();
            SubResults        _Subresult;

            SqlCommand MyCmd = this.MyConn.CreateCommand();

            if (Where.Equals(""))
            {
                MyCmd.CommandText = "Select " + Data2Get + " from " + TableName;
            }
            else
            {
                MyCmd.CommandText = "Select " + Data2Get + " from " + TableName + " where " + Where;
            }


            try
            {
                MyReader = MyCmd.ExecuteReader();

                while (MyReader.Read())
                {
                    _Subresult = new SubResults();

                    for (int i = 0; i < MyReader.FieldCount; i++)
                    {
                        _Subresult.Add(MyReader.GetValue(i));
                    }

                    Results.Add(_Subresult);
                }
                MyReader.Close();
            }
            catch (Exception MyEx)
            {
                Err(this, new IErrorEventArgs(MyEx, "GetData function in " + TableName + " on " + this.Database));
                if (MyReader != null)
                {
                    MyReader.Close();
                }
            }
            return(Results);
        }
예제 #6
0
        public SubResults Get1Data(string TableName, string Data2Get, string Where = "")
        {
            SubResults _Subresult = new SubResults();

            SqlCommand MyCmd = this.MyConn.CreateCommand();

            if (Where.Equals(""))
            {
                MyCmd.CommandText = "Select TOP 1 " + Data2Get + " from " + TableName;
            }
            else
            {
                MyCmd.CommandText = "Select TOP 1 " + Data2Get + " from " + TableName + " where " + Where;
            }


            try
            {
                MyReader = MyCmd.ExecuteReader();

                while (MyReader.Read())
                {
                    for (int i = 0; i < MyReader.FieldCount; i++)
                    {
                        _Subresult.Add(MyReader.GetValue(i));
                    }
                }
                MyReader.Close();
            }
            catch
            {
                if (MyReader != null)
                {
                    MyReader.Close();
                }
            }
            return(_Subresult);
        }
예제 #7
0
        public List <SubResults> Get_TblFields(string TableName)
        {
            List <SubResults> Results = new List <SubResults>();
            SubResults        _Subresult;
            SqlCommand        MyCmd = MyConn.CreateCommand();

            MyCmd.CommandText = "Select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='" + TableName + "'";

            try
            {
                MyReader = MyCmd.ExecuteReader();

                while (MyReader.Read())
                {
                    _Subresult = new SubResults();

                    for (int i = 0; i < MyReader.FieldCount; i++)
                    {
                        _Subresult.Add(MyReader.GetValue(i));
                    }

                    Results.Add(_Subresult);
                }
                MyReader.Close();
            }
            catch (Exception MyEx)
            {
                Err(this, new IErrorEventArgs(MyEx, "Get_TblFields function with " + TableName + " on " + this.Database));
                if (MyReader != null)
                {
                    MyReader.Close();
                }
            }

            return(Results);
        }