Esempio n. 1
0
        public void Read()
        {
            FreeTrackData local;

            accessor.Read(0, out local);
            if (local.DataID == Data.DataID)
            {
                sameDataCount++;
            }
            else
            {
                sameDataCount = 0;
                OnUpdate();
            }

            if (sameDataCount > 20)
            {
                local = new FreeTrackData {
                    DataID = Data.DataID
                };
                OnUpdate();
            }

            Data = local;
        }
Esempio n. 2
0
        public void Context()
        {
            var reset = new AutoResetEvent(false);
            var count = 0;
            var rand = new Random();

            ThreadPool.QueueUserWorkItem(o =>
            {
                
                using (var memoryMappedFile = MemoryMappedFile.CreateOrOpen("FT_SharedMem", Marshal.SizeOf(typeof(FreeTrackData))))
                {
                    using (var accessor = memoryMappedFile.CreateViewAccessor())
                    {

                        while (run)
                        {
                            count++;
                            var model = new FreeTrackData
                                {
                                    DataID = count,
                                    Yaw = rand.Next(0, 5),
                                    Pitch = rand.Next(5, 10),
                                    Roll = rand.Next(10, 15),
                                    X = rand.Next(15, 20),
                                    Y = rand.Next(20, 25),
                                    Z = rand.Next(25, 30)
                                };

                            accessor.Write(0, ref model);
                     
                            reset.Set();
                        }
                    }
                }
            });
            reset.WaitOne();
        }
Esempio n. 3
0
        public void Read()
        {
            FreeTrackData local;
            accessor.Read(0, out local);
            if (local.DataID == Data.DataID)
                sameDataCount++;
            else
            {
                sameDataCount = 0;
                OnUpdate();
            }

            if (sameDataCount > 20)
            {
                local = new FreeTrackData();
                local.DataID = Data.DataID;
                OnUpdate();
            }

            Data = local;
        }