public Mapping2Component(string _name, Component.Component _calculator, Dictionary <long, long> _input_mapping, Dictionary <long, long> _output_mapping)
 {
     this.Name           = _name;
     this.Calculator     = _calculator;
     this.input_mapping  = _input_mapping;
     this.output_mapping = _output_mapping;
 }
Example #2
0
 private static void PrintComponentLogs(
     Component.Component component,
     bool printMessages,
     bool printWarnings,
     bool printErrors,
     string indent)
 {
     PrintLogs(component.Messages, printMessages, indent);
     PrintLogs(component.Warnings, printWarnings, indent);
     PrintLogs(component.Errors, printErrors, indent);
 }
Example #3
0
        public Rule.Rule rule;                  //the rule, which manage the matching

        /// <summary>
        /// Mtch(gr, _rule) - check if Group gr is in match with rule
        ///    if Mtch.ok.Match - return Mtch.Component chousen from CompSet.Component
        ///    else ok.NoMatch
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="_rule"></param>
        public Mtch(ElmAttSet.Group gr, Rule.Rule _rule)
        {
            if (gr.prf.Contains("ш2") /* && _rule.text.Contains("д") */)
            {
                rule = _rule;
            }


            if (gr == null || gr.guids.Count < 1)
            {
                return;
            }
            ok    = OK.NoMatch;
            group = gr;
            foreach (var comp in _rule.CompSet.Components)
            {
                if (!comp.isMatch(gr, _rule))
                {
                    continue;
                }
                //-- Component is found - fill Price for all Guids elemets
                ok            = OK.Match;
                component     = comp;
                gr.match      = this; //27/3!!
                rule          = _rule;
                gr.totalPrice = 0;
                foreach (var id in gr.guids)
                {
                    Elm    elm      = gr.Elements[id];
                    string priceStr = comp.Str(SType.Price);
                    double price    = getPrice(elm, rule.CompSet.csDP, priceStr);
                    gr.Elements[id].price = price;
                    gr.totalPrice        += price;
                }
                break;
            }
        }
Example #4
0
        /// <summary>
        /// Mtch(gr, _rule) - check if Group gr is in match with rule
        ///    if Mtch.ok.Match - return Mtch.Component chousen from CompSet.Component
        ///    else ok.NoMatch
        /// </summary>
        /// <param name="gr"></param>
        /// <param name="_rule"></param>
        public Mtch(Group.Group gr, Rule.Rule _rule)
        {
            if (gr == null || gr.guids == null || gr.guids.Count < 1)
                Msg.F("Matcher__Mtch Bad arguments");
            ok = OK.NoMatch;
            group = gr;
            foreach (var comp in _rule.CompSet.Components)
            {
                bool found = false;
                try { found = comp.isMatch(gr, _rule); }
                catch { }
                if (!found) continue;
                //-- Component is found - fill Price for all Guids elemets
                ok = OK.Match;
                string priceStr;
                try { priceStr = comp.Str(SType.Price); }
                catch { Msg.F("Match: Bad Price descriptor", _rule.sSupl, _rule.sCS); }
                component = comp;
//29/8                gr.match = this;    //27/3!!
                rule = _rule;
                gr.totalPrice = getPrice(gr, rule.CompSet.csDP, comp.Str(SType.Price));
                break;
            }
        }
Example #5
0
 public void AddComponent(Component.Component component)
 {
     Components.Add(component.GetType(), component);
 }
Example #6
0
 public Log(string text, Component.Component parent)
 {
     Text   = text;
     Parent = parent;
 }
Example #7
0
 public Error(string text, Component.Component parent) : base(text, parent)
 {
 }
