public string getASPRepresentation(AdvancedSensor s)
        {
            MappingManager manager = MappingManager.getInstance();
            string         rep     = ((ASPSimpleSensorMapper)manager.getMapper(typeof(SimpleSensor))).getASPRepresentation(s);

            foreach (string p in s.advancedConf.Keys.Distinct())
            {
                List <string> elementConf             = s.advancedConf[p].toSave;
                string        keyWithoutDotsAndSpaces = p.Replace(".", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                //Debug.Log("goname " + s.gOName);
                string goNameNotCapital = "";
                if (s.gOName.Length > 0)
                {
                    goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                }

                foreach (string p2 in elementConf)
                {
                    rep += "%" + sensorNameNotCapital + "(";
                    if (!s.gOName.Equals(""))
                    {
                        rep += goNameNotCapital + "(";
                    }
                    string elemType = s.advancedConf[p].name;
                    elemType = Char.ToLower(elemType[0]) + elemType.Substring(1);
                    string partial = elemType + "(" + ASPMapperHelper.getInstance().buildMapping(p2, '^', "(V)") + ")";
                    //Debug.Log("Advanced conf " + p);
                    if (s.matrixProperties.Count > 0)
                    {
                        //Debug.Log("matrix " + s.matrixProperties.First());
                    }
                    if (s.listProperties.Count > 0)
                    {
                        //Debug.Log("list " + s.listProperties.First());
                    }
                    if (s.matrixProperties.ContainsKey(p))
                    {
                        //Debug.Log("is a matrix");
                        rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X,Y," + partial + ")") + ")";//TODO: improve whene map other types
                    }
                    else if (s.listProperties.ContainsKey(p))
                    {
                        //Debug.Log("is a list");
                        rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X," + partial + ")") + ")";//TODO: improve whene map other types
                    }
                    if (!s.gOName.Equals(""))
                    {
                        rep += ").";
                    }
                    rep += Environment.NewLine;
                }
            }
            return(rep);
        }
        public string Map(object o)//o is a Sensor
        {
            SimpleSensor s             = (SimpleSensor)o;
            String       sensorMapping = "";

            lock (s.toLock)
            {
                MappingManager manager = MappingManager.getInstance();
                foreach (IDictionary dictionary in s.dictionaryPerType.Values.Distinct())
                {
                    foreach (DictionaryEntry entry in dictionary)
                    {
                        //MyDebugger.MyDebug(entry.Key);
                        string keyWithoutDotsAndSpaces = ((string)entry.Key).Replace(".", "");
                        keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                        keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                        if (!s.unityASPVariationNames.ContainsKey(keyWithoutDotsAndSpaces))
                        {
                            s.unityASPVariationNames.Add(keyWithoutDotsAndSpaces, (string)entry.Key);
                        }
                        Type            mapperType = entry.Value.GetType().GetGenericArguments()[0];//entry is a List<SOMETHING>
                        DictionaryEntry toMap      = new DictionaryEntry();
                        toMap.Key = keyWithoutDotsAndSpaces;
                        string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                        //MyDebugger.MyDebug("goname " + s.gOName);
                        string goNameNotCapital = "";
                        if (s.gOName.Length > 0)
                        {
                            goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                        }
                        if (s.operationPerProperty.ContainsKey((string)entry.Key))
                        {
                            sensorMapping += sensorNameNotCapital + "(";
                            if (!s.gOName.Equals(""))
                            {
                                sensorMapping += goNameNotCapital + "(";
                            }
                            //MyDebugger.MyDebug(sensorMapping + " " + entry.Value + " " + s.operationPerProperty[(string)toMap.Key]);
                            toMap.Value = Operation.compute(s.operationPerProperty[(string)entry.Key], entry.Value);
                            //MyDebugger.MyDebug("toMap: " + toMap.Key + " " + toMap.Value);
                            sensorMapping += manager.getMapper(mapperType).Map(toMap) + ")";
                            if (!s.gOName.Equals(""))
                            {
                                sensorMapping += ").";
                            }
                            sensorMapping += Environment.NewLine;
                        }
                        //MyDebugger.MyDebug("sensorMapping done for " + sensorMapping);
                    }
                }
                foreach (IDictionary dic in s.dictionaryPerType.Values.Distinct())
                {
                    dic.Clear();
                }
            }
            return(sensorMapping);
        }
        public string Map(object o)//o is a Sensor
        {
            AdvancedSensor s             = (AdvancedSensor)o;
            String         sensorMapping = "";

            lock (s.toLock)
            {
                MappingManager manager = MappingManager.getInstance();
                //Debug.Log("mapping " + s.sensorName);
                sensorMapping = manager.getMapper(typeof(SimpleSensor)).Map(s);
                //Debug.Log("mapped as simple "+sensorMapping);
                sensorMapping = matrixMapping(s, sensorMapping, manager);
                sensorMapping = listMapping(s, sensorMapping, manager);

                s.dataAvailable = false;
            }
            //Debug.Log(s.sensorName+" sensor mapping: " + sensorMapping);
            return(sensorMapping);
        }
        public Dictionary <string, List <string> > getTemplateASPRepresentation(AdvancedSensor s)
        {
            MappingManager manager = MappingManager.getInstance();
            Dictionary <string, List <string> > rep = ((ASPSimpleSensorMapper)manager.getMapper(typeof(SimpleSensor))).getTemplateASPRepresentation(s);

            foreach (string p in s.advancedConf.Keys.Distinct())
            {
                List <string> elementConf             = s.advancedConf[p].toSave;
                string        keyWithoutDotsAndSpaces = p.Replace(".", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace(" ", "");
                keyWithoutDotsAndSpaces = keyWithoutDotsAndSpaces.Replace("_", "");
                string sensorNameNotCapital = char.ToLower(s.sensorName[0]) + s.sensorName.Substring(1);
                //Debug.Log("goname " + s.gOName);
                string goNameNotCapital = "";
                if (s.gOName.Length > 0)
                {
                    goNameNotCapital = char.ToLower(s.gOName[0]) + s.gOName.Substring(1);
                }

                foreach (string p2 in elementConf)
                {
                    rep.Add(p + "$" + p2, new List <string>()); //each property of the inner element is referred as propertyName$elementPropertyName
                    List <string> partial = rep[p + "$" + p2];
                    partial.Add(sensorNameNotCapital + "(");
                    if (!s.gOName.Equals(""))
                    {
                        partial[0] += goNameNotCapital + "(";
                    }
                    string elemType = s.advancedConf[p].name;
                    elemType = Char.ToLower(elemType[0]) + elemType.Substring(1);

                    List <string> inner = ASPMapperHelper.getInstance().buildTemplateMapping(p2, '^');
                    inner[0] = elemType + "(" + inner[0];
                    inner[inner.Count - 1] += ")";

                    List <string> temp = ASPMapperHelper.getInstance().buildTemplateMapping(keyWithoutDotsAndSpaces, '^');
                    partial[0] = partial[0] + temp[0] + "(";
                    partial.Add(inner[0]);
                    partial.Add(inner[inner.Count - 1] + temp[temp.Count - 1] + "))");

                    /*Debug.Log("Advanced conf " + p);
                     * if (s.matrixProperties.Count > 0)
                     * {
                     *  //Debug.Log("matrix " + s.matrixProperties.First());
                     * }
                     * if (s.listProperties.Count > 0)
                     * {
                     *  //Debug.Log("list " + s.listProperties.First());
                     * }
                     * if (s.matrixProperties.ContainsKey(p))
                     * {
                     *  //Debug.Log("is a matrix");
                     *  List<string> temp= ASPMapperHelper.getInstance().buildTemplateMapping(keyWithoutDotsAndSpaces, '^');//TODO: improve whene map other types
                     *  partial[0] = partial[0] + temp[0]+"(" + inner[0];
                     *  partial.Add("");
                     *  partial.Add(inner[inner.Count - 1] + temp[temp.Count - 1] + "))");
                     *
                     * }
                     * else if (s.listProperties.ContainsKey(p))
                     * {
                     *  //Debug.Log("is a list");
                     *  rep += ASPMapperHelper.getInstance().buildMapping(keyWithoutDotsAndSpaces, '^', "(X," + partial + ")") + ")";//TODO: improve whene map other types
                     *
                     * }*/
                    if (!s.gOName.Equals(""))
                    {
                        partial[partial.Count - 1] += ").";
                    }
                }
            }
            return(rep);
        }