internal void NodeOnPathFinderTest() { Graph <BasicNode> g = new Graph <BasicNode>(); BasicNode u = new BasicNode("u"); BasicNode v = new BasicNode("v"); BasicNode w = new BasicNode("w"); BasicNode x = new BasicNode("x"); BasicNode y = new BasicNode("y"); BasicNode z = new BasicNode("z"); g.Nodes.Add(u); g.Nodes.Add(v); g.Nodes.Add(w); g.Nodes.Add(x); g.Nodes.Add(y); g.Nodes.Add(z); g.AddEdge(u, v); g.AddEdge(v, w); g.AddEdge(w, x); g.AddEdge(x, v); g.AddEdge(v, y); g.AddEdge(v, z); g.AddEdge(z, u); var nodesOnPath = new HashSet <BasicNode>(); var pf = new NodeOnPathFinder <BasicNode>(g.TargetsOf, g, MakeIndexedProperty.FromSet(nodesOnPath), node => node.Data.Equals("z")); pf.SearchFrom(u); Console.Write("nodes on path: "); Console.WriteLine(StringUtil.CollectionToString(nodesOnPath, " ")); }
public BasicNode Run() { if (lines == null) { return(null); } Stopwatch watch = Stopwatch.StartNew(); BasicNode result = null; try { while (true) { result = Step(); if (runtimeError != null) { return(runtimeError); } if (result.IsAbort()) { return(result); } } } finally { WriteRunCompleteMessage(watch, result); } }
public SpecialMethodCallNode(string methodName, BasicNode where, List <BasicNode> args) : base(new CommonToken(0, "SpecialMethodCall")) { this.methodName = methodName; this.where = where; this.args = args; }
public CallvirtNode(MethodInfo method, BasicNode where, List <ExpressionNode> args) : base(new CommonToken(-1, "Callvirt")) { Method = method; Where = where; Args = args; }
private bool InternalStepOver() { if (breakLines.Contains(Runtime.NextLineToExecute)) { if (!IgnoreNextBreakpoint) { //BreakpointEncountered?.Invoke(this, Runtime.NextLineToExecute); State = DebuggerState.Breaked; return(false); } } IgnoreNextBreakpoint = false; Result = Runtime.Step(); if (Runtime.HasEnded || Result.IsAbort()) { State = DebuggerState.CompletedOK; } if (Runtime.LastError != null) { State = DebuggerState.CompletedWithError; } if (State >= DebuggerState.CompletedOK) { // Runtime.WriteRunCompleteMessage(watch, Result); //ExecutionComplete?.Invoke(this); } return(State < DebuggerState.CompletedOK); }
internal static Graph <BasicNode> WestGraph() { // this is the example graph in West sec 7.3.21 Graph <BasicNode> g = new Graph <BasicNode>(); BasicNode u = new BasicNode("u"); BasicNode v = new BasicNode("v"); BasicNode w = new BasicNode("w"); BasicNode x = new BasicNode("x"); BasicNode y = new BasicNode("y"); BasicNode z = new BasicNode("z"); g.Nodes.Add(u); g.Nodes.Add(v); g.Nodes.Add(w); g.Nodes.Add(x); g.Nodes.Add(y); g.Nodes.Add(z); g.AddEdge(u, v); g.AddEdge(v, w); g.AddEdge(w, x); g.AddEdge(w, y); g.AddEdge(x, u); g.AddEdge(x, y); g.AddEdge(y, z); g.AddEdge(z, u); g.AddEdge(z, v); return(g); }
public void WriteRunCompleteMessage(Stopwatch watch, BasicNode result) { if (WriteCompileRunMessage) { printer.WriteMessage($"=== {ExecutedLineCount:###,##0} lines with {InstructionCount:###,###,##0} instructions executed in {watch.ElapsedMilliseconds} ms ==="); } }
public static void CreateOne(SimioAPI.IIntelligentObjects intelligentObjects, int x, int y) { BasicNode point1 = new BasicNode(intelligentObjects, x, y + 10), point2 = new BasicNode(intelligentObjects, x + 10, y), point3 = new BasicNode(intelligentObjects, x + 10, y + 40); new Path(intelligentObjects, point1.GetInput(), point2.GetInput()); new Path(intelligentObjects, point2.GetInput(), point3.GetInput()); }
internal void PathFinderTest() { var g = WestGraph(); BasicNode u = g.Nodes.Where(node => (string)node.Data == "u").First(); PathFinder <BasicNode> pf = new PathFinder <BasicNode>(g); pf.AddNode += delegate(BasicNode node) { Console.Write(" " + node); }; pf.BeginPath += delegate() { Console.Write("["); }; pf.EndPath += delegate() { Console.Write("]"); }; pf.SearchFrom(u); Console.WriteLine(); }
List <int> Bfs(BasicNode startNode, BasicGraph graph) { var _minCycle = Inf; var _distances = Enumerable.Repeat(Inf, graph.NodeCount).ToArray(); var _previous = Enumerable.Repeat(-1, graph.NodeCount).ToArray(); _distances[startNode.Index] = 0; var todo = new Queue <BasicNode>(); todo.Enqueue(startNode); var completed = false; while (todo.Count > 0 && !completed) { var current = todo.Dequeue(); foreach (var edge in graph[current]) { var next = edge.To; var nextDistance = _distances[current.Index] + 1; if (_distances[next.Index] == 0) { _previous[next.Index] = current.Index; _minCycle = nextDistance; completed = true; } else if (_distances[next.Index] == Inf) { _previous[next.Index] = current.Index; _distances[next.Index] = nextDistance; todo.Enqueue(next); } } } if (_minCycle != Inf) { var nodes = new List <int>(); var node = startNode; for (int i = 0; i < _minCycle; i++) { var previous = new BasicNode(_previous[node.Index]); nodes.Add(previous.Index); node = previous; } return(nodes); } else { return(null); } }
protected void Log(string message, BasicNode node, LogLevel logLevel = LogLevel.Error) { if (logLevel == LogLevel.Error) { Error = true; } if (node != null) { message = string.Format("{0}, строка {1}", message, node.Line); } logger.Log(message, logLevel); }
public static void CreateFive(SimioAPI.IIntelligentObjects intelligentObjects, int x, int y) { BasicNode point1 = new BasicNode(intelligentObjects, x, y), point2 = new BasicNode(intelligentObjects, x + 30, y), point3 = new BasicNode(intelligentObjects, x, y + 20), point4 = new BasicNode(intelligentObjects, x + 30, y + 20), point5 = new BasicNode(intelligentObjects, x + 30, y + 40), point6 = new BasicNode(intelligentObjects, x, y + 40); new Path(intelligentObjects, point2.GetInput(), point1.GetInput()); new Path(intelligentObjects, point1.GetInput(), point3.GetInput()); new Path(intelligentObjects, point3.GetInput(), point4.GetInput()); new Path(intelligentObjects, point4.GetInput(), point5.GetInput()); new Path(intelligentObjects, point5.GetInput(), point6.GetInput()); }
void EularTour(BasicNode current, BasicNode before, int depth) { firstIndices[current.Index] = depthAndIndices.Count; depthAndIndices.Add(new DepthAndIndex(depth, current.Index)); depthes[current.Index] = depth; foreach (var edges in tree[current.Index]) { if (edges.To == before) { continue; } EularTour(edges.To, current, depth + 1); depthAndIndices.Add(new DepthAndIndex(depth, current.Index)); } }
static ProperNode CreateNodeTree(BasicNode[] nodeList, BasicNode root) { var nodeDict = nodeList.ToDictionary(node => node.Name, node => node); ProperNode createTree(BasicNode node) { var subNodes = node.SubNodes.Select(nodeName => createTree(nodeDict.GetValueOrDefault(nodeName))); return(new ProperNode { Name = node.Name, Weight = node.Weight, TotalWeight = node.Weight + subNodes.Sum(n => n.TotalWeight), SubNodes = subNodes.ToList() }); } return(createTree(root)); }
private void SetUpBaseTopology() { BasicInputLayer input = new BasicInputLayer(); input.ValueIndexes = new int[] { 0, 1, 2, 3 }; baseTopology.InputLayer = input; baseTopology.OutputLayer = new BasicOutputLayer(); baseTopology.PreProcessor = objectFactory["TestBinary"]. CreateUserObject <IPreProcessor>( "BasicPreProcessor", new Dictionary <string, string>()); baseTopology.PostProcessor = objectFactory["TestBinary"]. CreateUserObject <IPostProcessor>( "BasicPostProcessor", new Dictionary <string, string>()); BasicNode[][] nodes = new BasicNode[2][]; nodes[0] = new BasicNode[3]; nodes[1] = new BasicNode[3]; for (int i = 0; i < 3; i++) { nodes[0][i] = new BasicNode( new float[] { 0.4f, 0.3f, 0.2f, 0.6f }, SigmoidFunctions.Logistic); nodes[1][i] = new BasicNode( new float[] { 0.4f, 0.3f, 0.2f }, SigmoidFunctions.Logistic); } baseTopology.HiddenLayers = new BasicLayer[] { new BasicLayer(nodes[0]), new BasicLayer(nodes[1]) }; baseTopology.TrainingAlgorithm = new HillClimbAlgo(); baseTopology.TrainingPreProcessor = objectFactory["TestBinary"]. CreateUserObject <ITrainingPreProcessor>( "BasicPreProcessor", new Dictionary <string, string>()); }
static void Main() { var rt = new CompoundNode("root"); for (int i = 0; i < 5; i++) { var elt = new BasicNode("elt" + (i + 1), "val" + (i + 1)); rt.Add(elt); } var rtt = new CompoundNode("sub"); for (int i = 0; i < 5; i++) { var elt = new BasicNode("eltSub" + (i + 1), "valSub" + (i + 1)); rtt.Add(elt); } rt.Add(rtt); Console.WriteLine(rt.Print(-41)); Console.ReadKey(); }
public MethodCallNode(string name, BasicNode where, List <BasicNode> args) : base(new CommonToken(0, "MethodCall")) { var node = new BasicNode(new CommonToken(0, name)); this.InsertChild(0, node); node.Parent = this; var argsNode = new BasicNode(new CommonToken(0, "Args")); this.InsertChild(1, argsNode); argsNode.Parent = this; for (int i = 0; i < args.Count; i++) { argsNode.InsertChild(i, args[i]); args[i].Parent = argsNode; } this.InsertChild(2, where); where.Parent = this; }
//Creates a BasicNode for the body part joint, the node lasts timeToFinish seconds, at position spawnPosition public GameObject CreateBasicNode(Joint joint, float timeToFinish, Vector3 spawnPositon) { switch (joint) { case Joint.RightHand: nodeInstance = Object.Instantiate(nodePrefabBRH, spawnPositon, Quaternion.Euler(0, 0, 0)); break; case Joint.LeftHand: nodeInstance = Object.Instantiate(nodePrefabBLH, spawnPositon, Quaternion.Euler(0, 0, 0)); break; default: Debug.Log("Error"); break; } BasicNode obj = nodeInstance.GetComponent <BasicNode>(); obj.timeToFinish = timeToFinish; obj.transform.parent = main.transform; return(nodeInstance); }
private void EditRouter_Load(object sender, EventArgs e) { this.MaximumSize = new Size(254, 308); this.MinimumSize = new Size(254, 308); if (null == StrRouterID || "".Equals(StrRouterID)) { RID_1TB.Text = "00"; RID_2TB.Text = "00"; NodeTypeCB.SelectedIndex = 0; } else { RID_1TB.Text = StrRouterID.Substring(0, 2); RID_2TB.Text = StrRouterID.Substring(2, 2); if (1 == type) { NodeTypeCB.SelectedIndex = 1; BasicNode MyBasicNode = null; area.AreaNode.TryGetValue(StrRouterID, out MyBasicNode); if (null != MyBasicNode) { RouterVisibleCB.Checked = MyBasicNode.isVisible; ReferNameTB.Text = MyBasicNode.Name; } } else { NodeTypeCB.SelectedIndex = 0; BasicRouter MyBasicRouter = null; area.AreaRouter.TryGetValue(StrRouterID, out MyBasicRouter); if (null != MyBasicRouter) { RouterVisibleCB.Checked = MyBasicRouter.isVisible; ReferNameTB.Text = MyBasicRouter.Name; } } } }
public static List <BasicNode> GetCoordanates(SimioAPI.IIntelligentObjects intelligentObjects) { List <BasicNode> list = new List <BasicNode>(); var csvTable = new DataTable(); using (var csvReader = new CsvReader(new StringReader(FileStore.Resource.Coordinates), true)) { csvTable.Load(csvReader); } BasicNode basicNode; for (int i = 0; i < csvTable.Rows.Count; i++) { basicNode = new BasicNode( intelligentObjects, int.Parse(csvTable.Rows[i][0].ToString()), int.Parse(csvTable.Rows[i][1].ToString()), csvTable.Rows[i][2].ToString() ); basicNode.UpdateOutboundLinkRule("By Link Weight"); list.Add(basicNode); } return(list); }
public Event(EventDef def, BasicNode body) : base(def, body) { }
protected FunctionalMember(Definition def, BasicNode body) : base(def) => Body = body;
public void GraphTest() { Graph <BasicNode> g = new Graph <BasicNode>(); BasicNode a = new BasicNode("a"); BasicNode b = new BasicNode("b"); BasicNode c = new BasicNode("c"); g.Nodes.Add(a); g.Nodes.Add(a); // duplicate is ignored g.Nodes.Add(b); g.Nodes.Add(c); g.AddEdge(a, b); g.AddEdge(b, b); // self loop g.AddEdge(b, c); g.AddEdge(b, c); // double edge Assert.True(g.Nodes.Contains(a)); Assert.True(g.ContainsEdge(a, b)); Assert.True(g.ContainsEdge(b, b)); Assert.Equal(4, g.EdgeCount()); Assert.Equal(1, g.NeighborCount(a)); Assert.Equal(2, g.NeighborCount(c)); Assert.Equal(1, g.TargetCount(a)); Assert.Equal(0, g.SourceCount(a)); Console.WriteLine("g Edges:"); foreach (BasicNode source in g.Nodes) { foreach (BasicNode target in g.TargetsOf(source)) { Console.WriteLine(" {0} -> {1}", source, target); } } Console.Write("SourcesOf(b):"); foreach (BasicNode source in g.SourcesOf(b)) { Console.Write(" {0}", source); } Console.WriteLine(); Console.Write("NeighborsOf(b):"); foreach (BasicNode node in g.NeighborsOf(b)) { Console.Write(" {0}", node); } Console.WriteLine(); g.RemoveNodeAndEdges(a); Console.WriteLine("shape removed"); Console.WriteLine("g Edges:"); foreach (BasicNode source in g.Nodes) { foreach (BasicNode target in g.TargetsOf(source)) { Console.WriteLine(" {0} -> {1}", source, target); } } Console.WriteLine("b.Sources:"); foreach (BasicNode source in g.SourcesOf(b)) { Console.WriteLine(" {0}", source); } g.RemoveEdge(b, c); Console.WriteLine("(b,c) removed"); Console.WriteLine("g Edges:"); foreach (BasicNode source in g.Nodes) { foreach (BasicNode target in g.TargetsOf(source)) { Console.WriteLine(" {0} -> {1}", source, target); } } g.ClearEdgesOf(c); Console.WriteLine("c edges cleared"); Assert.Equal(0, g.NeighborCount(c)); Console.WriteLine("g Edges:"); foreach (BasicNode source in g.Nodes) { foreach (BasicNode target in g.TargetsOf(source)) { Console.WriteLine(" {0} -> {1}", source, target); } } g.ClearEdges(); Assert.Equal(0, g.EdgeCount()); g.Clear(); }
public void GraphSearchTest() { // this is the example graph at http://www.codeproject.com/cs/miscctrl/quickgraph.asp Graph <BasicNode> g = new Graph <BasicNode>(); BasicNode u = new BasicNode("u"); BasicNode v = new BasicNode("v"); BasicNode w = new BasicNode("w"); BasicNode x = new BasicNode("x"); BasicNode y = new BasicNode("y"); BasicNode z = new BasicNode("z"); g.Nodes.Add(u); g.Nodes.Add(v); g.Nodes.Add(w); g.Nodes.Add(x); g.Nodes.Add(y); g.Nodes.Add(z); g.AddEdge(u, v); g.AddEdge(u, x); g.AddEdge(v, y); g.AddEdge(y, x); g.AddEdge(x, v); g.AddEdge(w, u); g.AddEdge(w, y); g.AddEdge(w, z); DepthFirstSearch <BasicNode> dfs = new DepthFirstSearch <BasicNode>(g); dfs.DiscoverNode += delegate(BasicNode node) { Console.WriteLine("discover " + node); }; dfs.FinishNode += delegate(BasicNode node) { Console.WriteLine("finish " + node); }; dfs.DiscoverEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("discover " + edge); }; dfs.TreeEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("tree edge " + edge); }; dfs.FinishTreeEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("finish tree edge " + edge); }; dfs.CrossEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("cross edge " + edge); }; dfs.BackEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("back edge " + edge); }; Console.WriteLine("dfs from u:"); dfs.SearchFrom(u); Console.WriteLine(); Console.WriteLine("dfs from w:"); dfs.SearchFrom(w); Console.WriteLine(); dfs.Clear(); Console.WriteLine("cleared dfs from w:"); dfs.SearchFrom(w); Console.WriteLine(); Console.WriteLine("bfs:"); BreadthFirstSearch <BasicNode> bfs = new BreadthFirstSearch <BasicNode>(g); IndexedProperty <BasicNode, double> distance = g.CreateNodeData <double>(Double.PositiveInfinity); bfs.DiscoverNode += delegate(BasicNode node) { Console.WriteLine("discover " + node); }; bfs.FinishNode += delegate(BasicNode node) { Console.WriteLine("finish " + node); }; bfs.TreeEdge += delegate(Edge <BasicNode> edge) { Console.WriteLine("tree edge " + edge); distance[edge.Target] = distance[edge.Source] + 1; }; // compute distances from w distance[w] = 0; bfs.SearchFrom(w); Console.WriteLine("distances from w:"); foreach (BasicNode node in g.Nodes) { Console.WriteLine("[" + node + "] " + distance[node]); } Assert.Equal(2.0, distance[x]); Console.WriteLine(); Console.WriteLine("distances from w:"); DistanceSearch <BasicNode> dists = new DistanceSearch <BasicNode>(g); dists.SetDistance += delegate(BasicNode node, int dist) { Console.WriteLine("[" + node + "] " + dist); }; dists.SearchFrom(w); Console.WriteLine(); BasicNode start = z, end; (new PseudoPeripheralSearch <BasicNode>(g)).SearchFrom(ref start, out end); Console.WriteLine("pseudo-peripheral nodes: " + start + "," + end); StrongComponents <BasicNode> scc = new StrongComponents <BasicNode>(g); int count = 0; scc.AddNode += delegate(BasicNode node) { Console.Write(" " + node); }; scc.BeginComponent += delegate() { Console.Write("["); count++; }; scc.EndComponent += delegate() { Console.Write("]"); }; Console.Write("strong components reachable from w (topological order): "); scc.SearchFrom(w); Assert.Equal(4, count); Console.WriteLine(); count = 0; StrongComponents2 <BasicNode> scc2 = new StrongComponents2 <BasicNode>(g); scc2.AddNode += delegate(BasicNode node) { Console.Write(" " + node); }; scc2.BeginComponent += delegate() { Console.Write("["); count++; }; scc2.EndComponent += delegate() { Console.Write("]"); }; Console.Write("strong components reachable from w (rev topological order): "); scc2.SearchFrom(w); Assert.Equal(4, count); Console.WriteLine(); #if false Console.WriteLine("CyclicDependencySort:"); List <BasicNode> schedule = CyclicDependencySort <BasicNode> .Schedule(g, delegate(BasicNode node, ICollection <BasicNode> available) { if (node == x) { return(available.Contains(u)); } else { return(false); } }, g.Nodes); foreach (BasicNode node in schedule) { Console.Write(node + " "); } Console.WriteLine(); Assert.Equal <int>(6, schedule.Count); // order should be: w u x v y z (z can be re-ordered) Assert.Equal <BasicNode>(w, schedule[0]); Assert.Equal <BasicNode>(u, schedule[1]); //Assert.Equal<BasicNode>(z,schedule[5]); #endif }
//private TypeInfo BinaryOperator(BinaryOperator node, string methodName) //{ // var lType = Visit(node.LeftOperand as dynamic); // var rType = Visit(node.RightOperand as dynamic); // if (TypeInfo.IsNumeric(lType)) // { // return lType; // } // var where = node.LeftOperand; // var args = new List<BasicNode>() { node.RightOperand }; // var method = new SpecialMethodCallNode(methodName, where, args); // ReplaceNode(node.Parent, node.ChildIndex, method); // var classType = lType as ClassType; // if (classType == null) // { // Log("Индексная операция не может быть применена", node); // return TypeInfo.Undefined; // } // var methodInfo = classType.GetMethod(methodName, new List<TypeInfo>() { rType }, false); // if (methodInfo == null) // { // Log(string.Format("Операция {0} не может быть применена", methodName), node); // return TypeInfo.Undefined; // } // return methodInfo.Ret; //} void ReplaceNode(ITree parent, int index, BasicNode node) { parent.ReplaceChildren(index, index, node); node.Parent = parent; node.ChildIndex = index; }
/// <summary> /// 查找按钮,用于查找Tag和设备讯息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchBtn_Click(object sender, EventArgs e) { String StrIDorName = TagIDorNameTB.Text.ToUpper(); if ("".Equals(StrIDorName)) { MessageBox.Show("設備的ID或名稱不能為空!"); return; } if (tagrb.Checked) { #region 查找Tag设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchTag); CommonCollection.personOpers.Add(curpersonoper); TagPack MyTag = null; MyTag = SysParam.GetPackTag(StrIDorName); if (null == MyTag) { MyTag = SysParam.GetPackTag_Name(StrIDorName); } if (null == MyTag) { MessageBox.Show("查詢" + StrIDorName + "的Tag設備不存在!"); return; } Area curarea = CommonBoxOperation.GetAreaFromRouterID(MyTag.RD_New[0].ToString("X2") + MyTag.RD_New[1].ToString("X2")); if (null == curarea) { MessageBox.Show("對不起,卡片所在的區域不存在!"); return; } try { SysParam.isTracking = true; MyAllRegInfoWin = new AllRegInfoWin(frm, SpeceilAlarm.PersonHelp, MyTag.TD[0].ToString("X2") + MyTag.TD[1].ToString("X2")); MyAllRegInfoWin.ShowDialog(); } catch (Exception ex) { FileOperation.WriteLog("搜索Tag設備出現異常!異常原因:" + ex.ToString()); } finally { this.Close(); } #endregion } else if (rfrb.Checked) { #region 查找Refer设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchRefer); CommonCollection.personOpers.Add(curpersonoper); string strareaid = ""; BasicRouter mrt = null; foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas) { if (null == marea.Value) { continue; } marea.Value.AreaRouter.TryGetValue(StrIDorName, out mrt); if (mrt != null) { strareaid = marea.Key; break; } foreach (KeyValuePair <string, BasicRouter> router in marea.Value.AreaRouter) { if (null == router.Value) { continue; } if (StrIDorName.Equals(router.Value.Name)) { mrt = router.Value; break; } } if (null != mrt) { strareaid = marea.Key; break; } } if (null == strareaid || "".Equals(strareaid)) { MessageBox.Show("查詢" + StrIDorName + @"的參考點設備不存在!"); return; } RegInfoWin myregwin = new RegInfoWin(frm, strareaid); myregwin.ShowDialog(); this.Close(); #endregion } else if (ndrb.Checked) { #region 查找Node设备 PersonOperation curpersonoper = new PersonOperation(frm.CurPerson.ID, OperType.SearchNode); CommonCollection.personOpers.Add(curpersonoper); string strareaid = ""; BasicNode mnd = null; foreach (KeyValuePair <string, Area> marea in CommonCollection.Areas) { if (null == marea.Value) { continue; } marea.Value.AreaNode.TryGetValue(StrIDorName, out mnd); if (mnd != null) { strareaid = marea.Key; break; } foreach (KeyValuePair <string, BasicNode> node in marea.Value.AreaNode) { if (null == node.Value) { continue; } if (StrIDorName.Equals(node.Value.Name)) { mnd = node.Value; break; } } if (null != mnd) { strareaid = marea.Key; break; } } if (null == strareaid || "".Equals(strareaid)) { MessageBox.Show("查詢" + StrIDorName + @"的數據節點設備不存在!"); return; } RegInfoWin myregwin = new RegInfoWin(frm, strareaid); myregwin.ShowDialog(); this.Close(); #endregion } }
public Indexer(IndexerDef def, BasicNode body) : base(def, body) { }
/// <summary> /// 设置参考点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetBt_Click(object sender, EventArgs e) { #region 获取设置的参考点及节点讯息 string StrID1, StrID2, StrName, StrArea; StrID1 = RID_1TB.Text.ToUpper(); StrID2 = RID_2TB.Text.ToUpper(); //参考点名称 StrName = ReferNameTB.Text.ToUpper(); //判断区域是否存在 StrArea = Ps.ShowAreaCB.Text; //取出区域的ID Area are = SysParam.GetArea_IDName(StrArea); int index = NodeTypeCB.SelectedIndex; #endregion #region 檢查ID是否有误 if ("".Equals(StrID1) || "".Equals(StrID2)) { MessageBox.Show("對不起,ID不能为空!"); return; } if (StrID1.Length != 2 || StrID2.Length != 2) { MessageBox.Show("對不起,ID格式有誤,正常格式為ID1和ID2的長度都為2!"); return; } byte[] ID = new byte[2]; try { ID[0] = Convert.ToByte(StrID1, 16); ID[1] = Convert.ToByte(StrID2, 16); }catch (Exception) { MessageBox.Show("對不起,ID格式有误!"); return; } if (0 == ID[0] && 0 == ID[1]) { MessageBox.Show("對不起,參考點和數據節點的ID不能為0000!"); return; } if (0xFF == ID[0] && 0xFF == ID[1]) { MessageBox.Show("對不起,參考點和數據節點的ID不能為FFFF!"); return; } #endregion #region 检查添加或修改的参考点或数据节点是否已经存在 Area marea = null; Group mygroup = null; string strarea = "", strgrpid = "", strgroup = ""; int res = IsAreaContainNodeOrRefer(StrID1 + StrID2, out marea); if (null != marea) { if ("".Equals(marea.Name) || null == marea.Name) { strarea = marea.ID[0].ToString("X2") + marea.ID[1].ToString("X2"); } else { strarea = marea.Name; } strgrpid = marea.GroupID[0].ToString("X2") + marea.GroupID[1].ToString("X2"); } if (CommonCollection.Groups.TryGetValue(strgrpid, out mygroup)) {//获取到组别讯息 if ("".Equals(mygroup.Name) || null == mygroup.Name) { strgroup = mygroup.ID[0].ToString("X2") + mygroup.ID[1].ToString("X2"); } else { strgroup = mygroup.Name; } } #endregion if (StrRouterID != null && !"".Equals(StrRouterID)) { #region 修改参考点和数据节点讯息 if (!StrRouterID.Equals(StrID1 + StrID2)) { MessageBox.Show("對不起,參考點及數據節點的ID不能修改!"); return; } if (type != index) { //说明修改了节点的类型 if (index == 1) { //从参考点修改为数据节点 if (res == 1) { //包含数据节点 MessageBox.Show("在" + strgroup + "組別的" + strarea + "區域中" + "已經存在數據節點" + (StrID1 + StrID2) + "..."); return; } else { if (area.AreaRouter.Remove(StrRouterID)) { BasicNode Bn = new BasicNode(); Bn.ID = ID; Bn.Name = StrName; Bn.isVisible = true; Bn.x = ex.X; Bn.y = ex.Y; Bn.isVisible = RouterVisibleCB.Checked; are.AreaNode.Add(StrID1 + StrID2, Bn); this.Close(); return; } } } else {//从数据节点修改为参考点 if (res == 2) { MessageBox.Show("在" + strgroup + "組別的" + strarea + "區域中" + "已經存在參考點" + (StrID1 + StrID2) + "..."); return; } else { if (area.AreaNode.Remove(StrRouterID)) { BasicRouter BR = new BasicRouter(); BR.ID = ID; BR.Name = StrName; BR.isVisible = true; BR.x = ex.X; BR.y = ex.Y; BR.isVisible = RouterVisibleCB.Checked; are.AreaRouter.Add(StrID1 + StrID2, BR); this.Close(); return; } } } return; } //没有修改数据节点类型 if (index == 1) {//设置数据节点 BasicNode MyBasicNode = null; area.AreaNode.TryGetValue(StrRouterID, out MyBasicNode); if (null != MyBasicNode) { MyBasicNode.Name = StrName; MyBasicNode.isVisible = RouterVisibleCB.Checked; this.Close(); return; } } else {//设置参考点 BasicRouter MyBasicRouter = null; area.AreaRouter.TryGetValue(StrRouterID, out MyBasicRouter); if (null != MyBasicRouter) { MyBasicRouter.Name = StrName; MyBasicRouter.isVisible = RouterVisibleCB.Checked; this.Close(); return; } } #endregion } #region 添加参考点及节点 if (res == 1) { //包含节点 if (index == 1) { //数据节点 MessageBox.Show("在" + strgroup + "組別的" + strarea + "區域中" + "已經存在數據節點" + (StrID1 + StrID2) + "..."); } else {//参考点 MessageBox.Show("對不起,參考點ID與數據節點ID不能相同,在組別" + strgroup + "的" + strarea + "區域中" + "已經存在數據節點" + (StrID1 + StrID2) + "..."); } return; } else if (res == 2) { //包含参考点 if (index == 1) { //数据节点 MessageBox.Show("對不起,參考點ID與數據節點ID不能相同,在組別" + strgroup + "的" + strarea + "區域中" + "已經存在參考點" + (StrID1 + StrID2) + "..."); } else {//参考点 MessageBox.Show("對不起,在組別" + strgroup + "的" + strarea + "區域中" + "已經存在參考點" + (StrID1 + StrID2) + "..."); } return; } else if (res < 0) { //添加参考点与数据节点 if (index == 1) { //数据节点 BasicNode Bn = new BasicNode(); Bn.ID = ID; Bn.Name = StrName; Bn.isVisible = true; Bn.x = ex.X; Bn.y = ex.Y; Bn.isVisible = RouterVisibleCB.Checked; if (are.AreaNode.ContainsKey(StrID1 + StrID2)) { MessageBox.Show("Sorry,該區域上已經包含了" + StrID1 + StrID2 + "數據節點!"); return; } are.AreaNode.Add(StrID1 + StrID2, Bn); } else {//参考点 BasicRouter BR = new BasicRouter(); BR.ID = ID; BR.Name = StrName; BR.isVisible = true; BR.x = ex.X; BR.y = ex.Y; BR.isVisible = RouterVisibleCB.Checked; if (are.AreaRouter.ContainsKey(StrID1 + StrID2)) { MessageBox.Show("Sorry,該區域上已經包含了" + StrID1 + StrID2 + "參考點!"); return; } are.AreaRouter.Add(StrID1 + StrID2, BR); } SysParam.RestoreShow(); this.Close(); return; } #endregion }
public Constructor(ConstructorDef def, BasicNode body) : base(def, body) { }
public Property(PropertyDef def, BasicNode get, BasicNode set) : base(def) { Get = get; Set = set; }