コード例 #1
0
        private void CreateOperationResults()
        {
            ResultStreamFactory.PublishJob(agent: Agent
                                           , job: _currentOperation
                                           , duration: _currentOperation.Operation.RandomizedDuration
                                           , capabilityProvider: _jobConfirmation.CapabilityProvider);

            var fOperationResult = new FOperationResult(key: _currentOperation.Key
                                                        , creationTime: 0
                                                        , start: Agent.CurrentTime
                                                        , end: Agent.CurrentTime + _currentOperation.Operation.RandomizedDuration
                                                        , originalDuration: _currentOperation.Operation.Duration
                                                        , productionAgent: _currentOperation.ProductionAgent
                                                        , capabilityProvider: _jobConfirmation.CapabilityProvider.Name);

            Agent.Send(BasicInstruction.FinishJob.Create(fOperationResult, _currentOperation.ProductionAgent));
        }
        /// <summary>
        /// Starts the next Job
        /// </summary>
        internal void DoWork()
        {
            var randomizedWorkDuration = _workTimeGenerator.GetRandomWorkTime(duration: _jobInProgress.Current.Duration);

            Agent.DebugMessage(msg: $"Starting Job {_jobInProgress.Current.Name}  Key: {_jobInProgress.Current.Key} new Duration is {randomizedWorkDuration}");

            var pub = new FUpdateSimulationWork(workScheduleId: _jobInProgress.Current.Key.ToString(), duration: randomizedWorkDuration, start: Agent.CurrentTime, machine: Agent.Name);

            Agent.Context.System.EventStream.Publish(@event: pub);

            var fOperationResult = new FOperationResult(key: _jobInProgress.Current.Key
                                                        , creationTime: 0
                                                        , start: Agent.CurrentTime
                                                        , end: Agent.CurrentTime + randomizedWorkDuration
                                                        , originalDuration: _jobInProgress.Current.Duration
                                                        , productionAgent: ActorRefs.Nobody
                                                        , resourceAgent: Agent.Context.Self);

            Agent.Send(instruction: BasicInstruction.FinishJob.Create(message: fOperationResult, target: Agent.Context.Self), waitFor: randomizedWorkDuration);
        }
        /// <summary>
        /// Starts the next Job
        /// </summary>
        internal void DoWork()
        {
            if (_jobInProgress.IsSet)
            {
                Agent.DebugMessage(msg: "Im still working....");
                return; // Resource Agent is still working
            }

            var nextJobInProgress = _processingQueue.DequeueFirstSatisfied(currentTime: Agent.CurrentTime);

            // Wait if nothing more to do
            if (nextJobInProgress == null)
            {
                // No more work
                Agent.DebugMessage(msg: "Nothing more Ready in Queue!");
                return;
            }

            UpdateProcessingQueue();

            _jobInProgress.Set(job: nextJobInProgress, currentTime: Agent.CurrentTime);

            var randomizedDuration = _workTimeGenerator.GetRandomWorkTime(duration: nextJobInProgress.Duration);

            Agent.DebugMessage(msg: $"Starting Job {nextJobInProgress.Name}  Key: {nextJobInProgress.Key} new Duration is {randomizedDuration}");

            var pub = new FUpdateSimulationWork(workScheduleId: nextJobInProgress.Key.ToString(), duration: randomizedDuration, start: Agent.CurrentTime, machine: Agent.Name);

            Agent.Context.System.EventStream.Publish(@event: pub);

            var fOperationResult = new FOperationResult(key: nextJobInProgress.Key
                                                        , creationTime: 0
                                                        , start: Agent.CurrentTime
                                                        , end: Agent.CurrentTime + randomizedDuration
                                                        , originalDuration: nextJobInProgress.Duration
                                                        , productionAgent: ActorRefs.Nobody
                                                        , resourceAgent: Agent.Context.Self);

            Agent.Send(instruction: BasicInstruction.FinishJob.Create(message: fOperationResult, target: Agent.Context.Self), waitFor: randomizedDuration);
        }