private void UpdateSimulationWorkSchedule(FUpdateSimulationWork uws)
        {
            var edit = simulationWorkschedules.FirstOrDefault(predicate: x => x.WorkScheduleId.Equals(value: uws.WorkScheduleId));

            if (edit != null)
            {
                edit.Start   = (int)uws.Start;
                edit.End     = (int)(uws.Start + uws.Duration); // to have Time Points instead of Time Periods
                edit.Machine = uws.Machine;
                return;
            }
            _updatedSimulationWork.Add(item: uws);

            //tuples.Add(new Tuple<string, long>(uws.Machine, uws.Duration));
        }
        /// <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);
        }