Ejemplo n.º 1
0
        public MavlinkClient(IMavlinkV2Connection connection, MavlinkClientIdentity identity, MavlinkClientConfig config, IPacketSequenceCalculator sequence = null, bool disposeConnection = true)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _seq               = sequence ?? new PacketSequenceCalculator();
            Identity           = identity;
            _mavlinkConnection = connection ?? throw new ArgumentNullException(nameof(connection));


            _rtt = new MavlinkTelemetry(_mavlinkConnection, identity, _seq);
            Disposable.Add(_rtt);

            _params = new MavlinkParameterClient(_mavlinkConnection, identity, _seq, new VehicleParameterProtocolConfig {
                ReadWriteTimeoutMs = config.ReadParamTimeoutMs, TimeoutToReadAllParamsMs = config.TimeoutToReadAllParamsMs
            });
            Disposable.Add(_params);

            _mavlinkCommands = new MavlinkCommandClient(_mavlinkConnection, identity, _seq, new CommandProtocolConfig {
                CommandTimeoutMs = config.CommandTimeoutMs
            });
            Disposable.Add(_mavlinkCommands);

            _mission = new MissionClient(_mavlinkConnection, identity, _seq, new MissionClientConfig {
                CommandTimeoutMs = config.CommandTimeoutMs
            });
            Disposable.Add(_mission);

            _mavlinkOffboard = new MavlinkOffboardMode(_mavlinkConnection, identity, _seq);
            Disposable.Add(_mavlinkOffboard);

            _mode = new MavlinkCommon(_mavlinkConnection, identity, _seq);
            Disposable.Add(_mode);

            _debugs = new DebugClient(_mavlinkConnection, identity, _seq);
            Disposable.Add(_debugs);

            _heartbeat = new HeartbeatClient(_mavlinkConnection, identity, _seq);
            Disposable.Add(_heartbeat);

            _logging = new LoggingClient(_mavlinkConnection, identity, _seq);
            Disposable.Add(_logging);

            _v2Ext = new V2ExtensionClient(_mavlinkConnection, _seq, identity);
            Disposable.Add(_v2Ext);

            _rtk = new DgpsClient(_mavlinkConnection, identity, _seq);
            Disposable.Add(_rtt);

            if (disposeConnection)
            {
                Disposable.Add(_mavlinkConnection);
            }
        }
Ejemplo n.º 2
0
        public MavlinkClient(IMavlinkV2Connection connection, MavlinkClientIdentity identity, MavlinkClientConfig config, IPacketSequenceCalculator _sequence = null)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _seq               = _sequence ?? new PacketSequenceCalculator();
            Identity           = identity;
            _mavlinkConnection = connection;

            _rtt = new MavlinkTelemetry(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _rtt.Dispose());

            _params = new MavlinkParameterClient(_mavlinkConnection, identity, new VehicleParameterProtocolConfig {
                ReadWriteTimeoutMs = config.ReadParamTimeoutMs, TimeoutToReadAllParamsMs = config.TimeoutToReadAllParamsMs
            });
            _disposeCancel.Token.Register(() => _params.Dispose());

            _mavlinkCommands = new MavlinkCommandClient(_mavlinkConnection, identity, _seq, new CommandProtocolConfig {
                CommandTimeoutMs = config.CommandTimeoutMs
            });
            _disposeCancel.Token.Register(() => _mavlinkCommands.Dispose());

            _mission = new MissionClient(_mavlinkConnection, _seq, identity, new MissionClientConfig {
                CommandTimeoutMs = config.CommandTimeoutMs
            });
            _disposeCancel.Token.Register(() => _mission.Dispose());

            _mavlinkOffboard = new MavlinkOffboardMode(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _mavlinkOffboard.Dispose());

            _mode = new MavlinkCommon(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _mode.Dispose());

            _debugs = new DebugClient(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _debugs.Dispose());

            _heartbeat = new HeartbeatClient(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _heartbeat.Dispose());

            _logging = new LoggingClient(_mavlinkConnection, identity);
            _disposeCancel.Token.Register(() => _logging.Dispose());

            _v2Ext = new V2ExtensionClient(_mavlinkConnection, _seq, identity);
            _disposeCancel.Token.Register(() => _v2Ext.Dispose());

            _rtk = new DgpsClient(_mavlinkConnection, _seq, identity);
            _disposeCancel.Token.Register(() => _rtt.Dispose());
        }