00001 #ifndef RINGFACTORY_INCLUDED
00002 #define RINGFACTORY_INCLUDED
00003
00004 #include <odem.h>
00005 #include <string>
00006 #include <iostream>
00007 #include <fstream>
00008 #include <queue>
00009 #include <list>
00010
00011 #include "CustomerRequest.h"
00012 #include "Ring.h"
00013 #include "RingStack.h"
00014 #include "SetOfRingStack.h"
00015 #include "Loader.h"
00016 #include "Observer.h"
00017 #include "Listener.h"
00018 #include "SimringReport.h"
00019
00020 class RingFactory : public Discrete {
00021 Buff_tail* factoryOutlet;
00022 std::ifstream& inputStream;
00023 Buff_tail* requestDump;
00024 SimringReport* report;
00025
00026 public:
00027 RingFactory (Buff_tail* outlet, std::ifstream& input, Buff_tail* rD, SimringReport* rep);
00028 ~RingFactory();
00029
00030 virtual int main();
00031
00032
00033 double getNextPaletteTime() const;
00034
00035
00036 void interrupt (int cause);
00037 void goAhead (int cause);
00038
00039
00040 struct InputLine {
00041 std::string date;
00042
00043 std::string start;
00044 std::string material;
00045 Procedure WBH;
00046 BathType cooling;
00047 int numberOfRings;
00048 long commission;
00049 double diameter;
00050 double height;
00051 double mass;
00052 double time;
00053 double totalTime;
00054 double setupTime;
00055 double temp1, temp2;
00056
00057
00058 InputLine () {
00059 numberOfRings = commission = 0;
00060 diameter = height = mass = totalTime = 0.0;
00061 time = setupTime = temp1 = temp2 = 0.0;
00062 }
00063 };
00064 protected:
00065 bool stopped;
00066
00067 private:
00068
00069 long Yb, Mb, Db, hb, mb;
00070
00071 Count *genStacks;
00072 Count *genPaletties;
00073
00074 Count *allComms;
00075 Count *allCommsToHandle;
00076 Count *allCommsNotToHandle;
00077 Count *gluehComms;
00078
00079 Count *allRings;
00080 Count *allRingsToHandle;
00081 Count *allRingsNotToHandle;
00082 Count *gluehRings;
00083
00084 Sum *minDays;
00085
00086 Histo *oventime;
00087 Tally *overflow;
00088
00089 std::list<SetOfRingStack*> paletts;
00090
00091 SIMTIME now;
00092 SIMTIME nextPalletAt;
00093
00094 bool firstTime;
00095 bool mixedPalette;
00096
00097
00098 bool loadDayPlan(std::queue<InputLine*>& plan, int& ringCount);
00099 InputLine* readLine();
00100 bool toHandle(InputLine *);
00101 bool selectOther(InputLine *);
00102
00103 CustomerRequest* createRequest(const InputLine& line);
00104 static const Steelworks::Pallet& getVisPallet(SetOfRingStack* p);
00105
00106 bool readDate(const std::string& date, int& Y, int& M, int& D);
00107 bool readTime(const std::string& time, int& Hour, int& Minute, bool& NoTime);
00108 double getSimTime(int Y, int M, int D, int h, int m);
00109
00110
00111 friend std::istream& operator >>(std::istream& in, RingFactory::InputLine& l);
00112 };
00113
00114 #endif