Beispiel #1
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            CogPatternResult _CogPatternResult  = new CogPatternResult();
            CogPatternAlgo   _CogPatternAlgoRcp = new CogPatternAlgo();

            _CogPatternAlgoRcp.MatchingScore = Convert.ToDouble(numericUpDownFindScore.Value);
            _CogPatternAlgoRcp.MatchingCount = Convert.ToInt32(numericUpDownFindCount.Value);
            _CogPatternAlgoRcp.MatchingAngle = Convert.ToDouble(numericUpDownAngleLimit.Value);
            _CogPatternAlgoRcp.IsShift       = Convert.ToBoolean(checkBoxShift.Checked);
            _CogPatternAlgoRcp.AllowedShiftX = Convert.ToDouble(numericUpDownAllowedShiftX.Value);
            _CogPatternAlgoRcp.AllowedShiftY = Convert.ToDouble(numericUpDownAllowedShiftY.Value);
            _CogPatternAlgoRcp.PatternCount  = CogPatternAlgoRcp.ReferenceInfoList.Count;

            _CogPatternAlgoRcp.ReferenceInfoList = new References();
            for (int iLoopCount = 0; iLoopCount < CogPatternAlgoRcp.ReferenceInfoList.Count; ++iLoopCount)
            {
                ReferenceInformation _ReferInfo = new ReferenceInformation();
                _ReferInfo = CogPatternAlgoRcp.ReferenceInfoList[iLoopCount];
                _CogPatternAlgoRcp.ReferenceInfoList.Add(_ReferInfo);
            }

            var _ApplyPatternMatchingValueEvent = ApplyPatternMatchingValueEvent;

            _ApplyPatternMatchingValueEvent?.Invoke(_CogPatternAlgoRcp, ref _CogPatternResult);
        }
Beispiel #2
0
        public void SetAlgoRecipe(Object _Algorithm, double _BenchMarkOffsetX, double _BenchMarkOffsetY, double _ResolutionX, double _ResolutionY)
        {
            if (null == _Algorithm)
            {
                return;
            }

            CogAutoPatternAlgoRcp = _Algorithm as CogAutoPatternAlgo;
            for (int iLoopCount = 0; iLoopCount < CogAutoPatternAlgoRcp.ReferenceInfoList.Count; ++iLoopCount)
            {
                ReferenceInformation _ReferInfo = CogAutoPatternAlgoRcp.ReferenceInfoList[iLoopCount];
            }

            BenchMarkOffsetX = _BenchMarkOffsetX;
            BenchMarkOffsetY = _BenchMarkOffsetY;

            numericUpDownFindScore.Value = Convert.ToDecimal(CogAutoPatternAlgoRcp.MatchingScore);
            numericUpDownThreshold.Value = Convert.ToDecimal(CogAutoPatternAlgoRcp.PatternThreshold);

            if (CogAutoPatternAlgoRcp.ReferenceInfoList.Count > 0)
            {
                ShowPatternImageArea();
                ShowPatternImage();
            }
        }
 public string GetSalesOrderNumber()
 {
     return
         (ReferenceInformation
          .FirstOrDefault(info => info.ReferenceType == cidxListReferenceType.SalesOrderReference)?
          .DocumentReference?
          .DocumentIdentifier ?? string.Empty);
 }
 public void setReferenceInfo(ReferenceInformation item)
 {
     this.name_     = item.ReferenceEntity_.EntityName_.ValueStr;
     this.id_       = item.ReferenceEntity_.EntityId_.ValueStr;
     this.bondID_   = item.ReferenceObligation_.Bond_.InstrumentId_.ValueStr;
     this.coupon_   = item.ReferenceObligation_.Bond_.CouponRate_.DoubleValue();
     this.maturiry_ = item.ReferenceObligation_.Bond_.Maturity_.DateTimeValue();
 }
Beispiel #5
0
 public void CancelAlgoRecipe()
 {
     CogPatternAlgoRcp.ReferenceInfoList.Clear();
     for (int iLoopCount = 0; iLoopCount < ReferenceBackup.Count; ++iLoopCount)
     {
         ReferenceInformation _ReferInfo = ReferenceBackup[iLoopCount];
         CogPatternAlgoRcp.ReferenceInfoList.Add(_ReferInfo);
     }
 }
