Beispiel #1
0
        public static DataFlowSystem BuildSystem(Node tree, int processorElementsNumber)
        {
            var system = new DataFlowSystem();

            system.Processor      = new Processor(processorElementsNumber);
            system.CommandsMemory = new CommandsMemory();
            system.Distributor    = new Distributor(system.CommandsMemory);
            system.Arbitrator     = new Arbitrator(system.Processor, system.CommandsMemory, system.Distributor);

            BuildTables(system, tree, 0, OperantOrder.Right);
            return(system);
        }
Beispiel #2
0
 public static void PrintSystem(DataFlowSystem system)
 {
     Console.WriteLine("OPERANTS:");
     PrintOperantsTable(system.CommandsMemory.Operants);
     Console.WriteLine();
     Console.WriteLine("NOT ACTIVE COMMANDS:");
     PrintCommandsTable(system.CommandsMemory.NotActiveCommands);
     Console.WriteLine();
     Console.WriteLine("ACTIVATED COMMANDS:");
     PrintCommandsTable(system.CommandsMemory.ActivatedCommands);
     Console.WriteLine();
     Console.WriteLine("SRAM:");
     PrintCommandsTable(system.CommandsMemory.SRAM);
 }
Beispiel #3
0
        private static void BuildTables(DataFlowSystem system, Node node, int nextCommandId, OperantOrder order)
        {
            if (node is NodeBinary nodeBinary)
            {
                var command = new Command()
                {
                    Id            = system._lastCommandId++,
                    IsActive      = false,
                    NextCommandId = nextCommandId,
                    Order         = order,
                    Type          = (CommandType)nodeBinary.Operation
                };
                system.CommandsMemory.NotActiveCommands.Add(command);
                BuildTables(system, nodeBinary.Right, command.Id, OperantOrder.Right);
                BuildTables(system, nodeBinary.Left, command.Id, OperantOrder.Left);
            }

            if (node is NodeUnary nodeUnary)
            {
                var command = new Command()
                {
                    Id            = system._lastCommandId++,
                    IsActive      = false,
                    NextCommandId = nextCommandId,
                    Order         = order,
                    Type          = (CommandType)nodeUnary.Operation
                };
                system.CommandsMemory.NotActiveCommands.Add(command);
                BuildTables(system, nodeUnary.Right, command.Id, OperantOrder.Right);
            }

            if (node is NodeNumber nodeNumber)
            {
                var operant = new Operant {
                    NextCommandId = nextCommandId,
                    Order         = order,
                    Value         = nodeNumber.Number
                };
                system.Distributor.DistributeOperants(new List <Operant> {
                    operant
                });
            }
        }