Beispiel #1
0
        /// <summary>
        /// Set configuration for the Datalogger
        /// </summary>
        /// <param name="dataLoggerConfig">Configuration to apply to the DataLogger. Config is an array of structs containing paths to the subscription of data to log.
        /// For example:
        /// DataLoggerConfig.DataEntry[] entries = { new DataLoggerConfig.DataEntry("/Meas/IMU9/52") };
        /// DataLoggerConfig config = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
        /// </param>
        public async Task SetLoggerConfigAsync(DataLoggerConfig dataLoggerConfig)
        {
            string jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(dataLoggerConfig);

            var op = new ApiCallAsync(this, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync();
        }
Beispiel #2
0
        public async void GetLogEntriesTest()
        {
            // delete any existing log entries
            await movesenseDevice.DeleteLogEntriesAsync();

            // Start logging
            await movesenseDevice.CreateLogEntryAsync();

            // Configure logger
            DataLoggerConfig.DataEntry[] entries = { new DataLoggerConfig.DataEntry("/Meas/IMU9/52") };
            DataLoggerConfig             config  = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
            await movesenseDevice.SetLoggerConfigAsync(config);

            // Start logging
            await movesenseDevice.SetLoggerStatusAsync(true);

            Assert.True((await movesenseDevice.GetLoggerStatusAsync()).LogStatus == 3, "Verify data logger is running");
            // Pause this test for 5 seconds
            await Task.Delay(5000);

            // Stop the logging
            await movesenseDevice.SetLoggerStatusAsync(false);

            // Check it's stopped
            Assert.True((await movesenseDevice.GetLoggerStatusAsync()).LogStatus == 2, "Verify data logger not running");
            // Get the log entries
            var log = await movesenseDevice.GetLogEntriesJsonAsync();

            // Check that we've got some logbook entries
            Assert.True(log.Elements.Length > 0, "Log Entries contains results");
            // Check data integrity
            Assert.True(log.Elements[0].ModificationTimestamp > 0, "Log entry modification timestamp valid");
        }
Beispiel #3
0
        public async Task SetLoggerConfigAsync(string deviceName, DataLoggerConfig dataLoggerConfig)
        {
            string jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(dataLoggerConfig);

            var op = new ApiCallAsync(deviceName, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync().ConfigureAwait(false);
        }
Beispiel #4
0
        /// <summary>
        /// Set configuration for the Datalogger - ONLY sets IMU9
        /// </summary>
        /// <param name="freq">Sampling rate, e.g. 26 for 26Hz</param>
        public async Task SetupLoggerAsync(int freq = 26)
        {
            DataLoggerConfig.DataEntry[] entries =
            {
                new DataLoggerConfig.DataEntry("/Meas/IMU9/" + freq)
            };

            DataLoggerConfig config     = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
            string           jsonConfig = Newtonsoft.Json.JsonConvert.SerializeObject(config);

            var op = new ApiCallAsync(this, MdsOp.PUT, DATALOGGER_CONFIG_PATH, jsonConfig);
            await op.CallAsync();
        }
Beispiel #5
0
        public async void GetLogEntriesTimestampBug()
        {
            // delete any existing log entries
            await movesenseDevice.DeleteLogEntriesAsync();

            // Start logging
            await movesenseDevice.CreateLogEntryAsync();

            // Configure logger
            DataLoggerConfig.DataEntry[] entries = { new DataLoggerConfig.DataEntry("/Meas/IMU9/52") };
            DataLoggerConfig             config  = new DataLoggerConfig(new DataLoggerConfig.Config(new DataLoggerConfig.DataEntries(entries)));
            await movesenseDevice.SetLoggerConfigAsync(config);

            // Set the time to Int32.MaxValue seconds since Epoch
            long   timemicros  = (long)Int32.MaxValue * 1000000;
            string requestBody = $"{{\"value\":{timemicros}}}";

            Debug.WriteLine($"TEST SetTime TIME {requestBody}");
            await Plugin.Movesense.CrossMovesense.Current.ApiCallAsync(movesenseDevice, Plugin.Movesense.Api.MdsOp.PUT, "/Time", requestBody);

            // Check it took
            var currTime = await movesenseDevice.GetTimeAsync();

            Assert.True(currTime.Time - timemicros < 200000, $"Current device time set to {Int32.MaxValue} seconds since Epoch");

            // Start logging
            await movesenseDevice.SetLoggerStatusAsync(true);

            Assert.True((await movesenseDevice.GetLoggerStatusAsync()).LogStatus == 3, "Verify data logger is running");
            // Pause this test for 2 seconds
            await Task.Delay(2000);

            // Stop the logging
            await movesenseDevice.SetLoggerStatusAsync(false);

            // Check it's stopped
            Assert.True((await movesenseDevice.GetLoggerStatusAsync()).LogStatus == 2, "Verify data logger not running");
            // Get the log entries - should assert without the deserialization fix in it
            var log = await movesenseDevice.GetLogEntriesJsonAsync();

            // Check that we've got some logbook entries
            Assert.True(log.Elements.Length > 0, "Log Entries contains results");
            // Check data integrity
            Assert.True(log.Elements[0].ModificationTimestamp > 0, "Log entry modification timestamp valid");
        }