コード例 #1
0
ファイル: Form1.cs プロジェクト: liuchao0052/XModel
        /***************************************************************************
        *  函数名称: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
コード例 #2
0
ファイル: IoTGateway.cs プロジェクト: liuchao0052/XModel
        /********************************************
         * 函数名称: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()