Beispiel #6
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            int Num = Convert.ToInt32(((Button)sender).Tag);

            SelectedPattern = Num;

            if (CogMultiPatternAlgoRcp.ReferenceInfoList.Count <= Num)
            {
                MessageBox.Show("등록된 Pattern이 없습니다."); return;
            }

            CogMultiPatternResult _CogMultiPatternResult  = new CogMultiPatternResult();
            CogMultiPatternAlgo   _CogMultiPatternAlgoRcp = new CogMultiPatternAlgo();

            _CogMultiPatternAlgoRcp.MatchingScore = Convert.ToDouble(numericUpDownFindScore.Value);
            _CogMultiPatternAlgoRcp.MatchingCount = Convert.ToInt32(numericUpDownFindCount.Value);
            _CogMultiPatternAlgoRcp.MatchingAngle = Convert.ToDouble(numericUpDownAngleLimit.Value);

            _CogMultiPatternAlgoRcp.ReferenceInfoList = new References();

            int ReferenceCount = 1;

            if (SelectedPattern == -1)
            {
                ReferenceCount = CogMultiPatternAlgoRcp.ReferenceInfoList.Count;
            }

            for (int iLoopCount = 0; iLoopCount < ReferenceCount; iLoopCount++)
            {
                ReferenceInformation _ReferInfo = new ReferenceInformation();

                if (SelectedPattern != -1)
                {
                    _ReferInfo = CogMultiPatternAlgoRcp.ReferenceInfoList[SelectedPattern];
                }
                else
                {
                    _ReferInfo = CogMultiPatternAlgoRcp.ReferenceInfoList[iLoopCount];
                }

                _CogMultiPatternAlgoRcp.ReferenceInfoList.Add(_ReferInfo);
            }

            var _ApplyPatternMatchingValueEvent = ApplyMultiPatternValueEvent;

            _ApplyPatternMatchingValueEvent?.Invoke(_CogMultiPatternAlgoRcp, ref _CogMultiPatternResult);

            txtBoxAngle.Text = (_CogMultiPatternResult.IsGood) ? _CogMultiPatternResult.TwoPointAngle.ToString("N2") : "0.0";
        }
Beispiel #7
0
        public void SetAlgoRecipe(Object _Algorithm, double _BenchMarkOffsetX, double _BenchMarkOffsetY, double _ResolutionX, double _ResolutionY)
        {
            if (null == _Algorithm)
            {
                return;
            }
            CurrentPattern = 0;

            CogPatternAlgoRcp = _Algorithm as CogPatternAlgo;
            ReferenceBackup.Clear();
            for (int iLoopCount = 0; iLoopCount < CogPatternAlgoRcp.ReferenceInfoList.Count; ++iLoopCount)
            {
                ReferenceInformation _ReferInfo = CogPatternAlgoRcp.ReferenceInfoList[iLoopCount];
                ReferenceBackup.Add(_ReferInfo);
            }

            ResolutionX      = _ResolutionX;
            ResolutionY      = _ResolutionY;
            BenchMarkOffsetX = _BenchMarkOffsetX;
            BenchMarkOffsetY = _BenchMarkOffsetY;

            numericUpDownFindScore.Value     = Convert.ToDecimal(CogPatternAlgoRcp.MatchingScore);
            numericUpDownFindCount.Value     = Convert.ToDecimal(CogPatternAlgoRcp.MatchingCount);
            numericUpDownAngleLimit.Value    = Convert.ToDecimal(CogPatternAlgoRcp.MatchingAngle);
            numericUpDownAllowedShiftX.Value = Convert.ToDecimal(CogPatternAlgoRcp.AllowedShiftX);
            numericUpDownAllowedShiftY.Value = Convert.ToDecimal(CogPatternAlgoRcp.AllowedShiftY);
            checkBoxShift.Checked            = CogPatternAlgoRcp.IsShift;
            labelPatternCount.Text           = CogPatternAlgoRcp.ReferenceInfoList.Count.ToString();

            CogPatternAlgoRcp.PatternCount = CogPatternAlgoRcp.ReferenceInfoList.Count;
            if (CogPatternAlgoRcp.ReferenceInfoList.Count > 0)
            {
                if (CurrentPattern == 0)
                {
                    CurrentPattern = 1;
                }
                ShowPatternImageArea(CurrentPattern);
                ShowPatternImage(CurrentPattern);
                UpdatePatternCount();
            }
            else
            {
                ShowPatternImage(0);
            }
        }
