Beispiel #1
0
 private void RunTests(AppConfig config)
 {
     //Tests.Test.TestReadSkeletonFile();
     //Tests.Test.MultihumanGestureTest();
     //Tests.Test.CheckRelativeAngle();
     //Tests.Test.ExecuteParallel();
     //Tests.Test.TestVoiceCommandJson();
     //Tests.Test.TestSharpDxMatrixRotation();
     //Tests.Test.TestReadBehaviorXml(config);
     //Tests.Test.TestJson(JsonConvert.SerializeObject(config));
     //Tests.Test.TestProgramGeneration(config);
     //Tests.Test.TestJsonToProgram(config);
     //MainProgramUtil.ReadBehaviorXmlFile("complex_behavior.xml");
     //MainProgramUtil.ReadBehaviorXmlFile(@"C:\Work\Develop\sdk_2013\experimot\bin\scriptcs\behavior.xml");
     //Tests.Test.GestureConfidenceDataIterate();
 }
Beispiel #2
0
 public ContextServer()
 {
     _config = TinyIoCContainer.Current.Resolve<AppConfig>();
     _interval = ParameterUtil.Get(_config.parameters, "ContextServerInterval", _interval);
 }
Beispiel #3
0
 public IndriyaWeb(AppConfig config)
 {
     _config = config;
 }
Beispiel #4
0
 public ParameterServer()
 {
     _worldCtx = TinyIoCContainer.Current.Resolve<Context>();
     _config = TinyIoCContainer.Current.Resolve<AppConfig>();
     _interval = ParameterUtil.Get(_config.parameters, "ParameterServerInterval", _interval);
 }
Beispiel #5
0
 private void PrepareConfigData(AppConfig config)
 {
     if (config != null)
     {
         foreach (var parameter in config.parameters)
         {
             if (parameter.type == dataType.@string || parameter.type == dataType.file)
             {
                 parameter.value = Environment.ExpandEnvironmentVariables(parameter.value);
             }
         }
         foreach (var node in config.nodes)
         {
             foreach (var parameter in node.parameters)
             {
                 if (parameter.type == dataType.@string || parameter.type == dataType.file)
                 {
                     parameter.value = Environment.ExpandEnvironmentVariables(parameter.value);
                 }
             }
         }
     }
 }
Beispiel #6
0
 public static void TestReadBehaviorXml(AppConfig config)
 {
     var outputPath = ParameterUtil.Get(config.parameters, "MainProgramFilePath", "");
     if (!string.IsNullOrEmpty(outputPath))
     {
         var dir = Path.GetDirectoryName(outputPath);
         outputPath = Environment.ExpandEnvironmentVariables(dir ?? "");
         var behaviors = MainProgramUtil.ReadBehaviorXmlFile(Path.Combine(outputPath, "behavior.xml"));
         Console.WriteLine(@"Behaviors  : {0}", behaviors.Count);
         if (behaviors.Count > 0)
         {
             var motionBehavior = behaviors[0];
             if (motionBehavior.RobotActions.Count > 0)
             {
                 var behavior = motionBehavior.RobotActions[0];
                 var cloned = (BehaviorInfo)behavior.Clone();
                 if (cloned.Parameters.Count > 0)
                 {
                     string key = cloned.Parameters.Keys.FirstOrDefault();
                     if (!string.IsNullOrEmpty(key))
                     {
                         var param = cloned.Parameters[key] as Dictionary<string, object>;
                         if (param != null)
                         {
                             param["value"] = "New value";
                             Console.WriteLine(@"Value : {0}", cloned.Parameters[key]);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #7
0
        public static void TestJsonToProgram(AppConfig config)
        {
            var behaviorInfoDict = new Dictionary<string, List<BehaviorInfo>>();

            const string behavior =
                @"{ name : 'behavior', trigger : 'Greet_Left',  priority : 'high',  actions  : [{ name : 'stand' }, { name : 'greet' }, { name : 'crouch' }] }";
            var obj = JObject.Parse(behavior);
            if (obj != null)
            {
                var name = obj.Value<string>("name");
                Log.InfoFormat("Behavior Info - Name: {0}, Trigger: {1}, Priority: {2}", name,
                    obj.Value<string>("trigger"), obj.Value<string>("priority"));
                behaviorInfoDict.Add(name, new List<BehaviorInfo>());
                var actions = obj.SelectToken("$.actions"); //$.Manufacturers[?(@.Name == 'Acme Co')]
                foreach (var action in actions)
                {
                    var actionName = action.Value<string>("name");
                    behaviorInfoDict[name].Add(new BehaviorInfo()
                    {
                        BehaviorName = actionName
                    });
                    Log.InfoFormat("Action Info - Name: {0}", actionName);
                }
            }
            Log.InfoFormat("Dictionary constructed: {0}", behaviorInfoDict.Count);
            var outputPath = ParameterUtil.Get(config.parameters, "MainProgramFilePath", "");
            if (!string.IsNullOrEmpty(outputPath))
            {
                outputPath = Environment.ExpandEnvironmentVariables(outputPath);
                ProgramGenerator.GeneratePrograms(behavior, outputPath);
            }
        }
Beispiel #8
0
 public static void TestProgramGeneration(AppConfig config)
 {
     var outputPath = ParameterUtil.Get(config.parameters, "MainProgramFilePath", "");
     if (!string.IsNullOrEmpty(outputPath))
     {
         outputPath = Environment.ExpandEnvironmentVariables(outputPath);
         var dict = new Dictionary<string, string> {{"Greet_Left", "wave"}};
         ProgramGenerator.GeneratePrograms(dict, outputPath);
     }
 }
 public static bool LoadFromFile(string fileName, out AppConfig obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an AppConfig object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output AppConfig object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out AppConfig obj, out System.Exception exception)
 {
     exception = null;
     obj = default(AppConfig);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out AppConfig obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
 /// <summary>
 /// Deserializes workflow markup into an AppConfig object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output AppConfig object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out AppConfig obj, out System.Exception exception)
 {
     exception = null;
     obj = default(AppConfig);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }