//JobShopEntities.cpp #include "stdio.h" #include "iostream.h" #include "math.h" #include "string.h" #include "stdlib.h" #include "assert.h" #include "SetDef.h" #include "rankedSetDef.h" #include "subsetHolder.h" #include "Accumulated_Tallied_Variables.h" #include "Events.h" #include "JobShop.h" Machine_group::Machine_group() { First_free_EndProcess_notice = NULL; } Job::Job(Std_job_type * SJTPtr) { Place=NULL; Job_type = SJTPtr; Arrival_time = SimTime; } void Std_job_type::NewSale(Sale * SalePtr) { Job * j = new Job(this); Timer.Cause((long)SalePtr, SimTime + Mean_time_between_sales*exponential()); j->AdvanceJob(); } void EndProcess::endOfProcessing() { JobDoneCode jdc; Job * j = this->Job_being_processed; jdc = j->AdvanceJob(); if (jdc==JobDone) j->~Job(); this->DispatchMachine(); } JobDoneCode Job::AdvanceJob() { Machine_group * MGPtr; Std_job_type * SJTPtr = this->Job_type; EndProcess * EPPtr; if (Place==NULL) //New Job { Place = this->Job_type->First_step_in_routing; assert(Place!=NULL); } else { Place = Place->Next_step; if(Place==NULL) //Job finished.... { SJTPtr ->Time_in_shop.Update(SimTime-Arrival_time); return JobDone; //"this" job destroyed in calling routine } } //File in queue or start processing MGPtr = Place->MG; if (MGPtr->Free_machines.Value()==0) { assert(MGPtr->First_free_EndProcess_notice==NULL); MGPtr->Queue.fileMemberIntoSet(Place->Step_priority, (long)this); MGPtr->Queue_size.Increment(1.0); return JobNotDone; } else { EPPtr = MGPtr->First_free_EndProcess_notice; MGPtr->First_free_EndProcess_notice = EPPtr->Next_free_EndProcess_notice; MGPtr->Free_machines.Increment(-1.0); EPPtr->Job_being_processed = this; Timer.Cause((long)EPPtr, SimTime + Place->Proc_time); return JobNotDone; } } void EndProcess::DispatchMachine() { Machine_group * MGPtr = this->Machine_group_used; EndProcess * EPPtr; Job * j; RAandMID RM; if (MGPtr->Queue_size.Value()==0) { EPPtr = MGPtr->First_free_EndProcess_notice; MGPtr->First_free_EndProcess_notice = this; this->Next_free_EndProcess_notice = EPPtr; MGPtr->Free_machines.Increment(1.0); return; } else { RM = MGPtr->Queue.removeFirstFromSet(); j = (Job*)RM.RM_memberID; MGPtr->Queue_size.Increment(-1.0); this->Job_being_processed = j; Timer.Cause((long)this, SimTime + (j->Place)->Proc_time); } }