Beispiel #8
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            CogAutoPatternResult _CogAutoPatternResult  = new CogAutoPatternResult();
            CogAutoPatternAlgo   _CogAutoPatternAlgoRcp = new CogAutoPatternAlgo();

            _CogAutoPatternAlgoRcp.MatchingScore = Convert.ToDouble(numericUpDownFindScore.Value);
            _CogAutoPatternAlgoRcp.MatchingCount = 1;

            _CogAutoPatternAlgoRcp.ReferenceInfoList = new References();
            for (int iLoopCount = 0; iLoopCount < CogAutoPatternAlgoRcp.ReferenceInfoList.Count; ++iLoopCount)
            {
                ReferenceInformation _ReferInfo = new ReferenceInformation();
                _ReferInfo = CogAutoPatternAlgoRcp.ReferenceInfoList[iLoopCount];
                _CogAutoPatternAlgoRcp.ReferenceInfoList.Add(_ReferInfo);
            }

            var _ApplyAutoPatternFindValueEvent = ApplyAutoPatternFindValueEvent;

            _ApplyAutoPatternFindValueEvent?.Invoke(_CogAutoPatternAlgoRcp, ref _CogAutoPatternResult);
        }
Beispiel #9
0
        public void SetAlgoRecipe(Object _Algorithm, double _BenchMarkOffsetX, double _BenchMarkOffsetY, double _ResolutionX, double _ResolutionY)
        {
            if (null == _Algorithm)
            {
                return;
            }

            CogMultiPatternAlgoRcp = _Algorithm as CogMultiPatternAlgo;
            ReferenceBackup.Clear();
            for (int iLoopCount = 0; iLoopCount < CogMultiPatternAlgoRcp.ReferenceInfoList.Count; ++iLoopCount)
            {
                ReferenceInformation _ReferInfo = CogMultiPatternAlgoRcp.ReferenceInfoList[iLoopCount];
                ReferenceBackup.Add(_ReferInfo);
            }

            ResolutionX      = _ResolutionX;
            ResolutionY      = _ResolutionY;
            BenchMarkOffsetX = _BenchMarkOffsetX;
            BenchMarkOffsetY = _BenchMarkOffsetY;

            numericUpDownFindScore.Value  = Convert.ToDecimal(CogMultiPatternAlgoRcp.MatchingScore);
            numericUpDownFindCount.Value  = Convert.ToDecimal(CogMultiPatternAlgoRcp.MatchingCount);
            numericUpDownAngleLimit.Value = Convert.ToDecimal(CogMultiPatternAlgoRcp.MatchingAngle);
            txtBoxAngle.Text = CogMultiPatternAlgoRcp.TwoPointAngle.ToString("F2");
            //txtBoxAngle.Text = "0.0";

            if (CogMultiPatternAlgoRcp.ReferenceInfoList.Count > 0)
            {
                for (int iLoopCount = 0; iLoopCount < CogMultiPatternAlgoRcp.ReferenceInfoList.Count; iLoopCount++)
                {
                    ShowPatternImageArea(iLoopCount + 1);
                    ShowPatternImage(iLoopCount + 1);
                }

                SetPatternButton(1, true);
            }
            else
            {
                ShowPatternImage(0);
            }
        }
        /// <summary>
        /// Check this table has this reference or not
        /// </summary>
        /// <param name="reference"></param>
        /// <returns></returns>
        public bool HasReference(ReferenceInformation reference)
        {
            //
            // Initialize result
            bool result = false;

            //
            // Check
            foreach (ReferenceInformation refer in this._listReference)
            {
                if (refer.Equals(reference))
                {
                    result = true;
                    break;
                }
            }

            //
            // Return result
            return(result);
        }
