public void AddComponentToEntity(int entityId, GenericComponent componentToAdd)
 {
     if (!componentDictionary.ContainsKey(componentToAdd.GetType()))
     {
         componentDictionary.Add(componentToAdd.GetType(), new Dictionary <int, GenericComponent>());
     }
     entityDictionary[entityId].Add(componentToAdd.GetType(), componentToAdd);
     componentDictionary[componentToAdd.GetType()].Add(entityId, componentToAdd);
 }
Example #2
0
        public void SetUp()
        {
            var logicMap = new Dictionary <string, IComponentLogic>
            {
                { "score_sheet", new ScoreSheetLogic() }
            };

            _component = new TestComponent(logicMap);
        }
Example #3
0
        public static void Import()
        {
            Dictionary <string, GenericComponent> components = new Dictionary <string, GenericComponent>();

            string[] lines   = System.IO.File.ReadAllLines("Resources/circuit1.txt");
            bool     linking = false;

            foreach (string line in lines)
            {
                if (!line.StartsWith("#"))
                {
                    if (String.IsNullOrWhiteSpace(line))
                    {
                        linking = true;
                    }
                    else
                    {
                        if (!linking)
                        {
                            string[] strings = line.Split(':');
                            string   name    = strings[0].Trim();
                            string   type    = strings[1].Trim();
                            type = type.Replace(";", "");
                            GenericComponent component = GenericComponentFactory.CreateComponent(type);
                            components.Add(name, component);
                        }
                        else
                        {
                            string[] strings       = line.Split(':');
                            string   componentName = strings[0].Trim();
                            string   outputString  = strings[1].Trim();
                            outputString = outputString.Replace(";", "");

                            string[]         outputList = outputString.Split(',');
                            GenericComponent source     = components[componentName];
                            foreach (string target in outputList)
                            {
                                components[target].addInput(source);
                            }
                        }
                    }
                }
            }

            /*foreach(KeyValuePair<string,GenericComponent> kv in components)
             * {
             *  if (kv.Value is Source)
             *  {
             *      kv.Value.Trigger();
             *  }
             * }
             * foreach (KeyValuePair<string, GenericComponent> kv in components)
             * {
             *  Console.WriteLine(kv.Key + " " + kv.Value.state);
             * }*/
        }
Example #4
0
        public void CreateComponents(string componentLine)
        {
            string[] strings = componentLine.Split(':');
            string   name    = strings[0].Trim();
            string   type    = strings[1].Trim();

            type = type.Replace(";", "");

            GenericComponent component = GenericComponentFactory.CreateComponent(type);

            components.Add(name, component);
        }
Example #5
0
        public void LinkComponents(string linkLine)
        {
            string[] strings       = linkLine.Split(':');
            string   componentName = strings[0].Trim();
            string   outputString  = strings[1].Trim();

            outputString = outputString.Replace(";", "");

            string[]         outputList = outputString.Split(',');
            GenericComponent source     = components[componentName];

            foreach (string target in outputList)
            {
                components[target].addInput(source);
            }
        }
Example #6
0
        private object InitalizeProcess()
        {
            CloudLog.Debug("{0} Initializing has started...", GetType().Name);
            var sw = new Stopwatch();

            sw.Start();

            if (!string.IsNullOrEmpty(_username))
            {
                var logonResponse = Request("Logon", new
                {
                    User     = _username,
                    Password = _password
                });

                Debug.WriteSuccess(GetType().Name + " Login Response", logonResponse);
            }

            if (_components.Count == 0)
            {
                CloudLog.Debug("{0} has no component details... requesting...", GetType().Name);
                var response = Request("Component.GetComponents", null);

                CloudLog.Debug("QsysCore has received list of user defined components, count = {0}",
                               response.Result.Children().Count());

                foreach (var component in response.Result.Children())
                {
                    CloudLog.Debug("QsysCore has compononent \"{0}\"", component["Name"].Value <string>());
                }

                foreach (var component in response.Result.Children()
                         .Where(c => _userDefinedComponentNames.Contains(c["Name"].Value <string>())))
                {
                    var name = component["Name"].Value <string>();
                    if (_components.ContainsKey(name))
                    {
                        continue;
                    }
                    switch (component["Type"].Value <string>())
                    {
                    case "audio_file_player":
                        _components[name] = new AudioFilePlayer(this, component);
                        break;

                    case "mixer":
                        _components[name] = new Mixer(this, component);
                        break;

                    case "system_mute":
                    case "gain":
                        _components[name] = new Gain(this, component);
                        break;

                    case "scriptable_controls":
                        _components[name] = new ScriptableControls(this, component);
                        break;

                    case "snapshot_controller":
                        _components[name] = new SnapshotController(this, component);
                        break;

                    case "softphone":
                        _components[name] = new SoftPhone(this, component);
                        break;

                    case "pots_control_status_core":
                        _components[name] = new PotsPhone(this, component);
                        break;

                    case "signal_presence":
                        _components[name] = new SignalPresence(this, component);
                        break;

                    case "sine":
                        _components[name] = new Sine(this, component);
                        break;

                    case "router_with_output":
                        _components[name] = new RouterWithOutput(this, component);
                        break;

                    case "io_status":
                        _components[name] = new IoStatus(this, component);
                        break;

                    default:
                        _components[name] = new GenericComponent(this, component);
                        break;
                    }
                }
            }
            else
            {
                CloudLog.Debug("{0} has component details... updating...", GetType().Name);
                foreach (var component in this)
                {
                    component.UpdateAsync();
                }
            }

            _initialized = true;

            sw.Stop();
            CloudLog.Debug("{0} has initialized, process time = {1}", GetType().Name, sw.Elapsed);

            OnHasIntitialized(this);

            DefaultChangeGroup.PollAuto(1.0);

            return(null);
        }