コード例 #1
0
        public async Task StartStopRecord()
        {
            var server = PayloadV2TestHelper.CreateServerDevice(out var port, IlsRtt.Records, IlsRtt.Fields, out var rttFolder, 10);
            var client = PayloadV2TestHelper.CreateClientDevice(port);

            server.Rtt[IlsRtt.Power11] = 1000.0;
            var sw = new Stopwatch();

            sw.Start();
            await client.InitState.Where(_ => _ == VehicleInitState.Complete).FirstAsync();

            _output.WriteLine($"Connected by {sw.ElapsedMilliseconds:N0} ms");
            var result = await client.Rtt.StartRecord(new SessionSettings("session1", "tag1"));

            Assert.Equal("session1", result.Session.Settings.Name);
            Assert.Contains("tag1", result.Session.Settings.Tags);
            Assert.NotEqual(Guid.Empty, result.Session.SessionId.Guid);
            Assert.True(result.IsEnabled);
            _output.WriteLine("Wait 10 sec");
            await Task.Delay(TimeSpan.FromSeconds(10));

            _output.WriteLine("Stop record");
            var stoped = await client.Rtt.StopRecord();

            Assert.True(stoped);

            _output.WriteLine($"Folder: {rttFolder}");
        }
コード例 #2
0
        public async Task ConnectionTest()
        {
            var server = PayloadV2TestHelper.CreateServerDevice(out var port, IlsRtt.Records, IlsRtt.Fields, out var rttFolder, 1000);
            var client = PayloadV2TestHelper.CreateClientDevice(port);

            await client.Client.Client.Heartbeat.Link.Where(_ => _ == LinkState.Connected).FirstAsync();

            Observable.Timer(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)).Subscribe(_ =>
            {
                server.Rtt[IlsRtt.Power11] = -120 + _ * 0.01;
                server.Rtt[IlsRtt.Power12] = -120 + _ * 0.05;
                server.Rtt[IlsRtt.Power13] = -120 + _ * 0.5;

                server.Rtt[IlsRtt.Power21] = 30 - _ * 0.01;
                server.Rtt[IlsRtt.Power22] = 30 - _ * 0.10;
                server.Rtt[IlsRtt.Power23] = 30 - _ * 0.5;
            });
            server.Rtt[IlsRtt.Power11] = -70.01;
            server.Rtt[IlsRtt.Power12] = -70.01;
            server.Rtt[IlsRtt.Power13] = -70.01;

            server.Rtt[IlsRtt.Power21] = -70.01;
            server.Rtt[IlsRtt.Power22] = -70.01;
            server.Rtt[IlsRtt.Power23] = -70.01;

            var tcs     = new TaskCompletionSource <Unit>();
            var rttPass = false;

            client.Rtt.OnUpdate.Subscribe(_ =>
            {
                rttPass = true;
                if (rttPass)
                {
                    tcs.TrySetResult(Unit.Default);
                }
            });
            await tcs.Task;
            // server.Rtt[IlsRtt.Power] = 100.1;
        }