コード例 #1
0
 /// <summary>
 /// 连接
 /// </summary>
 /// <param name="ip"></param>
 /// <param name="port"></param>
 public void Link(string ip, int port)
 {
     try
     {
         ServerStation.AddStationObjectClass(this);
         Log.log("添加路由!");
         ServerStation.Start(ip, port);
         Log.log("服务器启动成功");
         ControlCom.Init(Coms[0].Value, Convert.ToInt32(StaticParameter.GetValue("Control.BandRate")),
                         System.IO.Ports.Parity.None, Convert.ToInt32(StaticParameter.GetValue("Control.DataBits")), System.IO.Ports.StopBits.One);
         ControlCom.Open();
         Log.log("连接控制成功");
         ControlCom.ControlSystemLED("绿");
     }
     catch (Exception ex)
     {
         Log.log("连接设备失败");
         Log.error(ex);
     }
 }