Beispiel #11
0
        protected override IDataProvider <DynamicJsonArray> CreateArrayLinkDataProvider(ReferenceInformation refInfo, DbConnection connection)
        {
            var queryColumns    = string.Join(", ", refInfo.TargetPrimaryKeyColumns.Select(QuoteColumn));
            var queryParameters = string.Join(" and ", refInfo.ForeignKeyColumns.Select((column, idx) => $"\"{QuoteColumn(column)}\" = :p{idx}"));

            var query = $"select \"{queryColumns}\" from \"{QuoteTable(refInfo.SourceSchema, refInfo.SourceTableName)}\" where {queryParameters}";

            return(new SqlStatementProvider <DynamicJsonArray>(connection, query, specialColumns => GetColumns(specialColumns, refInfo.SourcePrimaryKeyColumns), reader =>
            {
                var result = new DynamicJsonArray();
                while (reader.Read())
                {
                    var linkParameters = new object[reader.FieldCount];
                    for (var i = 0; i < linkParameters.Length; i++)
                    {
                        linkParameters[i] = reader[i];
                    }

                    result.Add(GenerateDocumentId(refInfo.CollectionNameToUseInLinks, linkParameters));
                }

                return result;
            }));
        }
Beispiel #12
0
        /// <summary>
        /// Has circle reference
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="referenceTable"></param>
        /// <param name="listTableHasCheck"></param>
        /// <returns></returns>
        private bool HasCircleReference(string tableName, ReferenceInformation reference, List <string> listTableHasCheck, List <string> tracking)
        {
            //
            // Initialize result
            bool result = false;

            //
            // Check current reference
            if (reference.PKTableName.Equals(tableName))
            {
                result = true;
            }
            else
            {
                //
                // Try to get referenced table
                // And go deeper (using recursion algorithm)
                MapTable referencedTable = this.GetMapTable(reference.PKTableName);
                List <ReferenceInformation> listReference = referencedTable.GetReference();
                listTableHasCheck.Add(referencedTable.Name);
                foreach (ReferenceInformation childReference in listReference)
                {
                    //
                    // Check
                    if (childReference.PKTableName.Equals(tableName))
                    {
                        // Add to tracking list if needed
                        if (tracking != null)
                        {
                            tracking.Add(referencedTable.Name);
                        }
                        result = true;
                        break;
                    }


                    //
                    // If referenced table is checked
                    // We don't need to go further
                    if (listTableHasCheck.Contains(childReference.PKTableName))
                    {
                        continue;
                    }


                    //
                    // Else try to go deeper
                    bool response = this.HasCircleReference(tableName, childReference, listTableHasCheck, tracking);
                    if (response)
                    {
                        // Add to tracking list if needed
                        if (tracking != null)
                        {
                            tracking.Add(referencedTable.Name);
                        }
                        result = true;
                        break;
                    }
                }
            }



            //
            // Return result
            return(result);
        }
