Example #1
0
        public virtual ElementDescription ToElementDescription()
        {
            var toReturn = new ElementDescription();

            base.Fill(toReturn);

            if (Caption != null)
            {
                toReturn.Properties["Caption"] = Caption;
            }

            if (LayoutName != null)
            {
                toReturn.Properties["LayoutName"] = LayoutName;
            }

            string selectedCommandName = null;

            if (SelectedCommandNameOverride != null)
            {
                selectedCommandName = SelectedCommandNameOverride;
            }
            else if (SelectedCommand != null)
            {
                selectedCommandName = SelectedCommand.GetPropertyText();
            }

            if (selectedCommandName != null)
            {
                toReturn.Properties["SelectedCommand"] = string.Format("@MvxBind:{0}", selectedCommandName);
            }

            return(toReturn);
        }
Example #2
0
        public IElement Build(ElementDescription description)
        {
            if (description == null)
            {
                return(null);
            }

            var  key = string.IsNullOrEmpty(description.Key) ? DefaultElementKey : description.Key;
            Type type;

            if (!KnownElements.TryGetValue(key, out type))
            {
                throw new KeyNotFoundException("Could not find Element for " + description.Key);
            }

            var constructor = type.GetConstructors()
                              .FirstOrDefault(c => c.GetParameters().All(p => p.IsOptional));

            if (constructor == null)
            {
                throw new ArgumentException("No parameterless Constructor found for " + key);
            }
            //var parameters = constructor.GetParameters().Select(p => (object)Type.Missing).ToArray();
            var parameters = constructor.GetParameters().Select(p => (object)p.DefaultValue).ToArray();
            var instance   = constructor.Invoke(parameters);

            FillGroup(instance, description.Group);
            FillProperties(instance, description.Properties);
            FillSections(instance, description.Sections);

            return(instance as IElement);
        }
Example #3
0
        public virtual ElementDescription ToElementDescription()
        {
            var toReturn = new ElementDescription();

            base.Fill(toReturn);

            if (this.Caption != null)
            {
                toReturn.Properties["Caption"] = this.Caption;
            }

            if (this.LayoutName != null)
            {
                toReturn.Properties["LayoutName"] = this.LayoutName;
            }

            string selectedCommandName = null;

            if (this.SelectedCommandNameOverride != null)
            {
                selectedCommandName = this.SelectedCommandNameOverride;
            }
            else if (this.SelectedCommand != null)
            {
                selectedCommandName = this.SelectedCommand.GetPropertyText();
            }

            if (selectedCommandName != null)
            {
                toReturn.Properties["SelectedCommand"] = $"@MvxBind:{selectedCommandName}";
            }

            return(toReturn);
        }
Example #4
0
        private static ElementDescription GetElementDescription(Type type, ref int offset)
        {
            ElementDescription result = null;

            if (type == typeof(float))
            {
                result = new ElementDescription {
                    Format = Format.R32_SFloat, Offset = offset
                };
                offset += 4;
            }
            else if (type == typeof(Vector2))
            {
                result = new ElementDescription {
                    Format = Format.R32G32_SFloat, Offset = offset
                };
                offset += 8;
            }
            else if (type == typeof(Vector3))
            {
                result = new ElementDescription {
                    Format = Format.R32G32B32_SFloat, Offset = offset
                };
                offset += 12;
            }
            else if (type == typeof(Vector4))
            {
                result = new ElementDescription {
                    Format = Format.R32G32B32A32_SFloat, Offset = offset
                };
                offset += 16;
            }
            else if (type == typeof(Color4))
            {
                result = new ElementDescription {
                    Format = Format.R8G8B8A8_UNorm, Offset = offset
                };
                offset += 4;
            }
            else if (type == typeof(Mesh3D.BlendIndices))
            {
                result = new ElementDescription {
                    Format = Format.R32G32B32A32_SFloat, Offset = offset
                };
                offset += 16;
            }
            else if (type == typeof(Mesh3D.BlendWeights))
            {
                result = new ElementDescription {
                    Format = Format.R32G32B32A32_SFloat, Offset = offset
                };
                offset += 16;
            }
            return(result);
        }
