private static void Main(string[] args) { using (LinkUpTcpClientConnector connector = new LinkUpTcpClientConnector(IPAddress.Parse("127.0.0.1"), 3000)) //using (LinkUpTcpClientConnector connector = new LinkUpTcpClientConnector(IPAddress.Parse("127.0.0.1"), 3000)) { connector.ReveivedPacket += ClientToServer_ReveivedPacket; connector.SentPacket += ClientToServer_SentPacket; connector.MetricUpdate += Connector_MetricUpdate; connector.ConnectivityChanged += Connector_ConnectivityChanged; node = new LinkUpNode(); node.Name = "leaf"; node.AddSubNode(connector); LinkUpEventLabel eventLabel = node.GetLabelByName <LinkUpEventLabel>("leaf/test/label_event"); func = node.GetLabelByName <LinkUpFunctionLabel>("leaf/test/label_function"); func.Return += Func_Return; eventLabel.Subscribe(); eventLabel.Fired += Program_Fired; Console.Read(); connector.Dispose(); } }
private void UpdateSubscription() { if (ProxyMode == IOProxyMode.Live) { if (_CameraEventLabel != null && _ImuEventLabel != null && _CameraImuEventLabel != null) { if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.CameraEvent) && _Subscriptions.Any(c => c.Item2 == ProxyEventType.ImuEvent) || _Subscriptions.Any(c => c.Item2 == ProxyEventType.CameraImuEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _CameraImuEventLabel.Subscribe(); } } catch (Exception) { } try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _ImuEventLabel.Unsubscribe(); } } catch (Exception) { } try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _CameraEventLabel.Unsubscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _CameraImuEventLabel.Unsubscribe(); } } catch (Exception) { } if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.CameraEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _CameraEventLabel.Subscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _CameraEventLabel.Unsubscribe(); } } catch (Exception) { } } if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.ImuEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _ImuEventLabel.Subscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _ImuEventLabel.Unsubscribe(); } } catch (Exception) { } } } } } //else if (ProxyMode == IOProxyMode.Offline) //{ // try // { // if (ConnectivityState == LinkUpConnectivityState.Connected) // _CameraEventLabel.Unsubscribe(); // } // catch (Exception) { } // try // { // if (ConnectivityState == LinkUpConnectivityState.Connected) // _ImuEventLabel.Unsubscribe(); // } // catch (Exception) { } // try // { // if (ConnectivityState == LinkUpConnectivityState.Connected) // _CameraImuEventLabel.Unsubscribe(); // } // catch (Exception) { } //} if (_SlamMapEventLabel != null) { if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.SlamMapEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _SlamMapEventLabel.Subscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _SlamMapEventLabel.Unsubscribe(); } } catch (Exception) { } } } if (_SlamStatusEventLabel != null) { if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.SlamStatusEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _SlamStatusEventLabel.Subscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _SlamStatusEventLabel.Unsubscribe(); } } catch (Exception) { } } } if (_ImuDerivedEventLabel != null) { if (_Subscriptions.Any(c => c.Item2 == ProxyEventType.ImuDerivedEvent)) { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _ImuDerivedEventLabel.Subscribe(); } } catch (Exception) { } } else { try { if (ConnectivityState == LinkUpConnectivityState.Connected) { _ImuDerivedEventLabel.Unsubscribe(); } } catch (Exception) { } } } }