/******************************************** * 函数名称:run() * 功能:医疗服务器组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------医疗服务器input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------有线模块组件启动执行-------------------// WiredModule wiredM = (WiredModule)this.wiredModule; //step1、有线模块组件接收数据 wiredM.ComponentDataReceive(wiredM); //step2、执行有线模块数据帧解封装功能 wiredM.EthernetFrameDecapsulation(); //step3、有线模块组件output端口传输数据 wiredM.ComponentDataTransfer(wiredM); //--------------------缓冲区组件启动执行--------------------// MyBuffer buf = (MyBuffer)this.myBuffer; //step1、缓冲区组件接收数据 buf.ComponentDataReceive(buf); //step2、执行缓冲区功能 buf.MessageBuffering(null); //step3、缓冲区1组件output端口传输数据 buf.ComponentDataTransfer(buf); //---------------网络数据处理模块组件启动执行--------------// DataProcessor dp = (DataProcessor)this.dataProcessor; //step1、网络数据处理模块接收数据 dp.ComponentDataReceive(dp); //step2、执行网络数据处理模块功能 dp.NetworkDataProcessing(); //step3、网络数据处理模块output端口传输数据 dp.ComponentDataTransfer(dp); //----------------信息分析控制模块启动执行------------------// DataAnalyzer da = (DataAnalyzer)this.dataAnalyzer; //step1、信息分析控制模块接收数据 da.ComponentDataReceive(da); //step2、执行信息分析控制模块功能 da.DataAnalysis(); //step3、信息分析控制模块output端口传输数据 da.ComponentDataTransfer(da); //----------------医疗服务器output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } }// public void run()
//public Component DisplayController //{ // get { return displayController; } // set { displayController = value; } //} //public Component AudioController //{ // get { return audioController; } // set { audioController = value; } //} public MedicalServer(GraphControl graphControl) : base(graphControl) { this.IsCompositeComponnet = true; //MedicalServer为复合组件 //this.bmp = new Bitmap(@"..\..\..\picture\MedicalServer.png"); this.bmp = Resource1.MedicalServer; this.Text = "MedicalServer"; this.Rectangle = new RectangleF(400, 300, 84, 56); //设置组件位置及大小 this.name = "MedicalServer"; //创建MedicalServer组件端口并显示 this.input_ports = new Input_port[1]; //组件input端口数组 this.output_ports = new Output_port[1]; //组件output端口数组 this.input_ports[0] = new Input_port((this.ID + "_P1"), this.name + "Port", "input", "String", this); this.output_ports[0] = new Output_port((this.ID + "_P2"), this.name + "Port", "output", "String", this); int input_port_LocationX = (int)(this.Location.X); int input_ports_LocationY = (int)(this.Location.Y + 1 * (this.Height / (1 + 1)) - input_ports[0].Height / 2); int output_port_LocationX = (int)(this.Location.X + this.Width - 2); int output_ports_LocationY = (int)(this.Location.Y + 1 * (this.Height / (1 + 1)) - output_ports[0].Height / 2); input_ports[0].Rectangle = new RectangleF(input_port_LocationX, input_ports_LocationY, 15, 15); output_ports[0].Rectangle = new RectangleF(output_port_LocationX, output_ports_LocationY, 15, 15); this.graphControl.AddShape(input_ports[0], new Point(input_port_LocationX, input_ports_LocationY)); this.graphControl.AddShape(output_ports[0], new Point(output_port_LocationX, output_ports_LocationY)); //创建WiredModule组件 this.wiredModule = new WiredModule(null, null, null, null); this.wiredModule.Mac_address = wiredModule_mac_address; //创建WiredModule组件端口 this.wiredModule.input_ports = new Input_port[1]; this.wiredModule.input_ports[0] = new Input_port(this.wiredModule.ID + "_P1", this.wiredModule.name + "Port", "input", "string", this.wiredModule); this.wiredModule.output_ports = new Output_port[1]; this.wiredModule.output_ports[0] = new Output_port(this.wiredModule.ID + "_P2", this.wiredModule.name + "Port", "output", "string", this.wiredModule); //创建MyBuffer组件 this.myBuffer = new MyBuffer(null, null, null, null); //创建MyBuffer组件端口 this.myBuffer.input_ports = new Input_port[1]; this.myBuffer.input_ports[0] = new Input_port(this.myBuffer.ID + "_P1", this.myBuffer.name + "Port", "input", "string", this.myBuffer); this.myBuffer.output_ports = new Output_port[1]; this.myBuffer.output_ports[0] = new Output_port(this.myBuffer.ID + "_P2", this.myBuffer.name + "Port", "output", "string", this.myBuffer); //创建DataProcessor组件 this.dataProcessor = new DataProcessor(null, null, null, null); this.dataProcessor.IPv6_address1 = Server_IPv6_address; //创建DataProcessor组件端口 this.dataProcessor.input_ports = new Input_port[1]; this.dataProcessor.input_ports[0] = new Input_port(this.dataProcessor.ID + "_P1", this.dataProcessor.name + "Port", "input", "string", this.dataProcessor); this.dataProcessor.output_ports = new Output_port[1]; this.dataProcessor.output_ports[0] = new Output_port(this.dataProcessor.ID + "_P2", this.dataProcessor.name + "Port", "output", "string", this.dataProcessor); //创建DataAnalyzer组件 this.dataAnalyzer = new DataAnalyzer(null, null, null, null); //创建DataAnalyzer组件端口 this.dataAnalyzer.input_ports = new Input_port[1]; this.dataAnalyzer.input_ports[0] = new Input_port(this.dataAnalyzer.ID + "_P1", this.dataAnalyzer.name + "Port", "input", "string", this.dataAnalyzer); //this.dataAnalyzer.output_ports = new Output_port[3]; this.dataAnalyzer.output_ports = new Output_port[2]; this.dataAnalyzer.output_ports[0] = new Output_port(this.dataAnalyzer.ID + "_P2", this.dataAnalyzer.name + "Port", "output", "string", this.dataAnalyzer); this.dataAnalyzer.output_ports[1] = new Output_port(this.dataAnalyzer.ID + "_P3", this.dataAnalyzer.name + "Port", "output", "string", this.dataAnalyzer); //this.dataAnalyzer.output_ports[2] = new Output_port(this.dataAnalyzer.ID + "_P4", // this.dataAnalyzer.name + "Port", "output", "string", this.dataAnalyzer); //创建DataMemory组件 this.dataMemory = new DataMemory(null, null, null, null); //创建DataMemory组件端口 this.dataMemory.input_ports = new Input_port[1]; this.dataMemory.input_ports[0] = new Input_port(this.dataMemory.ID + "_P1", this.dataMemory.name + "Port", "input", "string", this.dataMemory); //this.dataMemory.output_ports = new Output_port[1]; //this.dataMemory.output_ports[0] = new Output_port(this.dataMemory.ID + "_P2", // this.dataMemory.name + "Port", "output", "string", this.dataMemory); ////创建DisplayController组件 //this.displayController = new DisplayController(null, null, null, null); ////创建DisplayController组件端口 //this.displayController.input_ports = new Input_port[1]; //this.displayController.input_ports[0] = new Input_port(this.displayController.ID + "_P1", // this.displayController.name + "Port", "input", "string", this.displayController); ////this.displayController.output_ports = new Output_port[1]; ////this.displayController.output_ports[0] = new Output_port(this.displayController.ID + "_P2", //// this.displayController.name + "Port", "output", "string", this.displayController); ////创建AudioController组件 //this.audioController = new AudioController(null, null, null, null); ////创建AudioController组件端口 //this.audioController.input_ports = new Input_port[1]; //this.audioController.input_ports[0] = new Input_port(this.audioController.ID + "_P1", // this.audioController.name + "Port", "input", "string", this.audioController); ////this.audioController.output_ports = new Output_port[1]; ////this.audioController.output_ports[0] = new Output_port(this.audioController.ID + "_P2", //// this.audioController.name + "Port", "output", "string", this.audioController); //--------------------------------------------------------------// //--------建立内部组件端口到MedicalServer组件端口的连线---------// //--------------------------------------------------------------// //1、建立MedicalServer组件input端口到WiredModule组件input端口的连线 Connection connection1 = new Connection(); connection1.From = this.input_ports[0].PortConnector1; connection1.To = this.wiredModule.input_ports[0].PortConnector1; //修改ConnectionCollection.cs第78行,获取Add方法 //将连线添加到组件输出端口连接点 this.input_ports[0].PortConnector1.Connections.Add(connection1); //2、建立DataAnalyzer组件output1端口到MedicalServer组件output端口的连线 Connection connection2 = new Connection(); connection2.From = this.DataAnalyzer.output_ports[1].PortConnector1; connection2.To = this.output_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.DataAnalyzer.output_ports[1].PortConnector1.Connections.Add(connection2); //-------------------------------------------------------------------// ////2、建立WiredModule组件output端口到Mybuffer组件input端口的连线 //Connection connection2 = new Connection(); //connection2.From = this.wiredModule.output_ports[0].PortConnector1; //connection2.To = this.myBuffer.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.wiredModule.output_ports[0].PortConnector1.Connections.Add(connection2); ////3、建立Mybuffer组件output端口到DataProcessor组件input端口的连线 //Connection connection3 = new Connection(); //connection3.From = this.myBuffer.output_ports[0].PortConnector1; //connection3.To = this.dataProcessor.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer.output_ports[0].PortConnector1.Connections.Add(connection3); ////4、建立DataProcessor组件output端口到DataAnalyzer组件input端口的连线 //Connection connection4 = new Connection(); //connection4.From = this.dataProcessor.output_ports[0].PortConnector1; //connection4.To = this.dataAnalyzer.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.dataProcessor.output_ports[0].PortConnector1.Connections.Add(connection4); ////5、建立DataAnalyzer组件output端口到DataMemory组件input端口的连线 //Connection connection5 = new Connection(); //connection5.From = this.dataAnalyzer.output_ports[0].PortConnector1; //connection5.To = this.dataMemory.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.dataAnalyzer.output_ports[0].PortConnector1.Connections.Add(connection5); ////6、建立DataAnalyzer组件output端口到DisplayController组件input端口的连线 //Connection connection6 = new Connection(); //connection6.From = this.dataAnalyzer.output_ports[1].PortConnector1; //connection6.To = this.displayController.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.dataAnalyzer.output_ports[1].PortConnector1.Connections.Add(connection6); ////7、建立DataAnalyzer组件output端口到AudioController组件input端口的连线 //Connection connection7 = new Connection(); //connection7.From = this.dataAnalyzer.output_ports[2].PortConnector1; //connection7.To = this.audioController.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.dataAnalyzer.output_ports[2].PortConnector1.Connections.Add(connection7); this.InsideForm = new InsideForm(this); //构建内部结构显示表单 }
public IPv6Router(GraphControl graphControl) : base(graphControl) { this.IsCompositeComponnet = true; //IPv6Router为复合组件 //this.bmp = new Bitmap(@"..\..\..\picture\IPv6Router.png"); this.bmp = Resource1.IPv6Router; this.Text = "IPv6Router"; this.Rectangle = new RectangleF(400, 200, 84, 55); //设置组件位置及大小 this.name = "IPv6Router"; //创建IPv6Router组件端口并显示 this.input_ports = new Input_port[1]; //组件input端口数组 this.output_ports = new Output_port[1]; //组件output端口数组 this.input_ports[0] = new Input_port((this.ID + "_P1"), this.name + "Port", "input", "int[]", this); this.output_ports[0] = new Output_port((this.ID + "_P2"), this.name + "Port", "output", "String", this); int input_port_LocationX = (int)(this.Location.X); int input_ports_LocationY = (int)(this.Location.Y + 1 * (this.Height / (1 + 1)) - input_ports[0].Height / 2); int output_port_LocationX = (int)(this.Location.X + this.Width - 2); int output_ports_LocationY = (int)(this.Location.Y + 1 * (this.Height / (1 + 1)) - output_ports[0].Height / 2); input_ports[0].Rectangle = new RectangleF(input_port_LocationX, input_ports_LocationY, 15, 15); output_ports[0].Rectangle = new RectangleF(output_port_LocationX, output_ports_LocationY, 15, 15); this.graphControl.AddShape(input_ports[0], new Point(input_port_LocationX, input_ports_LocationY)); this.graphControl.AddShape(output_ports[0], new Point(output_port_LocationX, output_ports_LocationY)); //创建有线模块1组件 this.wiredModule1 = new WiredModule(null, null, null, null); this.wiredModule1.Mac_address = wiredModule1_mac_address; //创建有线模块1组件端口 this.wiredModule1.input_ports = new Input_port[1]; this.wiredModule1.input_ports[0] = new Input_port(this.wiredModule1.ID + "_P1", this.wiredModule1.name + "Port", "input", "string", this.wiredModule1); this.wiredModule1.output_ports = new Output_port[1]; this.wiredModule1.output_ports[0] = new Output_port(this.wiredModule1.ID + "_P2", this.wiredModule1.name + "Port", "output", "string", this.wiredModule1); //创建有线模块2组件 this.wiredModule2 = new WiredModule(null, null, null, null); this.wiredModule2.Mac_address = wiredModule2_mac_address; //创建有线模块2组件端口 this.wiredModule2.input_ports = new Input_port[1]; this.wiredModule2.input_ports[0] = new Input_port(this.wiredModule2.ID + "_P1", this.wiredModule2.name + "Port", "input", "string", this.wiredModule2); this.wiredModule2.output_ports = new Output_port[1]; this.wiredModule2.output_ports[0] = new Output_port(this.wiredModule2.ID + "_P2", this.wiredModule2.name + "Port", "output", "string", this.wiredModule2); //创建缓冲区1组件 this.myBuffer1 = new MyBuffer(null, null, null, null); //创建缓冲区1组件端口 this.myBuffer1.input_ports = new Input_port[1]; this.myBuffer1.input_ports[0] = new Input_port(this.myBuffer1.ID + "_P1", this.myBuffer1.name + "Port", "input", "string", this.myBuffer1); this.myBuffer1.output_ports = new Output_port[1]; this.myBuffer1.output_ports[0] = new Output_port(this.myBuffer1.ID + "_P2", this.myBuffer1.name + "Port", "output", "string", this.myBuffer1); //创建缓冲区2组件 this.myBuffer2 = new MyBuffer(null, null, null, null); //创建缓冲区2组件端口 this.myBuffer2.input_ports = new Input_port[1]; this.myBuffer2.input_ports[0] = new Input_port(this.myBuffer2.ID + "_P1", this.myBuffer2.name + "Port", "input", "string", this.myBuffer2); this.myBuffer2.output_ports = new Output_port[1]; this.myBuffer2.output_ports[0] = new Output_port(this.myBuffer2.ID + "_P2", this.myBuffer2.name + "Port", "output", "string", this.myBuffer2); //创建路由模块组件 this.routeModule = new RouteModule(null, null, null, null); //创建路由模块组件端口 this.routeModule.input_ports = new Input_port[1]; this.routeModule.input_ports[0] = new Input_port(this.routeModule.ID + "_P1", this.routeModule.name + "Port", "input", "string", this.routeModule); this.routeModule.output_ports = new Output_port[1]; this.routeModule.output_ports[0] = new Output_port(this.routeModule.ID + "_P2", this.routeModule.name + "Port", "output", "string", this.routeModule); //-------------------------------------------------------------// //--------建立内部组件端口到IPv6Router组件端口的连线-----------// //-------------------------------------------------------------// //1、建立IPv6Router组件input端口到WiredModule1组件input端口的连线 Connection connection1 = new Connection(); connection1.From = this.input_ports[0].PortConnector1; connection1.To = this.wiredModule1.input_ports[0].PortConnector1; //修改ConnectionCollection.cs第78行,获取Add方法 //将连线添加到组件输出端口连接点 this.input_ports[0].PortConnector1.Connections.Add(connection1); //6、建立WiredModule2组件output端口到IPv6Router组件output端口的连线 Connection connection6 = new Connection(); connection6.From = this.wiredModule2.output_ports[0].PortConnector1; connection6.To = this.output_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.wiredModule2.output_ports[0].PortConnector1.Connections.Add(connection6); //-------------------------------------------------------------------------// ////2、建立WiredModule1组件output端口到MyBuffer1组件input端口的连线 //Connection connection2 = new Connection(); //connection2.From = this.wiredModule1.output_ports[0].PortConnector1; //connection2.To = this.myBuffer1.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.wiredModule1.output_ports[0].PortConnector1.Connections.Add(connection2); ////3、建立MyBuffer1组件output端口到RouteModule组件input端口的连线 //Connection connection3 = new Connection(); //connection3.From = this.myBuffer1.output_ports[0].PortConnector1; //connection3.To = this.routeModule.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer1.output_ports[0].PortConnector1.Connections.Add(connection3); ////4、建立RouteModule组件output端口到MyBuffer2组件input端口的连线 //Connection connection4 = new Connection(); //connection4.From = this.routeModule.output_ports[0].PortConnector1; //connection4.To = this.myBuffer2.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.routeModule.output_ports[0].PortConnector1.Connections.Add(connection4); ////5、建立MyBuffer2组件output端口到WiredModule2组件input端口的连线 //Connection connection5 = new Connection(); //connection5.From = this.myBuffer2.output_ports[0].PortConnector1; //connection5.To = this.wiredModule2.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer2.output_ports[0].PortConnector1.Connections.Add(connection5); this.InsideForm = new InsideForm(this); //构建内部结构显示表单 }
/******************************************** * 函数名称:run() * 功能:IPv6路由器组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------IPv6路由器input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------有线模块1组件启动执行-------------------// WiredModule wiredM1 = (WiredModule)this.wiredModule1; //step1、有线模块1组件接收数据 wiredM1.ComponentDataReceive(wiredM1); //step2、执行有线模块1数据帧解封装功能 wiredM1.EthernetFrameDecapsulation(); //step3、有线模块1组件output端口传输数据 wiredM1.ComponentDataTransfer(wiredM1); //-------------------缓冲区1组件启动执行-------------------// MyBuffer buf1 = (MyBuffer)this.myBuffer1; //step1、缓冲区1组件接收数据 buf1.ComponentDataReceive(buf1); //step2、执行缓冲区功能 buf1.MessageBuffering(null); //step3、缓冲区1组件output端口传输数据 buf1.ComponentDataTransfer(buf1); //-------------------路由模块组件启动执行-------------------// RouteModule rm = (RouteModule)this.routeModule; //step1、路由模块组件接收数据 rm.ComponentDataReceive(rm); //step2、执行路由模块功能 rm.Routing(); //step3、路由模块组件output端口传输数据 rm.ComponentDataTransfer(rm); //-------------------缓冲区2组件启动执行-------------------// MyBuffer buf2 = (MyBuffer)this.myBuffer2; //step1、缓冲区2组件接收数据 buf2.ComponentDataReceive(buf2); //step2、执行缓冲区功能 buf2.MessageBuffering(null); //step3、缓冲区2组件output端口传输数据 buf2.ComponentDataTransfer(buf2); //-------------------有线模块2组件启动执行-------------------// WiredModule wiredM2 = (WiredModule)this.wiredModule2; //step1、有线模块2组件接收数据 wiredM2.ComponentDataReceive(wiredM2); //step2、执行有线模块2数据帧封装功能 wiredM2.EthernetFrameEncapsulation(dest_address); //step3、有线模块2组件output端口传输数据 wiredM2.ComponentDataTransfer(wiredM2); //----------------IPv6路由器output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } } // public void run()
/*************************************************************************** * 函数名称:treeView1_NodeMouseDoubleClick() * 功能:组件库列表表项鼠标双击事件,在graphControl绘图控制区创建相应组件 * 参数:sender;e * 返回值:无 * *************************************************************************/ private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); if (treeView1.SelectedNode.Level > 1) { string name; //int tabIndex = 0; //第一个选项卡 name = e.Node.Name.ToString(); switch (name) { //================================================================// //======================创建基本组件==============================// //================================================================// //B01 人体血压 case "BloodPressure": bloodPressure = new BloodPressure(this.graphControl, null, null, null); graphControl.AddShape(bloodPressure, bloodPressure.Location); break; //B02 人体体温 case "Temperature": temperature = new Temperature(this.graphControl, null, null, null); graphControl.AddShape(temperature, new PointF(temperature.Location.X, temperature.Location.Y + 80)); break; //B03 人体心率 case "HeartRate": heartRate = new HeartRate(this.graphControl, null, null, null); graphControl.AddShape(heartRate, new PointF(heartRate.Location.X, heartRate.Location.Y + 160)); break; //B04 血压传感器 case "BloodPressureSensor": bloodPressureSensor = new BloodPressureSensor(this.graphControl, null, null, null); graphControl.AddShape(bloodPressureSensor, new PointF(bloodPressureSensor.Location.X + 110, bloodPressureSensor.Location.Y)); break; //B05 体温传感器 case "TemperatureSensor": temperatureSensor = new TemperatureSensor(this.graphControl, null, null, null); graphControl.AddShape(temperatureSensor, new PointF(temperatureSensor.Location.X + 110, temperatureSensor.Location.Y + 80)); break; //B06 心率传感器 case "HeartRateSensor": heartRateSensor = new HeartRateSensor(this.graphControl, null, null, null); graphControl.AddShape(heartRateSensor, new PointF(heartRateSensor.Location.X + 110, heartRateSensor.Location.Y + 160)); break; //B07 显示控制器 case "DisplayController": displayController = new DisplayController(this.graphControl, null, null, null); graphControl.AddShape(displayController, new PointF(displayController.Location.X + 220, displayController.Location.Y)); break; //B08 音频控制器 case "AudioController": audioController = new AudioController(this.graphControl, null, null, null); graphControl.AddShape(audioController, new PointF(audioController.Location.X + 220, audioController.Location.Y + 80)); break; //B09 电机控制器 case "ElectricMachineryController": electricMachineryController = new ElectricMachineryController(this.graphControl, null, null, null); graphControl.AddShape(electricMachineryController, new PointF(electricMachineryController.Location.X + 220, electricMachineryController.Location.Y + 160)); break; //B10 运算器 微处理器 case "MicroProcessor": microProcessor = new MicroProcessor(this.graphControl, null, null, null); graphControl.AddShape(microProcessor, new PointF(microProcessor.Location.X + 330, microProcessor.Location.Y)); break; //B11 协议转换器 case "ProtocolConverter": protocolConverter = new ProtocolConverter(this.graphControl, null, null, null); graphControl.AddShape(protocolConverter, new PointF(protocolConverter.Location.X + 330, protocolConverter.Location.Y + 70)); break; //B12 数据处理器 case "DataProcessor": dataProcessor = new DataProcessor(this.graphControl, null, null, null); graphControl.AddShape(dataProcessor, new PointF(dataProcessor.Location.X + 330, dataProcessor.Location.Y + 160)); break; //B13 数据分析器 case "DataAnalyzer": dataAnalyzer = new DataAnalyzer(this.graphControl, null, null, null); graphControl.AddShape(dataAnalyzer, new PointF(dataAnalyzer.Location.X + 330, dataAnalyzer.Location.Y + 240)); break; //B14 有线通信模块 case "WiredModule": wiredModule = new WiredModule(this.graphControl, null, null, null); graphControl.AddShape(wiredModule, new PointF(wiredModule.Location.X + 440, wiredModule.Location.Y)); break; //B15 无线通信模块 case "WirelessModule": wirelessModule = new WirelessModule(this.graphControl, null, null, null); graphControl.AddShape(wirelessModule, new PointF(wirelessModule.Location.X + 440, wirelessModule.Location.Y + 80)); break; //B16 有线媒介 case "WiredMedia": wiredMedia = new WiredMedia(this.graphControl, null, null, null); graphControl.AddShape(wiredMedia, new PointF(wiredMedia.Location.X + 440, wiredMedia.Location.Y + 160)); break; //B17 无线媒介 case "WirelessMedia": wirelessMedia = new WirelessMedia(this.graphControl, null, null, null); graphControl.AddShape(wirelessMedia, new PointF(wirelessMedia.Location.X + 440, wirelessMedia.Location.Y + 240)); break; //18 寄存器 case "Register": register = new Register(this.graphControl, null, null, null); graphControl.AddShape(register, new PointF(register.Location.X + 550, register.Location.Y)); break; //B19 存储器RAM case "RAM": ram = new RAM(this.graphControl, null, null, null); graphControl.AddShape(ram, new PointF(ram.Location.X + 550, ram.Location.Y + 80)); break; //B20 存储器ROM case "ROM": rom = new ROM(this.graphControl, null, null, null); graphControl.AddShape(rom, new PointF(rom.Location.X + 550, rom.Location.Y + 160)); break; //B21 数据存储器 case "DataMemory": dataMemory = new DataMemory(this.graphControl, null, null, null); graphControl.AddShape(dataMemory, new PointF(dataMemory.Location.X + 550, dataMemory.Location.Y + 240)); break; //B22 缓冲区 case "Buffer": buffer = new MyBuffer(this.graphControl, null, null, null); graphControl.AddShape(buffer, new PointF(buffer.Location.X + 550, buffer.Location.Y + 320)); break; //B23 路由模块 case "RouteModule": routeModule = new RouteModule(this.graphControl, null, null, null); graphControl.AddShape(routeModule, new PointF(routeModule.Location.X + 330, routeModule.Location.Y + 320)); break; //B24 监控器 case "Monitor": monitor = new MyMonitor(this.graphControl, null, null, null); graphControl.AddShape(monitor, new PointF(monitor.Location.X + 220, monitor.Location.Y + 240)); break; //B25 血压监控器 case "BloodPressureMonitor": bpMonitor = new BloodPressureMonitor(this.graphControl, null, null, null); graphControl.AddShape(bpMonitor, new PointF(bpMonitor.Location.X + 220, bpMonitor.Location.Y + 280)); break; //B26 体温监控器 case "TemperatureMonitor": tempMonitor = new TemperatureMonitor(this.graphControl, null, null, null); graphControl.AddShape(tempMonitor, new PointF(tempMonitor.Location.X + 220, tempMonitor.Location.Y + 320)); break; //B27 心率监控器 case "HeartRateMonitor": hrMonitor = new HeartRateMonitor(this.graphControl, null, null, null); graphControl.AddShape(hrMonitor, new PointF(hrMonitor.Location.X + 220, hrMonitor.Location.Y + 360)); break; //====================================================================// //======================CMIoT组件库中组件=============================// //====================================================================// //C01 患者组件 case "Patient": patient = new Patient(this.graphControl); graphControl.AddShape(patient, patient.Location); break; //C02 血压传感节点 case "BloodPressureSensorNode": BPSN = new BloodPressureSensorNode(this.graphControl); //BPSN_InsideForm = new InsideForm(BPSN); //构建内部结构 graphControl.AddShape(BPSN, BPSN.Location); break; //C03 体温传感节点 case "TemperatureSensorNode": TSN = new TemperatureSensorNode(this.graphControl); graphControl.AddShape(TSN, TSN.Location); break; //C04 心率传感节点 case "HeartRateSensorNode": HRSN = new HeartRateSensorNode(this.graphControl); graphControl.AddShape(HRSN, HRSN.Location); break; //C05 物联网网关 case "IoTGateway": IoTG = new IoTGateway(this.graphControl); graphControl.AddShape(IoTG, IoTG.Location); break; //C06 802.11信道组件 case "802.11Channel": channel_802_11 = new Channel802_11(this.graphControl, null, null, null); graphControl.AddShape(channel_802_11, channel_802_11.Location); break; //C07 802.15.1信道组件 case "802.15.1Channel": channel802_15_1 = new Channel802_15_1(this.graphControl, null, null, null); graphControl.AddShape(channel802_15_1, channel802_15_1.Location); break; //C08 802.15.4信道组件 case "802.15.4Channel": channel802_15_4 = new Channel802_15_4(this.graphControl, null, null, null); graphControl.AddShape(channel802_15_4, channel802_15_4.Location); break; //C09 Ethernet信道组件 case "EthernetChannel": channel_ethernet = new ChannelEthernet(this.graphControl, null, null, null); graphControl.AddShape(channel_ethernet, channel_ethernet.Location); break; //C10 IPv6路由器组件 case "IPv6Router": ipv6Router = new IPv6Router(this.graphControl); graphControl.AddShape(ipv6Router, ipv6Router.Location); break; //C11 医疗服务器组件 case "MedicalServer": MS = new MedicalServer(this.graphControl); graphControl.AddShape(MS, MS.Location); break; } } // if (treeView1.SelectedNode.Level > 1) } //treeView1_NodeMouseDoubleClick
/******************************************** * 函数名称:run() * 功能:物联网网关组件执行函数 * 参数:无 * 返回值:无 * *****************************************/ public void run() { while (true) { if (Form1.stop) { this.EmptyingQueue(); return; } //-------------------IoT网关input端口传输数据----------------// //若input端口不为空 if (this.input_ports != null) { foreach (Input_port input in this.input_ports) { PortDataTransfer(input); //input端口进行数据传输 } } //-------------------无线模块1组件启动执行-------------------// WirelessModule wm1 = (WirelessModule)this.wirelessModule1; //step1、无线模块1组件接收数据 wm1.ComponentDataReceive(wm1); //step2、执行无线模块1数据帧解封装功能 wm1.FrameDecapsulation(); //step3、无线模块1组件output端口传输数据 wm1.ComponentDataTransfer(wm1); //-------------------无线模块2组件启动执行-------------------// WirelessModule wm2 = (WirelessModule)this.wirelessModule2; //step1、无线模块2组件接收数据 wm2.ComponentDataReceive(wm2); //step2、执行无线模块2数据帧解封装功能 wm2.FrameDecapsulation(); //step3、无线模块2组件output端口传输数据 wm2.ComponentDataTransfer(wm2); //-------------------无线模块3组件启动执行-------------------// WirelessModule wm3 = (WirelessModule)this.wirelessModule3; //step1、无线模块2组件接收数据 wm3.ComponentDataReceive(wm3); //step2、执行无线模块2数据帧解封装功能 wm3.FrameDecapsulation(); //step3、无线模块2组件output端口传输数据 wm3.ComponentDataTransfer(wm3); //-------------------缓冲区1组件启动执行-------------------// MyBuffer buf1 = (MyBuffer)this.myBuffer1; //step1、缓冲区1组件接收数据 buf1.ComponentDataReceive(buf1); //step2、执行缓冲区功能 buf1.MessageBuffering("frame802154"); //step3、缓冲区1组件output端口传输数据 buf1.ComponentDataTransfer(buf1); //-------------------缓冲区2组件启动执行-------------------// MyBuffer buf2 = (MyBuffer)this.myBuffer2; //step1、缓冲区2组件接收数据 buf2.ComponentDataReceive(buf2); //step2、执行缓冲区2功能 buf2.MessageBuffering("frame802154"); //step3、缓冲区2组件output端口传输数据 buf2.ComponentDataTransfer(buf2); //-------------------缓冲区3组件启动执行-------------------// MyBuffer buf3 = (MyBuffer)this.myBuffer3; //step1、缓冲区3组件接收数据 buf3.ComponentDataReceive(buf3); //step2、执行缓冲区3功能 buf3.MessageBuffering("frame802151"); //step3、缓冲区3组件output端口传输数据 buf3.ComponentDataTransfer(buf3); //----------------网络协议转换模块启动执行-----------------// ProtocolConverter pc = (ProtocolConverter)this.protocolConverter; //step1、网络协议转换模块接收数据 pc.ComponentDataReceive(pc); //step2、执行网络协议转换模块功能 pc.ProtocolConversion(); //step3、网络协议转换模块output端口传输数据 pc.ComponentDataTransfer(pc); //-------------------缓冲区4组件启动执行-------------------// MyBuffer buf4 = (MyBuffer)this.myBuffer4; //step1、缓冲区3组件接收数据 buf4.ComponentDataReceive(buf4); //step2、执行缓冲区3功能 buf4.MessageBuffering(null); //step3、缓冲区3组件output端口传输数据 buf4.ComponentDataTransfer(buf4); //-------------------有线模块组件启动执行-------------------// WiredModule wiredM = (WiredModule)wiredModule; //step1、有线模块组件接收数据 wiredM.ComponentDataReceive(wiredM); //step2、执行有线模块组件功能 wiredM.EthernetFrameEncapsulation(dest_address); //step3、有线模块组件output端口传输数据 wiredM.ComponentDataTransfer(wiredM); //----------------IoT网关output端口传输数据--------------// //若output端口不为空 if (this.output_ports != null) { foreach (Output_port output in this.output_ports) { PortDataTransfer(output); //output端口进行数据传输 } } } }// public void run()
public IoTGateway(GraphControl graphControl) : base(graphControl) { this.IsCompositeComponnet = true; //IoTGateway为复合组件 //this.bmp = new Bitmap(@"..\..\..\picture\IoTGateway.png"); this.bmp = Resource1.IoTGateway; this.Text = "IoTGateway"; this.Rectangle = new RectangleF(250, 200, 99, 105); //设置组件位置及大小 this.name = "IoTGateway"; //创建IoTGateway组件端口并显示 this.input_ports = new Input_port[3]; //组件input端口数组 this.output_ports = new Output_port[1]; //组件output端口数组 this.input_ports[0] = new Input_port((this.ID + "_P1"), this.name + "Port", "input", "string", this); this.input_ports[1] = new Input_port((this.ID + "_P2"), this.name + "Port", "input", "string", this); this.input_ports[2] = new Input_port((this.ID + "_P3"), this.name + "Port", "input", "string", this); this.output_ports[0] = new Output_port((this.ID + "_P4"), this.name + "Port", "output", "string", this); int input_port_LocationX = (int)(this.Location.X); int input_ports_LocationY1 = (int)(this.Location.Y + 1 * (this.Height / (3 + 1)) - input_ports[0].Height / 2); int input_ports_LocationY2 = (int)(this.Location.Y + 2 * (this.Height / (3 + 1)) - input_ports[1].Height / 2); int input_ports_LocationY3 = (int)(this.Location.Y + 3 * (this.Height / (3 + 1)) - input_ports[2].Height / 2); int output_port_LocationX = (int)(this.Location.X + this.Width - 2); int output_ports_LocationY = (int)(this.Location.Y + 1 * (this.Height / (1 + 1)) - output_ports[0].Height / 2); input_ports[0].Rectangle = new RectangleF(input_port_LocationX, input_ports_LocationY1, 15, 15); input_ports[1].Rectangle = new RectangleF(input_port_LocationX, input_ports_LocationY2, 15, 15); input_ports[2].Rectangle = new RectangleF(input_port_LocationX, input_ports_LocationY3, 15, 15); output_ports[0].Rectangle = new RectangleF(output_port_LocationX, output_ports_LocationY, 15, 15); this.graphControl.AddShape(input_ports[0], new Point(input_port_LocationX, input_ports_LocationY1)); this.graphControl.AddShape(input_ports[1], new Point(input_port_LocationX, input_ports_LocationY2)); this.graphControl.AddShape(input_ports[2], new Point(input_port_LocationX, input_ports_LocationY3)); this.graphControl.AddShape(output_ports[0], new Point(output_port_LocationX, output_ports_LocationY)); //创建无线模块1组件 this.wirelessModule1 = new WirelessModule(null, null, null, null); this.wirelessModule1.Mac_address = wirelessModule1_mac_address; //创建无线模块1组件端口 this.wirelessModule1.input_ports = new Input_port[1]; this.wirelessModule1.input_ports[0] = new Input_port(this.wirelessModule1.ID + "_P1", this.wirelessModule1.name + "Port", "input", "string", this.wirelessModule1); this.wirelessModule1.output_ports = new Output_port[1]; this.wirelessModule1.output_ports[0] = new Output_port(this.wirelessModule1.ID + "_P2", this.wirelessModule1.name + "Port", "output", "string", this.wirelessModule1); //创建无线模块2组件 this.wirelessModule2 = new WirelessModule(null, null, null, null); this.wirelessModule2.Mac_address = wirelessModule2_mac_address; //创建无线模块2组件端口 this.wirelessModule2.input_ports = new Input_port[1]; this.wirelessModule2.input_ports[0] = new Input_port(this.wirelessModule2.ID + "_P1", this.wirelessModule2.name + "Port", "input", "string", this.wirelessModule2); this.wirelessModule2.output_ports = new Output_port[1]; this.wirelessModule2.output_ports[0] = new Output_port(this.wirelessModule2.ID + "_P2", this.wirelessModule2.name + "Port", "output", "string", this.wirelessModule2); //创建无线模块3组件 this.wirelessModule3 = new WirelessModule(null, null, null, null); this.wirelessModule3.Mac_address = wirelessModule3_mac_address; this.WirelessModule3.Access_address = wirelessModule3_access_address; //创建无线模块3组件端口 this.wirelessModule3.input_ports = new Input_port[1]; this.wirelessModule3.input_ports[0] = new Input_port(this.wirelessModule3.ID + "_P1", this.wirelessModule3.name + "Port", "input", "string", this.wirelessModule3); this.wirelessModule3.output_ports = new Output_port[1]; this.wirelessModule3.output_ports[0] = new Output_port(this.wirelessModule3.ID + "_P2", this.wirelessModule3.name + "Port", "output", "string", this.wirelessModule3); //创建缓冲区1组件 this.myBuffer1 = new MyBuffer(null, null, null, null); //创建缓冲区1组件端口 this.myBuffer1.input_ports = new Input_port[1]; this.myBuffer1.input_ports[0] = new Input_port(this.myBuffer1.ID + "_P1", this.myBuffer1.name + "Port", "input", "string", this.myBuffer1); this.myBuffer1.output_ports = new Output_port[1]; this.myBuffer1.output_ports[0] = new Output_port(this.myBuffer1.ID + "_P2", this.myBuffer1.name + "Port", "output", "string", this.myBuffer1); //创建缓冲区2组件 this.myBuffer2 = new MyBuffer(null, null, null, null); //创建缓冲区2组件端口 this.myBuffer2.input_ports = new Input_port[1]; this.myBuffer2.input_ports[0] = new Input_port(this.myBuffer2.ID + "_P1", this.myBuffer2.name + "Port", "input", "string", this.myBuffer2); this.myBuffer2.output_ports = new Output_port[1]; this.myBuffer2.output_ports[0] = new Output_port(this.myBuffer2.ID + "_P2", this.myBuffer2.name + "Port", "output", "string", this.myBuffer2); //创建缓冲区3组件 this.myBuffer3 = new MyBuffer(null, null, null, null); //创建缓冲区2组件端口 this.myBuffer3.input_ports = new Input_port[1]; this.myBuffer3.input_ports[0] = new Input_port(this.myBuffer3.ID + "_P1", this.myBuffer3.name + "Port", "input", "string", this.myBuffer3); this.myBuffer3.output_ports = new Output_port[1]; this.myBuffer3.output_ports[0] = new Output_port(this.myBuffer3.ID + "_P2", this.myBuffer3.name + "Port", "output", "string", this.myBuffer3); //创建缓冲区4组件 this.myBuffer4 = new MyBuffer(null, null, null, null); //创建缓冲区4组件端口 this.myBuffer4.input_ports = new Input_port[1]; this.myBuffer4.input_ports[0] = new Input_port(this.myBuffer4.ID + "_P1", this.myBuffer4.name + "Port", "input", "string", this.myBuffer4); this.myBuffer4.output_ports = new Output_port[1]; this.myBuffer4.output_ports[0] = new Output_port(this.myBuffer4.ID + "_P2", this.myBuffer4.name + "Port", "output", "string", this.myBuffer4); //创建协议转换器组件 this.protocolConverter = new ProtocolConverter(null, null, null, null); //创建协议转换器组件端口 this.protocolConverter.input_ports = new Input_port[3]; this.protocolConverter.input_ports[0] = new Input_port(this.protocolConverter.ID + "_P1", this.protocolConverter.name + "Port", "input", "string", this.protocolConverter); this.protocolConverter.input_ports[1] = new Input_port(this.protocolConverter.ID + "_P2", this.protocolConverter.name + "Port", "input", "string", this.protocolConverter); this.protocolConverter.input_ports[2] = new Input_port(this.protocolConverter.ID + "_P3", this.protocolConverter.name + "Port", "input", "string", this.protocolConverter); this.protocolConverter.output_ports = new Output_port[1]; this.protocolConverter.output_ports[0] = new Output_port(this.protocolConverter.ID + "_P4", this.protocolConverter.name + "Port", "output", "string", this.protocolConverter); //创建有线模块组件 this.wiredModule = new WiredModule(null, null, null, null); this.wiredModule.Mac_address = wiredModule_mac_address; //创建有线模块组件端口 this.wiredModule.input_ports = new Input_port[1]; this.wiredModule.input_ports[0] = new Input_port(this.wiredModule.ID + "_P1", this.wiredModule.name + "Port", "input", "string", this.wiredModule); this.wiredModule.output_ports = new Output_port[1]; this.wiredModule.output_ports[0] = new Output_port(this.wiredModule.ID + "_P2", this.wiredModule.name + "Port", "output", "string", this.wiredModule); //-------------------------------------------------------------// //--------建立内部组件端口到IoTGateway组件端口的连线-----------// //-------------------------------------------------------------// //1、建立IoTGateway组件input端口到无线模块1组件input端口的连线 Connection connection1 = new Connection(); connection1.From = this.input_ports[0].PortConnector1; connection1.To = this.wirelessModule1.input_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.input_ports[0].PortConnector1.Connections.Add(connection1); //2、建立IoTGateway组件input端口到无线模块2组件input端口的连线 Connection connection2 = new Connection(); connection2.From = this.input_ports[1].PortConnector1; connection2.To = this.wirelessModule2.input_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.input_ports[1].PortConnector1.Connections.Add(connection2); //3、建立IoTGateway组件input端口到无线模块3组件input端口的连线 Connection connection3 = new Connection(); connection3.From = this.input_ports[2].PortConnector1; connection3.To = this.wirelessModule3.input_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.input_ports[2].PortConnector1.Connections.Add(connection3); //12、建立有线模块组件output端口到IoTGateway组件output端口的连线 Connection connection12 = new Connection(); connection12.From = this.wiredModule.output_ports[0].PortConnector1; connection12.To = this.output_ports[0].PortConnector1; //将连线添加到组件输出端口连接点 this.wiredModule.output_ports[0].PortConnector1.Connections.Add(connection12); //-------------------------------------------------------------------------// ////4、建立无线模块1组件output端口到缓冲区1组件input端口的连线 //Connection connection4 = new Connection(); //connection4.From = this.wirelessModule1.output_ports[0].PortConnector1; //connection4.To = this.myBuffer1.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.wirelessModule1.output_ports[0].PortConnector1.Connections.Add(connection4); ////5、建立无线模块2组件output端口到缓冲区2组件input端口的连线 //Connection connection5 = new Connection(); //connection5.From = this.wirelessModule2.output_ports[0].PortConnector1; //connection5.To = this.myBuffer2.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.wirelessModule2.output_ports[0].PortConnector1.Connections.Add(connection5); ////6、建立无线模块3组件output端口到缓冲区3组件input端口的连线 //Connection connection6 = new Connection(); //connection6.From = this.wirelessModule3.output_ports[0].PortConnector1; //connection6.To = this.myBuffer3.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.wirelessModule3.output_ports[0].PortConnector1.Connections.Add(connection6); ////7、建立缓冲区1组件output端口到协议转换模块组件input端口1的连线 //Connection connection7 = new Connection(); //connection7.From = this.myBuffer1.output_ports[0].PortConnector1; //connection7.To = this.protocolConverter.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer1.output_ports[0].PortConnector1.Connections.Add(connection7); ////8、建立缓冲区2组件output端口到协议转换模块组件input端口2的连线 //Connection connection8 = new Connection(); //connection8.From = this.myBuffer2.output_ports[0].PortConnector1; //connection8.To = this.protocolConverter.input_ports[1].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer2.output_ports[0].PortConnector1.Connections.Add(connection8); ////9、建立缓冲区3组件output端口到协议转换模块组件input端口3的连线 //Connection connection9 = new Connection(); //connection9.From = this.myBuffer3.output_ports[0].PortConnector1; //connection9.To = this.protocolConverter.input_ports[2].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer3.output_ports[0].PortConnector1.Connections.Add(connection9); ////10、建立协议转换模块组件output端口到缓冲区4组件input端口的连线 //Connection connection10 = new Connection(); //connection10.From = this.protocolConverter.output_ports[0].PortConnector1; //connection10.To = this.myBuffer4.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.protocolConverter.output_ports[0].PortConnector1.Connections.Add(connection10); ////11、建立缓冲区4组件output端口到有线模块组件input端口的连线 //Connection connection11 = new Connection(); //connection11.From = this.myBuffer4.output_ports[0].PortConnector1; //connection11.To = this.wiredModule.input_ports[0].PortConnector1; ////将连线添加到组件输出端口连接点 //this.myBuffer4.output_ports[0].PortConnector1.Connections.Add(connection11); this.InsideForm = new InsideForm(this); //构建内部结构显示表单 }