public byte[] ToByteArray()
        {
            GenericProviderData packet = this;
            int num = Marshal.SizeOf <GenericProviderData>(packet);

            byte[] array  = new byte[num];
            IntPtr intPtr = Marshal.AllocHGlobal(num);

            Marshal.StructureToPtr <GenericProviderData>(packet, intPtr, false);
            Marshal.Copy(intPtr, array, 0, num);
            Marshal.FreeHGlobal(intPtr);
            return(array);
        }
        public void Copy(GenericProviderData other)
        {
            version = other.version;

            yaw   = other.yaw;
            pitch = other.pitch;
            roll  = other.roll;

            position_x = other.position_x;
            position_y = other.position_y;
            position_z = other.position_z;

            local_velocity_x = other.local_velocity_x;
            local_velocity_y = other.local_velocity_y;
            local_velocity_z = other.local_velocity_z;

            gforce_lateral      = other.gforce_lateral;
            gforce_longitudinal = other.gforce_longitudinal;
            gforce_vertical     = other.gforce_vertical;

            engine_rpm = other.engine_rpm;
        }
Esempio n. 3
0
        public void Filter(GenericProviderData dataIn, ref GenericProviderData dataOut, int keyMask = int.MaxValue, bool newHistory = true)
        {
            mutex.WaitOne();

            GenericProviderData newRawData;
            GenericProviderData newFiltered;

            if (newHistory == true)
            {
                dataOut.Copy(dataIn);

                //copy to raw history
                newRawData = new GenericProviderData(dataIn.version);
                newRawData.Copy(dataIn);
                rawData.Add(newRawData);
                if (rawData.Count > maxHistorySamples)
                {
                    rawData.RemoveAt(0);
                }

                //add new filtered history
                newFiltered = new GenericProviderData(dataIn.version);
                filteredData.Add(newFiltered);
                if (filteredData.Count > maxHistorySamples)
                {
                    filteredData.RemoveAt(0);
                }
            }
            else
            {
                newFiltered = filteredData[filteredData.Count - 1];
                newRawData  = rawData[rawData.Count - 1];
            }


            //do filter lists for each key if it exists
            for (int i = 0; i < filters.Length; ++i)
            {
                List <FilterBase> filterList = filters[i];

                float value = dataIn.data[i];
                if (filterList == null || filterList.Count == 0)
                {
                    newFiltered.data[i] = value;
                    newRawData.data[i]  = value;
                    continue;
                }

                //ignore filter if not in keyMask
                if (((1 << i) & keyMask) == 0)
                {
                    continue;
                }

                //do filters for key
                foreach (FilterBase filter in filterList)
                {
                    value = filter.Filter(value);
                }

                //filtered
                newFiltered.data[i] = dataOut.data[i] = value;
            }

            mutex.ReleaseMutex();
        }
        public int GetSize()
        {
            GenericProviderData packet = this;

            return(Marshal.SizeOf <GenericProviderData>(packet));
        }