Example #5
0
        private static ElementDescription GetElementDescription(Type type, ref int offset)
        {
            ElementDescription result = null;

            if (type == typeof(float))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.Float1, Offset = offset
                };
                offset += 4;
            }
            else if (type == typeof(Vector2))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.Float2, Offset = offset
                };
                offset += 8;
            }
            else if (type == typeof(Vector3))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.Float3, Offset = offset
                };
                offset += 12;
            }
            else if (type == typeof(Color4))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.UByte4Norm, Offset = offset
                };
                offset += 4;
            }
            else if (type == typeof(Mesh3D.BlendIndices))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.UByte4, Offset = offset
                };
                offset += 4;
            }
            else if (type == typeof(Mesh3D.BlendWeights))
            {
                result = new ElementDescription {
                    Format = VertexInputElementFormat.Float4, Offset = offset
                };
                offset += 16;
            }
            return(result);
        }
        private void printElementDescription(StreamWriter sw,
                                             String name,
                                             ElementDescription ed)
        {
            sw.Write("   <" + name + "-key>");
            sw.Write(ed.key);
            sw.Write("</" + name + "-key>");

            sw.Write("   <" + name + "-label>");
            sw.Write(ed.label);
            sw.Write("</" + name + "-label>");

            sw.Write("   <" + name + "-summary>");
            sw.Write(ed.summary);
            sw.Write("</" + name + "-summary>");
        }
Example #7
0
        private void getCounters(ManagedObjectReference perfMgr, VimService service)
        {
            Object property = getProperty(service, perfMgr, "perfCounter");

            PerfCounterInfo[] counters = (PerfCounterInfo[])property;
            //  PerfCounterInfo[] counters = arrayCounter.getPerfCounterInfo();
            Console.WriteLine("Performance counters (averages only):");
            Console.WriteLine("-------------------------------------");
            foreach (PerfCounterInfo counter in counters)
            {
                if (counter.rollupType == PerfSummaryType.average)
                {
                    ElementDescription desc = counter.nameInfo;
                    Console.WriteLine(desc.label + ": " + desc.summary);
                }
            }
            Console.WriteLine();
        }
 public static TRoot LoadDialogRoot <TElement, TRoot>(this IMvxAutoView view,
                                                      ElementDescription rootDescription)
 {
     return(view.LoadUserInterfaceFromDescription <TElement, TRoot>(rootDescription));
 }
Example #9
0
 public int AddElement(ElementDescription element)
 {
     mElements.Add(element);
     return(mElements.Count - 1);
 }
Example #10
0
 private static void RenderElement(Canvas parent, CompositeTransform textRotation, ElementDescription element)
 {
     switch (element.Type)
     {
         case ElementType.Circle:
             Ellipse e = new Ellipse()
             {
                 Width = element.Width,
                 Height = element.Height,
                 Fill = BrushForColor(element.Fill),
                 Stroke = BrushForColor(element.Stroke),
             };
             parent.Children.Add(e);
             Canvas.SetLeft(e, element.CenterX);
             Canvas.SetTop(e, element.CenterY);
             break;
         case ElementType.Path:
             Path path = new Path()
             {
                 Data = ProcessPathData(element.Path),
                 Tag = element.Text,
                 Fill = BrushForColor(element.Fill),
                 Stroke = BrushForColor(element.Stroke),
             };
             parent.Children.Add(path);
             break;
         case ElementType.Text:
             Grid g = new Grid() { Width = 200, Height = 200 };
             parent.Children.Add(g);
             Canvas.SetLeft(g, element.CenterX - g.Width / 2);
             Canvas.SetTop(g, element.CenterY - g.Height / 2);
             TextBlock tb = new TextBlock()
             {
                 HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                 VerticalAlignment = System.Windows.VerticalAlignment.Center,
                 RenderTransform = textRotation,
                 Foreground = BrushForColor(element.Stroke),
                 FontSize = element.FontSize,
                 Text = element.Text,
             };
             g.Children.Add(tb);
             break;
         default:
             throw new InvalidOperationException("Unexpected node: " + element.Type);
     }
 }