Beispiel #13
0
        //private void DrawAutoPatternRegionFunction(CogRectangle _ReferRegion, double _OriginX, double _OriginY, CogColorConstants _Color)
        //{
        //    if (eTeachStep.ALGO_SET != CurrentTeachStep) { MessageBox.Show("Not select \"Algorithm Set\" button"); return; }
        //    AlgorithmAreaDisplayRefresh();

        //    CogPointMarker _PointMarker = new CogPointMarker();
        //    _PointMarker.SetCenterRotationSize(_OriginX, _OriginY, 0, 1);

        //    kpTeachDisplay.DrawInterActiveShape(_ReferRegion, "ReferRegion", _Color);
        //    kpTeachDisplay.DrawInterActiveShape(_PointMarker, "ReferOriginPoint", _Color, 14);
        //}

        private void AutoPatternActionFunction(eReferAction _ReferAction, int _Index = 0)
        {
            if (eTeachStep.ALGO_SET != CurrentTeachStep)
            {
                MessageBox.Show("Not select \"Algorithm Set\" button"); return;
            }

            //if (_ReferAction == eReferAction.ADD)
            //{
            //    CogPointMarker _PointMark = new CogPointMarker();
            //    int _Pixel;
            //    double _PointCenterX, _PointCenterY, _Rotate;
            //    _PointMark = kpTeachDisplay.GetInterActivePoint();
            //    _PointMark.GetCenterRotationSize(out _PointCenterX, out _PointCenterY, out _Rotate, out _Pixel);

            //    CogRectangle _ReferRegion = new CogRectangle();
            //    CogRectangle _Boundary = new CogRectangle();
            //    _Boundary.SetXYWidthHeight(AlgoRegionRectangle.X, AlgoRegionRectangle.Y, AlgoRegionRectangle.Width, AlgoRegionRectangle.Height);
            //    if (false == GetCorrectionRectangle(kpTeachDisplay, _Boundary, ref _ReferRegion)) { MessageBox.Show("The rectangle is outside the inspection area."); return; }

            //    double _OriginPointOffsetX = _ReferRegion.CenterX - _PointCenterX;
            //    double _OriginPointOffsetY = _ReferRegion.CenterY - _PointCenterY;

            //    DrawReferRegionFunction(_ReferRegion, _PointMark.X, _PointMark.Y, CogColorConstants.Cyan);

            //    //Pattern 추출
            //    ReferenceInformation _PatternInfo = new ReferenceInformation();
            //    _PatternInfo.StaticStartX = _ReferRegion.X;
            //    _PatternInfo.StaticStartY = _ReferRegion.Y;
            //    _PatternInfo.CenterX = _ReferRegion.CenterX;
            //    _PatternInfo.CenterY = _ReferRegion.CenterY;
            //    _PatternInfo.Width = _ReferRegion.Width;
            //    _PatternInfo.Height = _ReferRegion.Height;
            //    _PatternInfo.OriginPointOffsetX = _OriginPointOffsetX;
            //    _PatternInfo.OriginPointOffsetY = _OriginPointOffsetY;
            //    _PatternInfo.Reference = InspPatternProcess.GetPatternReference(InspectionImage, _ReferRegion, _PointCenterX, _PointCenterY);
            //    ((CogPatternAlgo)InspParam.InspAreaParam[InspAreaSelected].InspAlgoParam[InspAlgoSelected].Algorithm).ReferenceInfoList.Add(_PatternInfo);
            //    //((CogMultiPatternAlgo)InspParam.InspAreaParam[InspAreaSelected].InspAlgoParam[InspAlgoSelected].Algorithm).ReferenceInfoList.Add(_PatternInfo);
            //}

            else if (_ReferAction == eReferAction.MODIFY)
            {
                CogPointMarker _PointMark = new CogPointMarker();
                int            _Pixel;
                double         _PointCenterX, _PointCenterY, _Rotate;
                _PointMark = kpTeachDisplay.GetInterActivePoint();
                _PointMark.GetCenterRotationSize(out _PointCenterX, out _PointCenterY, out _Rotate, out _Pixel);

                CogRectangle _ReferRegion = new CogRectangle();
                CogRectangle _Boundary    = new CogRectangle();
                _Boundary.SetXYWidthHeight(AlgoRegionRectangle.X, AlgoRegionRectangle.Y, AlgoRegionRectangle.Width, AlgoRegionRectangle.Height);
                if (false == GetCorrectionRectangle(kpTeachDisplay, _Boundary, ref _ReferRegion))
                {
                    MessageBox.Show("The rectangle is outside the inspection area."); return;
                }

                double _OriginPointOffsetX = _ReferRegion.CenterX - _PointCenterX;
                double _OriginPointOffsetY = _ReferRegion.CenterY - _PointCenterY;

                DrawReferRegionFunction(_ReferRegion, _PointMark.X, _PointMark.Y, CogColorConstants.Cyan);

                //Pattern 추출
                ReferenceInformation _PatternInfo = new ReferenceInformation();
                _PatternInfo.StaticStartX       = _ReferRegion.X;
                _PatternInfo.StaticStartY       = _ReferRegion.Y;
                _PatternInfo.CenterX            = _ReferRegion.CenterX;
                _PatternInfo.CenterY            = _ReferRegion.CenterY;
                _PatternInfo.Width              = _ReferRegion.Width;
                _PatternInfo.Height             = _ReferRegion.Height;
                _PatternInfo.OriginPointOffsetX = _OriginPointOffsetX;
                _PatternInfo.OriginPointOffsetY = _OriginPointOffsetY;
                bool PatternResult = InspPatternProcess.GetPatternReference(InspectionImage, _ReferRegion, _PointCenterX, _PointCenterY, ref _PatternInfo.Reference);


                if (PatternResult)
                {
                    ((CogPatternAlgo)InspParam.InspAreaParam[InspAreaSelected].InspAlgoParam[InspAlgoSelected].Algorithm).ReferenceInfoList[_Index] = _PatternInfo;
                }
            }

            //else if (_ReferAction == eReferAction.DEL)
            //{
            //    kpTeachDisplay.ClearDisplay("ReferRegion");
            //    kpTeachDisplay.ClearDisplay("ReferOriginPoint");

            //    ((CogPatternAlgo)InspParam.InspAreaParam[InspAreaSelected].InspAlgoParam[InspAlgoSelected].Algorithm).ReferenceInfoList.RemoveAt(_Index);
            //}

            GC.Collect();
        }
 /// <summary>
 /// Remove reference
 /// </summary>
 /// <param name="reference"></param>
 public void RemoveReference(ReferenceInformation reference)
 {
     this._listReference.Remove(reference);
 }
