Exemplo n.º 1
0
        static ITelemetry ReadAllValues(MemoryMappedViewAccessor accessor, int buffOffset, VarHeader[] varHeaders)
        {
            var result = new Telemetry();

            var maps = new Dictionary <VarType, Func <int, object> >()
            {
                { VarType.irInt, (offset) => accessor.ReadInt32(offset) },
                { VarType.irBitField, (offset) => accessor.ReadInt32(offset) },
                { VarType.irDouble, (offset) => accessor.ReadDouble(offset) },
                { VarType.irBool, (offset) => accessor.ReadBoolean(offset) },
                { VarType.irFloat, (offset) => accessor.ReadSingle(offset) }
            };

            var arryMaps = new Dictionary <VarType, Func <int, int, object> >()
            {
                { VarType.irInt, (size, offset) => GetArrayData <int>(accessor, size, offset) },
                { VarType.irBitField, (size, offset) => GetArrayData <int>(accessor, size, offset) },
                { VarType.irDouble, (size, offset) => GetArrayData <double>(accessor, size, offset) },
                { VarType.irFloat, (size, offset) => GetArrayData <float>(accessor, size, offset) },
                { VarType.irBool, (size, offset) => GetArrayData <bool>(accessor, size, offset) }
            };

            for (var i = 0; i < varHeaders.Length; i++)
            {
                var varHeader = varHeaders[i];
                var offset    = buffOffset + varHeader.offset;

                if (varHeader.type == VarType.irChar)
                {
                    throw new NotSupportedException();
                }

                object value;
                if (varHeader.count != 1)
                {
                    value = arryMaps[varHeader.type](varHeader.count, offset);
                }
                else
                {
                    value = maps[varHeader.type](offset);
                }

                result.Add(varHeader.name, value);
            }

            return(result);
        }
Exemplo n.º 2
0
 public override void LogTelemetry(string eventName, IDictionary <string, string> properties) => Telemetry.Add(new Tuple <string, IDictionary <string, string> >(eventName, properties));
Exemplo n.º 3
0
 public void Send(ITelemetry item)
 {
     Telemetry.Add(item);
 }