Example #11
0
        private IEnumerable<ElementDescription> ConvertToElements(Line l)
        {
            List<ElementDescription> ret = new List<ElementDescription>();

            ElementDescription ed = new ElementDescription();
            if (l.LayerDescription == "RM$")
            {
                ed.Parent = ParentType.Rooms;
            }
            else if (goodLayerPrefixes.Any(p => l.LayerDescription.StartsWith(p)))
            {
                ed.Parent = ParentType.Background;
            }
            else
            {
                return ret;
            }

            ed.Type = ElementType.Path;

            var fixedPt = FixPoint(new Point(l.CenterX, l.CenterY));
            ed.CenterX = fixedPt.X;
            ed.CenterY = fixedPt.Y;
            ed.Text = l.Text;

            ed.Width = (l.Width.HasValue ? double.Parse(l.Width.Value.ToString("F3")) : 0);
            ed.Height = (l.Height.HasValue ? double.Parse(l.Height.Value.ToString("F3")) : 0);
            ed.Path = Pathify(l.Geom);
            ed.Stroke = l.LineColor;
            ed.Fill = l.FillForegnd;
            ret.Add(ed);

            if (ed.Parent == ParentType.Rooms)
            {
                ed = new ElementDescription();
                ed.Parent = ParentType.Labels;
                ed.Type = ElementType.Text;
                ed.FontSize = 10;
                ed.CenterX = fixedPt.X + l.Width / 2;
                ed.CenterY = fixedPt.Y - l.Height / 2;
                ed.Text = l.Text;
                ret.Add(ed);
            }

            return ret;
        }
