Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 启动服务
            try
            {
                siemens = new SiemensS7Net(SiemensPLCS.S1200, "127.0.0.1");
                siemens.SetPersistentConnection( );
                pcccNet = new AllenBradleyPcccNet("127.0.0.1");
                pcccNet.SetPersistentConnection( );

                httpServer = new HttpServer( );
                httpServer.Start(int.Parse(textBox2.Text));
                httpServer.HandleRequestFunc = HandleRequest;
                httpServer.IsCrossDomain     = checkBox1.Checked;                    // 是否跨域的设置
                httpServer.RegisterHttpRpcApi("", this);
                httpServer.RegisterHttpRpcApi("Siemens", siemens);                   // 注册一个西门子PLC的服务接口的示例
                httpServer.RegisterHttpRpcApi("TimeOut", typeof(HslTimeOut));        // 注册的类的静态方法和静态属性
                httpServer.RegisterHttpRpcApi("PCCC", pcccNet);
                if (checkBox2.Checked)
                {
                    httpServer.SetLoginAccessControl(new HslCommunication.MQTT.MqttCredential[] {
                        new HslCommunication.MQTT.MqttCredential("admin", "123456")
                    });
                }

                panel2.Enabled  = true;
                button1.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Started Failed:" + ex.Message);
            }
        }
Exemplo n.º 2
0
 public FormAllenBrandlyPCCC( )
 {
     InitializeComponent( );
     allenBradleyNet = new AllenBradleyPcccNet("192.168.0.110");
 }