00001 #ifndef CUSTOMERREQUEST_INCLUDED
00002 #define CUSTOMERREQUEST_INCLUDED
00003
00004 #include <cassert>
00005 #include <odem.h>
00006 #include <string>
00007 #include <list>
00008
00009 #include "HStorage.h"
00010 #include "Bath.h"
00011
00012 #include "ConfigParser.h"
00013
00014
00015 extern const char* ProcString[];
00016 extern const char* ProcStringForReport[];
00017
00018 enum Procedure {
00019 NV,V,T,QT,TQT,
00020 VE,NVE,
00021 NT,
00022 N,TN,
00023 GA,
00024 Other
00025 };
00026
00027 int variante(Procedure p);
00028
00029 Procedure proc (const char* s);
00030 BathType String2BathType (const char* s);
00031
00032 class Treatment {
00033 static std::list<Treatment*> all;
00034 Procedure p;
00035 double temp1;
00036 double temp2;
00037 BathType c;
00038 Treatment (Procedure proc, double ptemp1, double ptemp2, BathType cool): p(proc), temp1(ptemp1), temp2(ptemp2), c(cool){}
00039 public:
00040 static Treatment* newTreatment(Procedure proc, double temp1, double temp2, BathType cool)
00041 {
00042 Treatment* newT = new Treatment(proc, temp1, temp2, cool);
00043 for (std::list<Treatment*>::iterator it=all.begin(); it!=all.end(); ++it)
00044 if (**it==*newT) { delete newT; return *it; }
00045 all.push_back(newT);
00046 return newT;
00047 }
00048
00049 bool operator==(const Treatment& other) const {
00050 return p==other.p && c==other.c && temp1==other.temp1 && temp2==other.temp2;
00051 }
00052 friend std::ostream& operator<<(std::ostream& o, const Treatment& t)
00053 {
00054 return o<<ProcString[t.p]<<'\t'<<t.temp1<<'\t'<<t.temp2<<'\t'<<BathString[t.c]<<'\n';
00055 }
00056 static void printAll(std::ostream& os) {
00057 for (std::list<Treatment*>::iterator it=all.begin(); it!=all.end(); ++it)
00058 os<<**it;
00059 }
00060
00061
00062
00063 double timePreCool()const{ double time = conf.getONPALETTE(variante(p)); return time;}
00064
00065 double timeOnPalette()const { std::cerr<<"\ntimeOnPalette depricated: use timePrePaletteCool instead\n";
00066 return timePreCool(); }
00067
00068
00069 double timeOven1()const { double time = conf.getOVEN1(variante(p)); return time;}
00070
00071
00072 double timeOven2()const {
00073 assert (("oventime 2 not allowed", p < N));
00074 double time = conf.getOVEN2(variante(p)); return time;
00075 }
00076
00077
00078 double timePostCool()const{ double time = conf.getCOOLING (variante(p)); return time;}
00079
00080 double timeEndCooling()const{ std::cerr<<"\ntimeEndCooling depricated: use timePostCool instead\n";
00081 return timePostCool(); }
00082
00083
00084 double timeChill1()const {
00085 assert (("chilltime 1 not allowed", p < N));
00086 double time = conf.getCHILL(variante(p), c); return time;
00087 }
00088
00089
00090 double timeChill2()const {
00091 assert (("chilltime 2 not allowed", p >= N));
00092 double time = conf.getCHILL(variante(p), c); return time;
00093 }
00094
00095
00096 double timeCool1()const {
00097 return 0;
00098 }
00099
00100
00101 double timeCool2() const { return 0; }
00102
00103
00104
00105 double timeChill_A()const { return 10;}
00106
00107 double timeChill_B()const { return 30;}
00108
00109 Procedure getProcedure() const {return p;}
00110 BathType getBath() const {return c;}
00111 };
00112
00113
00114
00115 class CustomerRequest: public Msg {
00116 public:
00117
00118
00119 double diameter;
00120
00121 double height;
00122
00123 double mass;
00124
00125 Treatment* treatment;
00126
00127 std::string material;
00128
00129 SIMTIME startTime;
00130 SIMTIME endTime;
00131
00132 Buff_tail* outputAreaH;
00133
00134 private:
00135 int no;
00136 int noOfRings;
00137
00138 int openNumberOfRings;
00139
00140 private:
00141
00142 static CustomerRequest* firstRequest;
00143 CustomerRequest* nextRequest;
00144
00145 public:
00146 CustomerRequest(int number, int numberOfRings,
00147 double diameter, double height, double mass, Treatment* treatment,
00148 std::string material, Buff_tail* oa);
00149
00150 int getNumber() const {return no;}
00151 int getNumberOfRings() const {return noOfRings;}
00152 int getOpenNumberOfRings() const {return openNumberOfRings;}
00153 Treatment* getTreatment() const {return treatment;}
00154 void setNumberOfRings(int n);
00155
00156 protected:
00157 ~CustomerRequest();
00158
00159 public:
00160
00161 int getRequestNumber() const {return no;}
00162
00163
00164 bool isCompatibleTo(const CustomerRequest* r);
00165
00166 public:
00167
00168 static CustomerRequest* getFirstRequest() {return firstRequest;}
00169 static CustomerRequest* getRequest(int number) {
00170 CustomerRequest* r = getFirstRequest();
00171 while (r!=0 && r->no!=number) r=r->nextRequest;
00172 return r;
00173 }
00174 const CustomerRequest* getNextRequest() const {return nextRequest;}
00175
00176 bool isLastRequest() const {return nextRequest==0;}
00177 bool isDone() const {return openNumberOfRings==0;}
00178
00179 SIMTIME productionTime() const {return endTime - startTime;}
00180
00181
00182 void ringFinished();
00183 };
00184
00185
00186 #endif
00187