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(); }
public ContextServer() { _config = TinyIoCContainer.Current.Resolve<AppConfig>(); _interval = ParameterUtil.Get(_config.parameters, "ContextServerInterval", _interval); }
public IndriyaWeb(AppConfig config) { _config = config; }
public ParameterServer() { _worldCtx = TinyIoCContainer.Current.Resolve<Context>(); _config = TinyIoCContainer.Current.Resolve<AppConfig>(); _interval = ParameterUtil.Get(_config.parameters, "ParameterServerInterval", _interval); }
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); } } } } }
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]); } } } } } } }
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); } }
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; } }