Example #12
0
        public static ElementDescription ParseSvgElement(XElement node2, String parentName)
        {
            ElementDescription ret = new ElementDescription();
            string name = node2.Name.LocalName;

            if (parentName.ToLowerInvariant() == "rooms".ToLowerInvariant())
            {
                ret.Parent = ParentType.Rooms;
            }
            else if (parentName.ToLowerInvariant() == "labels".ToLowerInvariant())
            {
                ret.Parent = ParentType.Labels;
            }
            else if (parentName.ToLowerInvariant() == "background".ToLowerInvariant())
            {
                ret.Parent = ParentType.Background;
            }
            else if (parentName.ToLowerInvariant() == "tooltip".ToLowerInvariant())
            {
                return null;
            }
            else
            {
                throw new ArgumentOutOfRangeException("Unexpected node type: " + parentName);
            }

            var styleParts = new Dictionary<string, string>();
            // Fill out some defaults
            styleParts["stroke"] = "black";
            styleParts["font-size"] = "11";
            styleParts["fill"] = "none";

            if (node2.Attribute("style") != null)
            {
                foreach (var part in node2.Attribute("style").Value.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).Select(p => p.Split(':')))
                {
                    styleParts[part[0]] = part[1];
                }
            }

            if (name == "circle")
            {
                ret.Type = ElementType.Circle;
                ret.Width = double.Parse(node2.Attribute("r").Value) * 2;
                ret.Height = double.Parse(node2.Attribute("r").Value) * 2;
                ret.Fill = styleParts["fill"];
                ret.Stroke = styleParts["stroke"];
                ret.CenterX = double.Parse(node2.Attribute("cx").Value);
                ret.CenterY = double.Parse(node2.Attribute("cy").Value);
            }
            else if (name == "path")
            {
                ret.Type = ElementType.Path;
                ret.IsHall = (node2.Attribute("desc") == null ? false : node2.Attribute("desc").Value.Contains("irculation"));
                ret.Stroke = styleParts["stroke"];
                if (ret.IsHall)
                {
                    ret.Fill = "lightgray";
                }
                else if (styleParts["fill"] != "none")
                {
                    ret.Fill = styleParts["fill"];
                }
                ret.Path = PathInfo.ProcessPathData(node2.Attribute("d").Value);

                if (node2.Attribute("id") != null)
                {
                    ret.Text = node2.Attribute("id").Value;
                }

                ret.elementBounds = BoundingRectangle.GetBoundsFromPath(ret.Path);
            }
            else if (name == "text")
            {
                ret.Type = ElementType.Text;
                ret.CenterX = double.Parse(node2.Attribute("x").Value);
                ret.CenterY = double.Parse(node2.Attribute("y").Value);
                ret.Stroke = styleParts["stroke"];
                ret.FontSize = double.Parse(styleParts["font-size"]);
                ret.Text = node2.Value;
            }
            else
            {
                throw new InvalidOperationException("Unexpected node: " + name);
            }

            return ret;
        }
 public ElementEntry(ElementDescription description, Object obj, Dictionary <string, Pin> elementPins)
 {
     this.description = description;
     this.obj         = obj;
     this.elementPins = elementPins;
 }
        private Transient.TransientModel GetTransientModel(
            List <ElementNode> elements,
            List <ConnectionNode> rootConnections,
            Object modelParameters)
        {
            Dictionary <string, ElementEntry> elementEntries = new Dictionary <string, ElementEntry>();
            int nodeIndicies = 0;

            Transient.TransientModel model = new Transient.TransientModel();
            foreach (var element in elements)
            {
                //get Object from element.Definition
                Object obj = BuildObject(element.Definition);

                if (!elementsMap.ContainsKey(obj.Name))
                {
                    errors.Add(new ErrorMessage($"Не существует элемента {obj.Name}", element.Line, element.Position));
                    continue;
                }
                //get Element description( nodes and parameters)
                ElementDescription description = elementsMap[obj.Name];

                Dictionary <string, Pin> elementPins = new Dictionary <string, Pin>();
                var keys = description.GetNodes();
                for (int i = 0; i < keys.Count; i++)
                {
                    string key = keys.ElementAt(i);
                    Pin    pin = description.CreatePin(key, nodeIndicies);
                    elementPins.Add(key, pin);
                    model.AddPin(pin);
                    nodeIndicies++;
                }
                //create element entry
                elementEntries.Add(element.Id, new ElementEntry(description, obj, elementPins));
                bool valid = description.Validate(ref obj, ref errors);
                if (valid)
                {
                    try
                    {
                        if (description.Validate(ref obj, ref errors))
                        {
                            ITransientElement modelElement = description.CreateTransientElement(obj, elementPins);
                            if (modelElement is null)
                            {
                                errors.Add(new ErrorMessage($"Элемент {obj.Name} не может использоваться для расчёта переходных процессов", element.Line, element.Position));
                            }
                            else
                            {
                                model.AddElement(modelElement);
                            }
                        }
                    }
                    catch (MissingValueException exc)
                    {
                        errors.Add(new ErrorMessage($"Отсутствует параметр {exc.Key} в элементе {obj.Name}", element.Line, element.Position));
                    }
                    catch (Exception)
                    {
                        errors.Add(new ErrorMessage($"Ошибка при создании элемента {obj.Name}", element.Line, element.Position));
                    }
                }
            }
            //resolve connections between elements
            List <Connection> connections = new List <Connection>();

            foreach (var connection in rootConnections)
            {
                try
                {
                    if (!elementEntries.ContainsKey(connection.Element1))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Element1} in connection", connection.Line, connection.Position));
                        continue;
                    }
                    if (!elementEntries.ContainsKey(connection.Element2))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Element2} in connection", connection.Line, connection.Position));
                        continue;
                    }
                    ElementEntry       entry1   = elementEntries[connection.Element1];
                    ElementEntry       entry2   = elementEntries[connection.Element2];
                    ElementDescription element1 = entry1.GetDescription();
                    ElementDescription element2 = entry2.GetDescription();
                    if (!element1.ContainsNode(connection.Node1))
                    {
                        errors.Add(new ErrorMessage($"Non existing pin {connection.Node1} in element {connection.Element1}", connection.Line, connection.Position));
                        continue;
                    }
                    if (!element2.ContainsNode(connection.Node2))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Node2} in element {connection.Element2}", connection.Line, connection.Position));
                        continue;
                    }
                    ElementDescription.NodeType node1 = element1.GetNodeType(connection.Node1);
                    ElementDescription.NodeType node2 = element2.GetNodeType(connection.Node2);
                    if (node1 != node2)
                    {
                        errors.Add(new ErrorMessage($"Pins in connection ({connection.Element1}.{connection.Node1},{connection.Element2}.{connection.Node2}) have different types", connection.Line, connection.Position));
                        continue;
                    }
                    connections.Add(new Connection(entry1.GetPin(connection.Node1), entry2.GetPin(connection.Node2)));
                }
                catch (Exception exc)
                {
                    throw exc;
                }
            }
            foreach (Connection connection in connections)
            {
                model.AddElement(connection.CreateTransientElement());
            }
            try
            {
                Object solver = (Object)Convert(modelParameters.GetValue("solver"), Constant.Type.Object);
                switch (solver.Name)
                {
                case "radauIIA5":
                {
                    FloatValue fAbsTol    = Convert(solver.GetValue("fAbsTol"), Constant.Type.Float) as FloatValue;
                    IntValue   iterations = Convert(solver.GetValue("iterations"), Constant.Type.Int) as IntValue;
                    FloatValue alpha      = Convert(solver.GetValue("alpha"), Constant.Type.Float) as FloatValue;
                    FloatValue step       = Convert(solver.GetValue("step"), Constant.Type.Float) as FloatValue;
                    model.SetSolver(new Equations.DAE.Implicit.RADAUIIA5(fAbsTol.Value, iterations.Value, alpha.Value, step.Value));
                }
                break;

                case "radauIIA3":
                {
                    FloatValue fAbsTol    = Convert(solver.GetValue("fAbsTol"), Constant.Type.Float) as FloatValue;
                    IntValue   iterations = Convert(solver.GetValue("iterations"), Constant.Type.Int) as IntValue;
                    FloatValue alpha      = Convert(solver.GetValue("alpha"), Constant.Type.Float) as FloatValue;
                    FloatValue step       = Convert(solver.GetValue("step"), Constant.Type.Float) as FloatValue;
                    model.SetSolver(new Equations.DAE.Implicit.RADAUIIA3(fAbsTol.Value, iterations.Value, alpha.Value, step.Value));
                }
                break;

                case "bdf1":
                {
                    FloatValue fAbsTol    = Convert(solver.GetValue("fAbsTol"), Constant.Type.Float) as FloatValue;
                    IntValue   iterations = Convert(solver.GetValue("iterations"), Constant.Type.Int) as IntValue;
                    FloatValue alpha      = Convert(solver.GetValue("alpha"), Constant.Type.Float) as FloatValue;
                    FloatValue step       = Convert(solver.GetValue("step"), Constant.Type.Float) as FloatValue;
                    model.SetSolver(new Equations.DAE.Implicit.BDF1(fAbsTol.Value, iterations.Value, alpha.Value, step.Value));
                }
                break;

                default:
                    errors.Add(new ErrorMessage("Unknown solver in transient model"));
                    return(null);
                }
                FloatValue t0 = Convert(modelParameters.GetValue("t0"), Constant.Type.Float) as FloatValue;
                FloatValue t1 = Convert(modelParameters.GetValue("t1"), Constant.Type.Float) as FloatValue;
                model.SetT0(t0.Value);
                model.SetT1(t1.Value);
            }
            catch (MissingValueException exc)
            {
                errors.Add(new ErrorMessage($"Отсутствует аргумент {exc.Key} в определении модели."));
                return(null);
            }
            catch (Exception exc)
            {
                errors.Add(new ErrorMessage($"Exception: {exc.Message}"));
                return(null);
            }
            return(model);
        }
