Exemple #1
0
 /// <summary>
 /// ConnecotrProfileをもとにPortConnectorを作成する
 /// </summary>
 /// <param name="profile">接続情報</param>
 public PortConnector(ConnectorProfile profile)
 {
     _portServices = profile.Ports;
     _profile = profile;
     _connectorId = _profile.ConnectorId;
     IsConnected = true;
 }
        public ReturnCode_t NotifyConnect(ref ConnectorProfile connectorProfile)
        {
            if (connectorProfile.GetInterfaceType() != "corba_cdr")
            {
                throw new NotSupportedException();
            }

            _connector.SetConnectionInfo(connectorProfile);

            var myIor = CorbaUtility.GetIor(this);

            //var port = connector_profile.ports.Select(CorbaUtility.GetIor).FirstOrDefault(ior => ior == myIor);

            int currentIndex = -1;
            for (int i = 0; i < connectorProfile.Ports.Count; i++)
            {
                if (CorbaUtility.GetIor(connectorProfile.Ports[i]) == myIor)
                {
                    currentIndex = i;
                    break;
                }
            }
            if (currentIndex == -1) return ReturnCode_t.BAD_PARAMETER;

            if (currentIndex + 1 < connectorProfile.Ports.Count)
            {
                connectorProfile.Ports[currentIndex + 1].NotifyConnect(ref connectorProfile);
            }

            _connector.Connect(connectorProfile);

            _profile.ConnectorProfiles.Add(connectorProfile);

            return ReturnCode_t.RTC_OK;
        }
Exemple #3
0
        /// <summary>
        /// <see cref="PortConnector"/>クラスの新しいインスタンスを初期化します。
        /// </summary>
        /// <param name="ports">接続対象のポート</param>
        public PortConnector(params PortService[] ports)
        {
            _portServices = new List<PortService>(ports);

            _profile = new ConnectorProfile();
            _profile.Ports = ports.ToList();

            _profile.SetDataFlowType("push");
            _profile.SetInterfaceType("corba_cdr");
            _profile.SetSubscriptionType("flush");
        }
Exemple #4
0
        public async Task<ReturnCode_t> ConnectAsync()
        {
            if (IsConnected) return ReturnCode_t.PRECONDITION_NOT_MET;

            var ret = await _portServices[0].ConnectAsync(_profile);
            
            _profile = ret.Item2;
            _connectorId = _profile.ConnectorId;
            if (ret.Item1 == ReturnCode_t.RTC_OK) IsConnected = true;
            //todo:仮実装。
            return ret.Item1;
        }
        public ReturnCode_t Connect(ref ConnectorProfile connectorProfile)
        {
            if (string.IsNullOrEmpty(connectorProfile.ConnectorId))
            {
                connectorProfile.ConnectorId = Guid.NewGuid().ToString();
            }

            var port = connectorProfile.Ports.FirstOrDefault();
            if (port != null)
            {
                return port.NotifyConnect(ref connectorProfile);
            }

            return ReturnCode_t.BAD_PARAMETER;
        }