/// <summary> /// Adds a new metric entry in the existing list of metric entries /// </summary> /// <param name="property"></param> /// <param name="tag"></param> /// <returns></returns> public MetricEntryType AddMetricEntry(StylusPointPropertyInfo property, KnownTagCache.KnownTagIndex tag) { // Create a new metric entry based on the packet information passed. MetricEntry entry = new MetricEntry(); MetricEntryType type = entry.CreateMetricEntry(property, tag); // Don't add this entry to the global list if size is 0, means default metric values! if (0 == entry.Size) { return(type); } MetricEntry start = _Entry; if (null == start) { _Entry = entry; } else // tack on data at the end, want to keep x,y at the beginning { while (start.Next != null) { start = start.Next; } start.Next = entry; } _Count++; _size += entry.Size + SerializationHelper.VarSize(entry.Size) + SerializationHelper.VarSize((uint)_Entry.Tag); return(type); }
public MetricEntryProperty(MetricEntryType type, int value, string message = null) { Type = Enum.GetName(typeof(MetricEntryType), type); Value = value; _message = message; }
/// <summary> /// This function checks if this packet property results in a valid metric entry. This will be a valid entry if /// 1. it is a custom property, 2. Does not belong to the global list of gaMetricEntry_Never, 3. Belongs to the /// global list of gaMetricEntry_Must and 4. Belongs to global list of gaMetricEntry_Optional and at least one of /// its metric values is different from the corresponding default. /// </summary> /// <param name="propertyInfo"></param> /// <param name="tag"></param> /// <param name="metricEntryType"></param> /// <param name="index"></param> /// <returns></returns> static bool IsValidMetricEntry(StylusPointPropertyInfo propertyInfo, KnownTagCache.KnownTagIndex tag, out MetricEntryType metricEntryType, out uint index) { index = 0; // If this is a custom property, check if all the Metric values are null or not. If they are then this is not a // valid metric entry if (tag >= (KnownTagCache.KnownTagIndex)KnownIdCache.CustomGuidBaseIndex) { metricEntryType = MetricEntryType.Custom; if( Int32.MinValue == propertyInfo.Minimum && Int32.MaxValue == propertyInfo.Maximum && StylusPointPropertyUnit.None == propertyInfo.Unit && DoubleUtil.AreClose(1.0, propertyInfo.Resolution) ) return false; else return true; } else { int ul; // First find the property in the gaMetricEntry_Never. If it belongs to this list, // we will never write the metric table for this prop. So return FALSE; for( ul = 0; ul < MetricEntry_Never.Length ; ul++ ) { if( MetricEntry_Never[ul] == tag ) { metricEntryType = MetricEntryType.Never; return false; } } // Then search the property in the gaMetricEntry_Must list. If it belongs to this list, // we must always write the metric table for this prop. So return TRUE; for( ul = 0; ul<MetricEntry_Must.Length; ul++ ) { if( MetricEntry_Must[ul] == tag ) { metricEntryType = MetricEntryType.Must; if( propertyInfo.Minimum == DefaultPropertyMetrics.Minimum && propertyInfo.Maximum == DefaultPropertyMetrics.Maximum && propertyInfo.Unit == DefaultPropertyMetrics.Unit && DoubleUtil.AreClose(propertyInfo.Resolution, DefaultPropertyMetrics.Resolution )) return false; else return true; } } // Now seach it in the gaMetricEntry_Optional list. If it is there, check the metric values // agianst the default values and if there is any non default value, return TRUE; for( ul = 0; ul<MetricEntry_Optional.Length; ul++ ) { if( ((MetricEntryList)MetricEntry_Optional[ul]).Tag == tag ) { metricEntryType = MetricEntryType.Optional; if( propertyInfo.Minimum == MetricEntry_Optional[ul].PropertyMetrics.Minimum && propertyInfo.Maximum == MetricEntry_Optional[ul].PropertyMetrics.Maximum && propertyInfo.Unit == MetricEntry_Optional[ul].PropertyMetrics.Unit && DoubleUtil.AreClose(propertyInfo.Resolution, MetricEntry_Optional[ul].PropertyMetrics.Resolution) ) return false; else { index = (uint)ul; return true; } } } // it is not found in any of the list. Force to write all metric entries for the property. metricEntryType = MetricEntryType.Must; return true; } }
/// <summary> /// This function checks if this packet property results in a valid metric entry. This will be a valid entry if /// 1. it is a custom property, 2. Does not belong to the global list of gaMetricEntry_Never, 3. Belongs to the /// global list of gaMetricEntry_Must and 4. Belongs to global list of gaMetricEntry_Optional and at least one of /// its metric values is different from the corresponding default. /// </summary> /// <param name="propertyInfo"></param> /// <param name="tag"></param> /// <param name="metricEntryType"></param> /// <param name="index"></param> /// <returns></returns> static bool IsValidMetricEntry(StylusPointPropertyInfo propertyInfo, KnownTagCache.KnownTagIndex tag, out MetricEntryType metricEntryType, out uint index) { index = 0; // If this is a custom property, check if all the Metric values are null or not. If they are then this is not a // valid metric entry if (tag >= (KnownTagCache.KnownTagIndex)KnownIdCache.CustomGuidBaseIndex) { metricEntryType = MetricEntryType.Custom; if (Int32.MinValue == propertyInfo.Minimum && Int32.MaxValue == propertyInfo.Maximum && StylusPointPropertyUnit.None == propertyInfo.Unit && DoubleUtil.AreClose(1.0, propertyInfo.Resolution)) { return(false); } else { return(true); } } else { int ul; // First find the property in the gaMetricEntry_Never. If it belongs to this list, // we will never write the metric table for this prop. So return FALSE; for (ul = 0; ul < MetricEntry_Never.Length; ul++) { if (MetricEntry_Never[ul] == tag) { metricEntryType = MetricEntryType.Never; return(false); } } // Then search the property in the gaMetricEntry_Must list. If it belongs to this list, // we must always write the metric table for this prop. So return TRUE; for (ul = 0; ul < MetricEntry_Must.Length; ul++) { if (MetricEntry_Must[ul] == tag) { metricEntryType = MetricEntryType.Must; if (propertyInfo.Minimum == DefaultPropertyMetrics.Minimum && propertyInfo.Maximum == DefaultPropertyMetrics.Maximum && propertyInfo.Unit == DefaultPropertyMetrics.Unit && DoubleUtil.AreClose(propertyInfo.Resolution, DefaultPropertyMetrics.Resolution)) { return(false); } else { return(true); } } } // Now seach it in the gaMetricEntry_Optional list. If it is there, check the metric values // agianst the default values and if there is any non default value, return TRUE; for (ul = 0; ul < MetricEntry_Optional.Length; ul++) { if (((MetricEntryList)MetricEntry_Optional[ul]).Tag == tag) { metricEntryType = MetricEntryType.Optional; if (propertyInfo.Minimum == MetricEntry_Optional[ul].PropertyMetrics.Minimum && propertyInfo.Maximum == MetricEntry_Optional[ul].PropertyMetrics.Maximum && propertyInfo.Unit == MetricEntry_Optional[ul].PropertyMetrics.Unit && DoubleUtil.AreClose(propertyInfo.Resolution, MetricEntry_Optional[ul].PropertyMetrics.Resolution)) { return(false); } else { index = (uint)ul; return(true); } } } // it is not found in any of the list. Force to write all metric entries for the property. metricEntryType = MetricEntryType.Must; return(true); } }