public void Initialize() { if (IsInitialize) { throw new Exception("已初始化"); } IsInitialize = true; try { if (!TCPDataService.Init(int.Parse(_conf.GetNetPort()))) { throw new Exception("数据端口初始化失败"); } if (!TCPCmdService.Init(int.Parse(_conf.GetNetCmdPort()))) { throw new Exception("命令端口初始化失败"); } } catch (Exception) { IsInitialize = false; } try { if (!TCPPoseService.Init(int.Parse(_conf.GetPosePort()))) { throw new Exception("姿态传感器端口初始化失败"); } } catch (Exception) { IsInitialize = false; } }
public void Initialize() { if (IsInitialize) { throw new Exception("已初始化"); } _datatcpClient = new TcpClient { SendTimeout = 1000 }; _cmdtcpClient = new TcpClient { SendTimeout = 1000 }; _posetcpClient = new TcpClient { SendTimeout = 1000 }; IsInitialize = true; try { if (!TCPDataService.Init(_datatcpClient, IPAddress.Parse(_conf.GetIP()), int.Parse(_conf.GetNetPort()))) { throw new Exception("数据端口初始化失败"); } if (!TCPCmdService.Init(_cmdtcpClient, IPAddress.Parse(_conf.GetIP()), int.Parse(_conf.GetNetCmdPort()))) { throw new Exception("命令端口初始化失败"); } } catch (Exception) { IsInitialize = false; } try { if (!TCPPoseService.Init(_posetcpClient, IPAddress.Parse(_conf.GetPoseIP()), int.Parse(_conf.GetPosePort()))) { throw new Exception("姿态传感器网络初始化失败"); } } catch (Exception) { IsInitialize = false; } }