Пример #1
0
        public override void GetHandler()
        {
            var nearestNeededPosition   = GetNearesElementWarehousePosition(ProductionState, ItemState.Empty);
            var stackerRoundtripForItem = ProductionState[PositionCodes.Stacker, nearestNeededPosition] + ProductionState[nearestNeededPosition, PositionCodes.Stacker] - StackerOperationTime * 2;

            ProductionState[nearestNeededPosition] = Current;
            var nextIntake       = GetClosestNextIntakeTime();
            var realTimeBeforeOp = RealTime;

            RealTime       += stackerRoundtripForItem;
            IsReadyForBreak = true;

            AsyncStepModel step = new AsyncStepModel
            {
                CurrentState = AsyncControllerState.Get,
                Message      = $"RealTime: {RealTime}, Current: {Current}, Took item to position: {nearestNeededPosition} with time {stackerRoundtripForItem}, Next intake in: {nextIntake}, Time before get: {realTimeBeforeOp}"
            };

            /*if (RealTime > nextIntake)
             * {
             *  Delay += RealTime - nextIntake;
             *  nextIntake = GetClosestNextIntakeTime();
             * }*/

            ProductionState.ProductionHistory.Dequeue();
            if (ProductionState.FutureProductionPlan.Peek() == ProductionState.ProductionHistory.Peek())
            {
                CurrentState  = AsyncControllerState.Start;
                RealTime      = nextIntake;
                IntakeItem    = ItemState.Empty;
                step.Message += $", Going to state: {CurrentState}, Skipped to intake {nextIntake}";
                StepLog.Add(step);
                return;
            }

            double closestOuttake  = GetClosestNextOuttakeTime();
            double previousOuttake = GetPreviousOuttakeTime();

            if (RealTime < closestOuttake && RealTime < previousOuttake)
            {
                RealTime      = closestOuttake;
                step.Message += $", Skipped to outtake: {RealTime}";
            }

            CurrentState        = AsyncControllerState.Put;
            PreviousStateForPut = AsyncControllerState.Get;
            Needed        = ProductionState.FutureProductionPlan.Peek();
            step.Message += $", Going to state: {CurrentState}";
            StepLog.Add(step);
        }
Пример #2
0
        public override void PutHandler()
        {
            var nearestNeededPosition   = GetNearesElementWarehousePosition(ProductionState, Needed);
            var stackerRoundtripForItem = ProductionState[PositionCodes.Stacker, nearestNeededPosition] + ProductionState[nearestNeededPosition, PositionCodes.Stacker] - StackerOperationTime * 2;

            ProductionState[nearestNeededPosition] = ItemState.Empty;
            var realTimeBeforeOp = RealTime;
            var nextOuttake      = GetClosestNextOuttakeTime();
            var nextIntake       = GetClosestNextIntakeTime();

            RealTime       += stackerRoundtripForItem;
            Current         = ProductionState.ProductionHistory.Peek();
            IsReadyForBreak = false;

            AsyncStepModel step = new AsyncStepModel
            {
                CurrentState = AsyncControllerState.Put,
                Message      = $"RealTime: {RealTime}, Need: {Needed}, Took item from position: {nearestNeededPosition} with time {stackerRoundtripForItem}, Next outtake in: {nextOuttake}, Came here from: {PreviousStateForPut}, Time before put: {realTimeBeforeOp}"
            };

            switch (PreviousStateForPut)
            {
            case AsyncControllerState.Start:
                if (RealTime > nextOuttake)
                {
                    Delay       += RealTime - nextOuttake;
                    CurrentState = AsyncControllerState.Get;
                    nextOuttake  = GetClosestNextOuttakeTime();
                }

                if (RealTime <= nextOuttake)
                {
                    OuttakeItem  = Needed;
                    CurrentState = AsyncControllerState.Get;

                    //double closestIntake = GetClosestNextIntakeTime();
                    double closestIntake = nextIntake;
                    if (RealTime < closestIntake)
                    {
                        RealTime      = closestIntake;
                        step.Message += $", Skipped to intake: {RealTime}";
                    }
                }
                break;


            //TODO: 7205 ma byt 131 tzn 1309 je zbytek
            //TODO: 2750 ma byt 50 aut a 1390 zbyva
            case AsyncControllerState.SwapChain:
                var deq = ProductionState.FutureProductionPlan.Dequeue();
                ProductionState.ProductionHistory.Enqueue(deq);
                CurrentState = AsyncControllerState.Get;

                if (RealTime <= nextIntake)
                {
                    //RealTime = GetClosestNextIntakeTime();
                    RealTime      = nextIntake;
                    step.Message += $", Skipped to intake: {RealTime}";
                }

                OuttakeItem = Needed;
                Current     = ProductionState.ProductionHistory.Peek();
                IntakeItem  = Current;
                break;

            case AsyncControllerState.Get:
                if (RealTime > nextOuttake)
                {
                    Delay       += RealTime - nextOuttake;
                    CurrentState = AsyncControllerState.Get;
                    nextOuttake  = GetClosestNextOuttakeTime();
                }

                if (RealTime <= nextOuttake)
                {
                    OuttakeItem  = Needed;
                    Current      = ProductionState.ProductionHistory.Peek();
                    CurrentState = AsyncControllerState.Get;
                    var deq1 = ProductionState.FutureProductionPlan.Dequeue();
                    ProductionState.ProductionHistory.Enqueue(deq1);

                    double closestIntake  = GetClosestNextIntakeTime();
                    double previousIntake = GetPreviousOuttakeTime() - IntakeOuttakeDifference;
                    if (RealTime < closestIntake & RealTime < previousIntake)
                    {
                        RealTime      = closestIntake;
                        step.Message += $", Skipped to intake: {RealTime}";
                    }
                }
                break;
            }
            step.Message += $", Going to state: {CurrentState}";
            StepLog.Add(step);
        }