Beispiel #15
0
        protected override IDataProvider <EmbeddedObjectValue> CreateObjectEmbedDataProvider(ReferenceInformation refInfo, DbConnection connection)
        {
            var queryParameters = string.Join(" and ", refInfo.TargetPrimaryKeyColumns.Select((column, idx) => $"\"{QuoteColumn(column)}\" = :p{idx}"));
            var query           = $"select * from \"{QuoteTable(refInfo.SourceSchema, refInfo.SourceTableName)}\" where {queryParameters}";

            return(new SqlStatementProvider <EmbeddedObjectValue>(connection, query, specialColumns => GetColumns(specialColumns, refInfo.ForeignKeyColumns), reader =>
            {
                if (reader.Read() == false)
                {
                    // parent object is null
                    return new EmbeddedObjectValue();
                }

                return new EmbeddedObjectValue
                {
                    Object = ExtractFromReader(reader, refInfo.TargetDocumentColumns),
                    SpecialColumnsValues = ExtractFromReader(reader, refInfo.TargetSpecialColumnsNames),
                    Attachments = ExtractAttachments(reader, refInfo.TargetAttachmentColumns)
                };
            }));
        }
Beispiel #16
0
        protected override IDataProvider <EmbeddedArrayValue> CreateArrayEmbedDataProvider(ReferenceInformation refInfo, DbConnection connection)
        {
            var queryParameters = string.Join(" and ", refInfo.ForeignKeyColumns.Select((column, idx) => $"\"{QuoteColumn(column)}\" = :p{idx}"));

            var query = $"select * from \"{QuoteTable(refInfo.SourceSchema, refInfo.SourceTableName)}\" where {queryParameters}";

            return(new SqlStatementProvider <EmbeddedArrayValue>(connection, query, specialColumns => GetColumns(specialColumns, refInfo.SourcePrimaryKeyColumns), reader =>
            {
                var objectProperties = new DynamicJsonArray();
                var specialProperties = new List <DynamicJsonValue>();
                var attachments = new List <Dictionary <string, byte[]> >();
                while (reader.Read())
                {
                    objectProperties.Add(ExtractFromReader(reader, refInfo.TargetDocumentColumns));
                    attachments.Add(ExtractAttachments(reader, refInfo.TargetAttachmentColumns));

                    if (refInfo.ChildReferences != null)
                    {
                        // fill only when used
                        specialProperties.Add(ExtractFromReader(reader, refInfo.TargetSpecialColumnsNames));
                    }
                }

                return new EmbeddedArrayValue
                {
                    ArrayOfNestedObjects = objectProperties,
                    SpecialColumnsValues = specialProperties,
                    Attachments = attachments
                };
            }));
        }
 /// <summary>
 /// Add reference
 /// </summary>
 /// <param name="table"></param>
 public void AddReference(ReferenceInformation reference)
 {
     this._listReference.Add(reference);
 }