Exemple #1
0
        public string[,] GetElementsInSyncDomain(int num)
        {
            var table = new Table();

            table.AddRow("SyncDomain {0}".FormatWith(num));

            foreach (var machine in Machines)
            {
                if (machine.SyncDomain == SyncDomains[num])
                {
                    table.AddRow(this[machine]);
                }
            }

            foreach (var synchronizedExternal in ExternalsManager.Externals.Select(x => x as ISynchronized).Where(x => x != null))
            {
                string name;
                if (synchronizedExternal.SyncDomain == SyncDomains[num] && ExternalsManager.TryGetName((IExternal)synchronizedExternal, out name))
                {
                    table.AddRow(name);
                }
            }

            return(table.ToArray());
        }
Exemple #2
0
        public bool TryGetEmulationElementName(object obj, out string name, out string containerName)
        {
            if (obj == null)
            {
                name          = null;
                containerName = null;
                return(false);
            }

            Tuple <string, string> result;

            if (nameCache.TryGetValue(obj, out result))
            {
                name          = result.Item1;
                containerName = result.Item2;
                return(true);
            }

            containerName = null;
            var objAsIPeripheral = obj as IPeripheral;

            if (objAsIPeripheral != null)
            {
                Machine machine;
                string  machName;

                if (TryGetMachineForPeripheral(objAsIPeripheral, out machine) && TryGetMachineName(machine, out machName))
                {
                    containerName = machName;
                    if (Misc.IsPythonObject(obj))
                    {
                        name = Misc.GetPythonName(obj);
                    }
                    else
                    {
                        if (!machine.TryGetAnyName(objAsIPeripheral, out name))
                        {
                            name = Machine.UnnamedPeripheral;
                        }
                    }
                    nameCache.Add(obj, Tuple.Create(name, containerName));
                    return(true);
                }
            }
            var objAsMachine = obj as Machine;

            if (objAsMachine != null)
            {
                if (EmulationManager.Instance.CurrentEmulation.TryGetMachineName(objAsMachine, out name))
                {
                    nameCache.Add(obj, Tuple.Create(name, containerName));
                    return(true);
                }
            }
            var objAsIExternal = obj as IExternal;

            if (objAsIExternal != null)
            {
                if (ExternalsManager.TryGetName(objAsIExternal, out name))
                {
                    nameCache.Add(obj, Tuple.Create(name, containerName));
                    return(true);
                }
            }

            var objAsIHostMachineElement = obj as IHostMachineElement;

            if (objAsIHostMachineElement != null)
            {
                if (HostMachine.TryGetName(objAsIHostMachineElement, out name))
                {
                    containerName = HostMachine.HostMachineName;
                    nameCache.Add(obj, Tuple.Create(name, containerName));
                    return(true);
                }
            }

            name = null;
            return(false);
        }