Example #15
0
        public RequestAssignedBaselineResponse RequestAssignedBaseline(RequestAssignedBaselineRequest request)
        {
            RequestAssignedBaselineResponse lResponse = new RequestAssignedBaselineResponse();

            lResponse.Result  = ResultEnumType.Failure;
            lResponse.Version = "";

            try
            {
                using (RemoteDataStoreProxy lRemDSProxy = new RemoteDataStoreProxy())
                {
                    try
                    {
                        DataContainer      baselinesDef = lRemDSProxy.getElementBaselinesDefinitions(request.ElementId);
                        ElementDescription elemDescr    = DataTypeConversion.fromDataContainerToElementDescription(baselinesDef);

                        if (request.Current)
                        {
                            lResponse.Version        = lRemDSProxy.getAssignedCurrentBaselineVersion(request.ElementId);
                            lResponse.ActivationDate = DateTime.Now;
                            lResponse.ExpirationDate = elemDescr.AssignedCurrentBaselineExpirationDate;
                        }
                        else
                        {
                            lResponse.Version        = lRemDSProxy.getAssignedFutureBaselineVersion(request.ElementId);
                            lResponse.ActivationDate = elemDescr.AssignedFutureBaselineActivationDate;
                            lResponse.ExpirationDate = elemDescr.AssignedFutureBaselineExpirationDate;
                        }

                        lResponse.Result = ResultEnumType.Success;

                        DataPackageService   lDataPackageService = new DataPackageService();
                        DataPackageErrorEnum lResult             = lDataPackageService.distributeTargetedBaseline(request.ElementId, lResponse.Version, lResponse.ActivationDate, lResponse.ExpirationDate);

                        switch (lResult)
                        {
                        case DataPackageErrorEnum.REQUEST_ACCEPTED:
                            lResponse.Result = ResultEnumType.Success;
                            break;

                        case DataPackageErrorEnum.REMOTEDATASTORE_NOT_ACCESSIBLE:
                            lResponse.Result = ResultEnumType.RemoteDataStoreNotAccessible;
                            break;

                        case DataPackageErrorEnum.ELEMENT_ID_NOT_FOUND:
                            lResponse.Result = ResultEnumType.InvalidElementId;
                            break;

                        case DataPackageErrorEnum.BASELINE_NOT_FOUND:
                            lResponse.Result = ResultEnumType.BaselineNotFound;
                            break;

                        case DataPackageErrorEnum.DATA_PACKAGE_NOT_FOUND:
                            lResponse.Result = ResultEnumType.PackageNotFound;
                            break;

                        default:
                            lResponse.Result = ResultEnumType.Failure;
                            break;
                        }
                    }
                    catch (FaultException fe)
                    {
                        if (fe.Code.Name == "UNKNOWN_ELEMENT_ID" || fe.Code.Name == "INVALID_ELEMENT_ID")
                        {
                            lResponse.Result = ResultEnumType.InvalidElementId;
                        }
                        else
                        {
                            PIS.Ground.Core.LogMgmt.LogManager.WriteLog(PIS.Ground.Core.Data.TraceType.EXCEPTION, "Element ID : " + request.ElementId + ". Error Code : " + fe.Code.Name + ". Error Message : " + fe.Message
                                                                        , "PIS.Ground.DataPackage.DataPackageSyncGroundService.RequestAssignedbaseline"
                                                                        , fe, PIS.Ground.Core.Data.EventIdEnum.DataPackage);
                            lResponse.Result = ResultEnumType.Failure;
                        }
                    }
                    finally
                    {
                        if (lRemDSProxy.State == CommunicationState.Faulted)
                        {
                            lRemDSProxy.Abort();
                        }
                    }
                }
            }
            catch (TimeoutException)
            {
                lResponse.Result = ResultEnumType.RemoteDataStoreNotAccessible;
            }
            catch (CommunicationException)
            {
                lResponse.Result = ResultEnumType.RemoteDataStoreNotAccessible;
            }

            return(lResponse);
        }
  private void printElementDescription(StreamWriter sw, 
                                      String name, 
                                      ElementDescription ed) {
     sw.Write("   <"+ name + "-key>");
     sw.Write(ed.key);
     sw.Write("</" + name + "-key>");
    
     sw.Write("   <"+ name + "-label>");
     sw.Write(ed.label);
     sw.Write("</" + name + "-label>");
 
     sw.Write("   <"+ name + "-summary>");
     sw.Write(ed.summary);
     sw.Write("</" + name + "-summary>");
  }
        private SteadyStateModel GetSteadyStateModel(
            List <ElementNode> elements,
            List <ConnectionNode> rootConnections,
            Object modelParameters)
        {
            Dictionary <string, ElementEntry> elementEntries = new Dictionary <string, ElementEntry>();
            int nodeIndicies       = 0;
            SteadyStateModel model = new SteadyStateModel();

            foreach (var element in elements)
            {
                //get Object from element.Definition
                Object obj = BuildObject(element.Definition);

                //get Element description( nodes and parameters)
                if (!elementsMap.ContainsKey(obj.Name))
                {
                    errors.Add(new ErrorMessage($"Не существует элемента {obj.Name}", element.Line, element.Position));
                    continue;
                }
                ElementDescription description = elementsMap[obj.Name];

                Dictionary <string, Pin> elementPins = new Dictionary <string, Pin>();
                var keys = description.GetNodes();
                for (int i = 0; i < keys.Count; i++)
                {
                    string key = keys.ElementAt(i);
                    Pin    pin = description.CreatePin(key, nodeIndicies);
                    elementPins.Add(key, pin);
                    model.AddPin(pin);
                    nodeIndicies++;
                }
                //create element entry
                elementEntries.Add(element.Id, new ElementEntry(description, obj, elementPins));
                bool valid = description.Validate(ref obj, ref errors);
                if (valid)
                {
                    try
                    {
                        if (description.Validate(ref obj, ref errors))
                        {
                            ISteadyStateElement modelElement = description.CreateSteadyStateElement(obj, elementPins);
                            if (modelElement is null)
                            {
                                errors.Add(new ErrorMessage($"Element {obj.Name} cannot be used in steady state model", element.Line, element.Position));
                            }
                            else
                            {
                                model.AddElement(modelElement);
                            }
                        }
                    }
                    catch (MissingValueException exc)
                    {
                        errors.Add(new ErrorMessage($"Missing parameter {exc.Key} in element {obj.Name}", element.Line, element.Position));
                    }
                    catch (Exception exc)
                    {
                        errors.Add(new ErrorMessage($"Ошибка при создании элемента {obj.Name}: {exc.Message}", element.Line, element.Position));
                    }
                }
            }
            //resolve connections between elements
            List <Connection> connections = new List <Connection>();

            foreach (var connection in rootConnections)
            {
                try
                {
                    if (!elementEntries.ContainsKey(connection.Element1))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Element1} in connection", connection.Line, connection.Position));
                        continue;
                    }
                    if (!elementEntries.ContainsKey(connection.Element2))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Element2} in connection", connection.Line, connection.Position));
                        continue;
                    }
                    ElementEntry       entry1   = elementEntries[connection.Element1];
                    ElementEntry       entry2   = elementEntries[connection.Element2];
                    ElementDescription element1 = entry1.GetDescription();
                    ElementDescription element2 = entry2.GetDescription();
                    if (!element1.ContainsNode(connection.Node1))
                    {
                        errors.Add(new ErrorMessage($"Non existing pin {connection.Node1} in element {connection.Element1}", connection.Line, connection.Position));
                        continue;
                    }
                    if (!element2.ContainsNode(connection.Node2))
                    {
                        errors.Add(new ErrorMessage($"Non existing element {connection.Node2} in element {connection.Element2}", connection.Line, connection.Position));
                        continue;
                    }
                    ElementDescription.NodeType node1 = element1.GetNodeType(connection.Node1);
                    ElementDescription.NodeType node2 = element2.GetNodeType(connection.Node2);
                    if (node1 != node2)
                    {
                        errors.Add(new ErrorMessage($"Pins in connection ({connection.Element1}.{connection.Node1},{connection.Element2}.{connection.Node2}) have different types", connection.Line, connection.Position));
                        continue;
                    }
                    connections.Add(new Connection(entry1.GetPin(connection.Node1), entry2.GetPin(connection.Node2)));
                }
                catch (Exception exc)
                {
                    throw exc;
                }
            }
            foreach (Connection connection in connections)
            {
                model.AddElement(connection.CreateSteadyStateElement());
            }
            try
            {
                Object solver = (Object)Convert(modelParameters.GetValue("solver"), Constant.Type.Object);
                switch (solver.Name)
                {
                case "newton":
                    FloatValue fAbsTol    = Convert(solver.GetValue("fAbsTol"), Constant.Type.Float) as FloatValue;
                    IntValue   iterations = Convert(solver.GetValue("iterations"), Constant.Type.Int) as IntValue;
                    FloatValue alpha      = Convert(solver.GetValue("alpha"), Constant.Type.Float) as FloatValue;
                    model.SetSolver(new SteadyStateNewtonSolver(fAbsTol.Value, iterations.Value, alpha.Value));
                    break;

                default:
                    errors.Add(new ErrorMessage("Unknown solver in steadystate model"));
                    return(null);
                }
                FloatValue baseFrequency = (FloatValue)Convert(modelParameters.GetValue("baseFrequency"), Constant.Type.Float);
                model.SetBaseFrequency(baseFrequency.Value);
            }
            catch (MissingValueException exc)
            {
                errors.Add(new ErrorMessage($"Отсутствует аргумент {exc.Key} в определении модели."));
                return(null);
            }
            catch (Exception exc)
            {
                errors.Add(new ErrorMessage($"Exception: {exc.Message}"));
                return(null);
            }
            return(model);
        }