public GaitupFolder(GaitupData data)
        {
            _data = data;
            Name  = "sensor" + data.Config.Name;

            IsSaved = false;
            if (data.Accelerometer.Count > 0)
            {
                AddChild(new AccTable(data.Accelerometer, data.Config.Frequency));
            }
            if (data.Gyro.Count > 0)
            {
                AddChild(new GyrTable(data.Gyro, data.Config.Frequency));
            }
            if (data.Barometer.Count > 0)
            {
                AddChild(new BaroTable(data.Barometer, data.Config.Frequency));
            }
            if (data.Ble.Count > 0)
            {
                AddChild(new BleTable(data.Ble, data.Config.Frequency));
            }
            if (data.Radio.Count > 0)
            {
                AddChild(new RadioTable(data.Radio, data.Config.Frequency));
            }
        }
Esempio n. 2
0
        private static long CalcOffset(GaitupData slave)
        {
            if (slave.Radio.Count == 0)
            {
                return(0);
            }
            var(masterTime, slaveTime, _) = slave.Radio.First();
            var offset = slaveTime - masterTime;

            return(offset);
        }
Esempio n. 3
0
        public void Synchronize(GaitupData slave, long startTime)
        {
            if (_master == slave)
            {
                throw new InvalidOperationException("Can't synchronize with master");
            }
            if (slave.Radio.Count == 0)
            {
                throw new InvalidOperationException("No radio messages recorded - can't synchronize");
            }

            slave.OffsetTime(CalcOffset(slave) - startTime);
        }
Esempio n. 4
0
        public void AddSlave(GaitupData slave)
        {
            if (slave.Config.Radio.Mode == 0)
            {
                throw new InvalidOperationException("The slave should not have mode = 0");
            }
            if (slave.Config.Radio.Channel != _master.Config.Radio.Channel)
            {
                throw new InvalidOperationException("The data sets is not from the same session as the master.");
            }
            if (slave.Config.Frequency != _master.Config.Frequency)
            {
                throw new InvalidOperationException("The data sets must have the same frequency.");
            }

            _slaves.Add(slave);
        }
        public void ParseFile(GaitupConfig config = null)
        {
            if (config == null)
            {
                config = GetConfig();
            }
            config.Name     = _name;
            config.FileName = _fileName;

            var fileLength = _stream.Length;

            // Ensure we are at the start of the first sector
            _reader.BaseStream.Seek(SectorLength, SeekOrigin.Begin);

            _data = new GaitupData(config);
            var lastPrint = -1;

            try
            {
                while (true)
                {
                    if (_stream.Length == _stream.Position)
                    {
                        // End of file
                        break;
                    }

                    ParseSector(config);

                    if (!PrintProgress)
                    {
                        continue;
                    }

                    var print = (int)(_stream.Position * 100 / fileLength);
                    if (print == lastPrint)
                    {
                        continue;
                    }

                    Debug.WriteLine($"Handling: {print}%");
                    lastPrint = print;
                }
            } catch (EndOfStreamException) { }
        }
Esempio n. 6
0
        public void AddDataSets(IReadOnlyList <GaitupData> dataSets)
        {
            if (dataSets.Count == 1)
            {
                _master = dataSets.First();
            }
            else
            {
                try
                {
                    _master = dataSets.Single(el => el.Config.Radio.Mode == 0);
                }
                catch (InvalidOperationException)
                {
                    throw new InvalidOperationException("Cannot find any master with mode = 0");
                }
            }

            // All except the master are slaves
            foreach (var slave in dataSets.Where(el => el != _master))
            {
                AddSlave(slave);
            }
        }