Exemplo n.º 1
0
        public bool ValidateTaskRAM(AllocationDisplay allocationDisplay, Configuration configuration)
        {
            int errorCount = 0;
            List <ProcessorAllocation> processorAllocations = allocationDisplay.ProcessorAllocations;

            for (int processorAllocatioNum = 0; processorAllocatioNum < processorAllocations.Count; processorAllocatioNum++)
            {
                ProcessorAllocation processorAllocation = processorAllocations[processorAllocatioNum];
                int processorAllocationRAM = processorAllocation.RAM;
                int processorRAM           = configuration.Processors[processorAllocatioNum].RAM;

                if (processorAllocationRAM > processorRAM)
                {
                    Error error = new Error();

                    error.Message = $"The processor (ID={processorAllocatioNum}) of allocation (ID={allocationDisplay.ID}) " +
                                    $"has {processorRAM} GB RAM but requires {processorAllocationRAM} GB RAM";
                    error.ActualValue   = $"{processorAllocationRAM} GB RAM";
                    error.ExpectedValue = $"Must be less than or equal to {processorRAM} GB RAM";
                    error.Filename      = ValidationsManager.Filename;
                    error.LineNumber    = "";
                    error.ErrorCode     = ErrorCode.INVALID_ALLOCATION;

                    errorCount++;
                    ValidationsManager.ErrorValidationManager.Errors.Add(error);
                }
            }

            return(errorCount == 0);
        }
        public void CalculateAllocationValues(Configuration configuration)
        {
            for (int allocationNum = 0; allocationNum < Allocations.Count; allocationNum++)
            {
                AllocationDisplay allocationDisplay = new AllocationDisplay();
                Allocation        allocation        = Allocations[allocationNum];

                allocationDisplay.ID      = allocation.ID;
                allocationDisplay.Runtime = CalculateAllocationRuntime(allocation, configuration);
                allocationDisplay.Energy  = CalculateAllocationEnergy(allocation, configuration);
                allocationDisplay.ProcessorAllocations = CalculateProcessorAllocationValues(allocation, configuration);

                AllocationDisplays.Add(allocationDisplay);
            }
        }
Exemplo n.º 3
0
        public bool CheckValidRuntime(AllocationDisplay allocationDisplay, double requiredRuntime)
        {
            double runtime    = allocationDisplay.Runtime;
            int    errorCount = 0;

            if (runtime > requiredRuntime)
            {
                Error error = new Error();

                error.Message = $"The runtime ({runtime}) of an allocation (ID={allocationDisplay.ID})" +
                                $" is greater then the expected program runtime ({requiredRuntime})";
                error.ActualValue   = $"{runtime}";
                error.ExpectedValue = $"Must be smaller than or equal to {requiredRuntime}";
                error.Filename      = ValidationsManager.Filename;
                error.LineNumber    = "";
                error.ErrorCode     = ErrorCode.INVALID_ALLOCATION;

                errorCount++;
                ValidationsManager.ErrorValidationManager.Errors.Add(error);
            }

            return(errorCount == 0);
        }
Exemplo n.º 4
0
        public bool IsAllocationEnergiesEqual(double initalEnergy, AllocationDisplay allocationDisplay)
        {
            int    errorCount       = 0;
            double allocationEnergy = allocationDisplay.Energy;

            if (allocationEnergy != initalEnergy)
            {
                Error error = new Error();

                error.Message = $"The energy value ({allocationEnergy}) of an allocation (ID={allocationDisplay.ID})" +
                                $" differs from the energy value ({initalEnergy}) of another allocation (ID=0)";
                error.ActualValue   = $"{allocationEnergy}";
                error.ExpectedValue = "All allocation's energy values must be the same";
                error.Filename      = ValidationsManager.Filename;
                error.LineNumber    = "";
                error.ErrorCode     = ErrorCode.INVALID_ALLOCATION;

                errorCount++;
                ValidationsManager.ErrorValidationManager.Errors.Add(error);
            }

            return(errorCount == 0);
        }