/// <summary> /// This method runs all processors with data they requested /// </summary> /// <param name="readRequests">All data requests from this cycle</param> /// <returns>Returns number of working processors</returns> private int RunProcessors(List <RWRequest> readRequests) { int workingProcessorsCount = processors.Count; foreach (Processor processor in processors) { if (!processor.IsStopped) { // TODO: sprawdzić czy nie da się tego ifa rozwiązać lepiej np. !processor.ReadRequest.Empty if (readRequests.Any(request => request.From == processor.Number)) { RWRequest req = readRequests.First(request => request.From == processor.Number); processor.Execute(memory.ReadData(req)); } else { processor.Execute(null); } //If it was the las operation processor executed if (processor.IsStopped) { workingProcessorsCount--; } } else { //The processor allready managed to write its data co we stop it from trying that again processor.ClearDataToWrite(); workingProcessorsCount--; } } return(workingProcessorsCount); }
public override dynamic writeReaction(List <RWRequest> requests, RWRequest currentRequest, dynamic cellData) { return(cellData + currentRequest.Data); }