Example #8
0
        public static StructureNode CreateFrom(Component.Component _node_source, StructureNode _sn_parent)
        {
            if (_node_source == null)
            {
                return(null);
            }

            // create the node
            StructureNode node = new StructureNode();

            // content
            node.IDAsLong         = _node_source.ID;
            node.IDAsLong_Used    = true;
            node.ContentType      = typeof(Component.Component);
            node.ContentType_Used = true;

            // structure
            if (_sn_parent != null)
            {
                // the parent has to be a component
                if (!_sn_parent.ContentType_Used || _sn_parent.ContentType == null)
                {
                    return(null);
                }
                if (_sn_parent.ContentType != typeof(Component.Component))
                {
                    return(null);
                }
                // no self-parenting
                if (_sn_parent.IDAsLong == _node_source.ID)
                {
                    return(null);
                }

                node.ParentNode = _sn_parent;
            }

            foreach (var entry in _node_source.ContainedParameters)
            {
                Parameter.Parameter p = entry.Value;
                if (p == null)
                {
                    continue;
                }

                StructureNode p_sn = StructureNode.CreateFrom(p, node);
                if (p_sn != null)
                {
                    node.children_nodes.Add(p_sn);
                }
            }

            foreach (GeometricRelationship gr in _node_source.R2GInstances)
            {
                StructureNode gr_sn = StructureNode.CreateFrom(gr, node);
                if (gr_sn != null)
                {
                    node.children_nodes.Add(gr_sn);
                }
            }

            // recursion
            foreach (var entry in _node_source.ContainedComponents)
            {
                Component.Component sC = entry.Value;
                if (sC == null)
                {
                    continue;
                }

                StructureNode sC_sn = StructureNode.CreateFrom(sC, node);
                if (sC_sn != null)
                {
                    node.children_nodes.Add(sC_sn);
                }
            }

            return(node);
        }
Example #9
0
        public Point3DContainer FindSinglePointMatchIn(List <Component.Component> _comps, out Component.Component _comp_parent)
        {
            _comp_parent = null;
            if (_comps == null || _comps.Count == 0)
            {
                return(null);
            }

            List <Component.Component> flat_list = Component.Component.GetFlattenedListOf(_comps);

            foreach (Component.Component c in flat_list)
            {
                foreach (GeometricRelationship gr in c.R2GInstances)
                {
                    List <HierarchicalContainer> geometry = gr.GeometricContent;
                    if (geometry == null || geometry.Count == 0)
                    {
                        continue;
                    }

                    foreach (HierarchicalContainer hc in geometry)
                    {
                        Point3DContainer p3dc = hc as Point3DContainer;
                        if (p3dc == null)
                        {
                            continue;
                        }

                        StructureNode match = this.FindMatchFor(p3dc.ID_primary, p3dc.ID_secondary, -1, string.Empty, typeof(ParameterStructure.Geometry.Point3DContainer));
                        if (match != null)
                        {
                            _comp_parent = c;
                            return(p3dc);
                        }
                    }
                }
            }

            return(null);
        }
Example #10
0
        public GeometricRelationship FindGeomRelationshipMatchIn(List <Component.Component> _comps, out Component.Component _comp_parent)
        {
            _comp_parent = null;
            if (_comps == null || _comps.Count == 0)
            {
                return(null);
            }

            List <Component.Component> flat_list = Component.Component.GetFlattenedListOf(_comps);

            foreach (Component.Component c in flat_list)
            {
                foreach (GeometricRelationship gr in c.R2GInstances)
                {
                    StructureNode match = this.FindMatchFor(gr.ID, -1, -1, string.Empty, typeof(ParameterStructure.Geometry.GeometricRelationship));
                    if (match != null)
                    {
                        _comp_parent = c;
                        return(gr);
                    }
                }
            }

            return(null);
        }
Example #11
0
        public Parameter.Parameter FindParameterMatchIn(List <Component.Component> _comps, out Component.Component _comp_parent)
        {
            _comp_parent = null;
            if (_comps == null || _comps.Count == 0)
            {
                return(null);
            }

            List <Component.Component> flat_list = Component.Component.GetFlattenedListOf(_comps);

            foreach (Component.Component c in flat_list)
            {
                foreach (var entry in c.ContainedParameters)
                {
                    Parameter.Parameter p = entry.Value;
                    if (p == null)
                    {
                        continue;
                    }

                    StructureNode match = this.FindMatchFor(p.ID, -1, -1, p.Name, typeof(ParameterStructure.Parameter.Parameter));
                    if (match != null)
                    {
                        _comp_parent = c;
                        return(p);
                    }
                }
            }

            return(null);
        }
Example #12
0
 public Message(string text, Component.Component parent, MessageImportance importance) : base(text, parent)
 {
     Importance = importance;
 }
Example #13
0
 public Warning(string text, Component.Component parent) : base(text, parent)
 {
 }