public void AccessDataModelServerSide() { IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg"); ModelNode modelNode = iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.AnIn1"); Assert.IsTrue(modelNode.GetType().Equals(typeof(DataObject))); modelNode = iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.AnIn1.mag.f"); Assert.IsTrue(modelNode.GetType().Equals(typeof(IEC61850.Server.DataAttribute))); Assert.IsNotNull(modelNode); }
public void AccessDataModelClientServer() { IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg"); ModelNode ind1 = iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.Ind1.stVal"); Assert.IsTrue(ind1.GetType().Equals(typeof(IEC61850.Server.DataAttribute))); IedServer iedServer = new IedServer(iedModel); iedServer.Start(10002); iedServer.UpdateBooleanAttributeValue((IEC61850.Server.DataAttribute)ind1, true); IedConnection connection = new IedConnection(); connection.Connect("localhost", 10002); bool stVal = connection.ReadBooleanValue("simpleIOGenericIO/GGIO1.Ind1.stVal", FunctionalConstraint.ST); Assert.IsTrue(stVal); iedServer.UpdateBooleanAttributeValue((IEC61850.Server.DataAttribute)ind1, false); stVal = connection.ReadBooleanValue("simpleIOGenericIO/GGIO1.Ind1.stVal", FunctionalConstraint.ST); Assert.IsFalse(stVal); connection.Abort(); iedServer.Stop(); iedServer.Destroy(); }
public void AccessDataModelServerSideNavigateModelNode() { IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg"); ModelNode modelNode = iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.AnIn1"); Assert.IsNotNull(modelNode); Assert.IsTrue(modelNode.GetType().Equals(typeof(DataObject))); var children = modelNode.GetChildren(); Assert.AreEqual(3, children.Count); ModelNode mag = children.First.Value; Assert.AreEqual("mag", mag.GetName()); ModelNode t = children.Last.Value; Assert.AreEqual("t", t.GetName()); //modelNode = iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.AnIn1.mag.f"); //Assert.IsTrue(modelNode.GetType().Equals(typeof(IEC61850.Server.DataAttribute))); }
public override void UpdateNode(ModelNode node) { var baseType = node.GetType().BaseType; Debug.Assert(baseType != null, "baseType != null"); var genericArgument = baseType.GetGenericArguments()[0]; if (genericArgument == typeof(TModelLogicRule)) { foreach (IModelClass modelClass in node.Application.BOModel) { var findAttributes = LogicRuleManager.FindAttributes(modelClass.TypeInfo); AddRules(node, findAttributes.OfType <TLogicRule>(), modelClass); } } }
private void button_Import_Click(object sender, EventArgs e) { if (!typeof(MT5Node).IsAssignableFrom(m_node.GetType())) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Supported files|*.obj"; if (openFileDialog.ShowDialog() == DialogResult.OK) { MT5Node mt5Node = (MT5Node)m_node; OBJ obj = new OBJ(openFileDialog.FileName); mt5Node.MeshData = new MT5Mesh(obj.RootNode, mt5Node); OnNodeChanged(this, null); } }
/// <summary> /// Sorts WMS folders before WMS layers. /// </summary> /// <param name="first"></param> /// <param name="second"></param> /// <returns></returns> internal static int SortWMSChildNodes(ModelNode first, ModelNode second) { if (first is WMSFolderModelNode) { if (second is WMSLayerModelNode) { return -1; } else if (second is WMSFolderModelNode) { return first.CompareTo(second); } else { throw new ApplicationException("Unexpected model node '" + second.GetType().ToString() + "'in WMS subree"); } } else if (first is WMSLayerModelNode) { if (second is WMSLayerModelNode) { return first.CompareTo(second); } else if (second is WMSFolderModelNode) { return 1; } else { throw new ApplicationException("Unexpected model node '" + second.GetType().ToString() + "'in WMS subree"); } } else { throw new ApplicationException("Unexpected model node '" + first.GetType().ToString() + "'in WMS subree"); } }
protected virtual void ReverseModel(ReverseContext context) { if (context.RootModelNode == null) { Type rootTargetType = null; ModelNode modelNode = null; ReverseHandlerBase rootHandler = null; var rootHost = context.ReverseHost; // manually reverse a single 'root' model node // update RequireSelfProcessing to false if (context.ReverseHost.GetType() == typeof(SiteReverseHost)) { rootTargetType = typeof(SiteDefinition); rootHandler = Handlers.First(h => h.ReverseType == rootTargetType); modelNode = rootHandler.ReverseSingleHost(rootHost, context.ReverseOptions); modelNode.Options.RequireSelfProcessing = false; } else if (context.ReverseHost.GetType() == typeof(WebReverseHost)) { rootTargetType = typeof(WebDefinition); rootHandler = Handlers.First(h => h.ReverseType == rootTargetType); modelNode = rootHandler.ReverseSingleHost(rootHost, context.ReverseOptions); modelNode.Options.RequireSelfProcessing = false; } context.RootModelNode = modelNode; context.CurrentModelNode = modelNode; InvokeOnReverseProgress(new ReverseProgressEventArgs { CurrentNode = modelNode, TargetType = modelNode.GetType(), ProcessedModelNodeCount = 1, TotalModelNodeCount = 1 }); } var defType = context.CurrentModelNode.Value.GetType(); if (!_localReverseDepth.ContainsKey(defType)) { _localReverseDepth.Add(defType, 0); } else { _localReverseDepth[defType] = _localReverseDepth[defType] + 1; } var shouldReverseSelfChildren = ShouldReverseChildren(context); var targetType = context.CurrentModelNode.Value.GetType(); var childHandlers = Handlers.Where(h => h.ReverseParentTypes.Any(t => t == targetType)) .ToList(); // prevent furver reverse of the same type if (!shouldReverseSelfChildren) { var selfHandler = childHandlers.FirstOrDefault(h => h.ReverseType == defType); if (selfHandler != null) { childHandlers.Remove(selfHandler); } } foreach (var handler in childHandlers) { var hosts = handler.ReverseHosts(context.ReverseHost, context.ReverseOptions); var count = 1; var totalCount = hosts.Count(); foreach (var host in hosts) { var modelNode = handler.ReverseSingleHost(host, context.ReverseOptions); context.CurrentModelNode.ChildModels.Add(modelNode); InvokeOnReverseProgress(new ReverseProgressEventArgs { CurrentNode = modelNode, TargetType = modelNode.GetType(), ProcessedModelNodeCount = count, TotalModelNodeCount = totalCount }); ReverseModel(new ReverseContext { ReverseOptions = context.ReverseOptions, CurrentModelNode = modelNode, ReverseHost = host, RootModelNode = context.RootModelNode }); count++; } } _localReverseDepth[defType] = _localReverseDepth[defType] - 1; }