Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

RingStack.h

Go to the documentation of this file.
00001 #ifndef RINGSTACK_INCLUDED
00002 #define RINGSTACK_INCLUDED
00003 
00004 #include "Ring.h"
00005 
00006 #include <list>
00007 #include <cassert>
00008 #include <iostream>
00009 
00010 static const int MAX_STACK_HEIGHT = 1500;
00011 static const double MAX_MASS_PER_PALETTE = 16000.0;
00012 static const int MAX_DIAMETER_DIFF = 30;
00013 
00014 class RingStack : public std::list<class Ring*> {
00015         double x, y; // Platz auf Palette
00016         double height;
00017         double mass;
00018         double d;
00019         int noRings;
00020         SIMTIME lastRingAt;
00021 public:
00022         RingStack() : x(0.0), y(0.0), height(0.0), mass(0.0), d(0.0), noRings(0), lastRingAt(0.0) {}
00023         ~RingStack(){std::cout<<"~RingStack()\n";}
00024 
00025         friend std::ofstream& operator<<(std::ofstream& o, const RingStack& s)
00026         {
00027                 o<<s.d<<'\t'<<s.x<<'\t'<<s.y<<std::endl;
00028                 return o;
00029         }
00030 
00031         // Auftragsdaten
00032         class Treatment* getTreatment() const {return front()->getTreatment();}
00033 
00034         const std::string& getMaterial() const {return front()->getMaterial();}
00035         double getDiameter() const {return d;}  
00036         double getMass() const {return mass;}
00037         int     getNoRings() const {return noRings;}
00038         SIMTIME getLastRingAt() const { return lastRingAt; }
00039         double getMaxDiameter() const {return getDiameter() + MAX_DIAMETER_DIFF;}
00040 
00041         bool isCompatibleTo(RingStack* s) const {
00042                 if (empty() || s->empty())
00043                         return true;
00044 
00045                 return (front())->isCompatibleTo((s->front()));
00046         }
00047 
00048         bool canStackOn(Ring* r) const {
00049                 if (empty())
00050                         return true;
00051                 else if (r->canStackOn(front())) {
00052                         double dSoll = getDiameter();
00053                         double dIst  = r->getDiameter();
00054                         if ((height + r->getHeight()) < MAX_STACK_HEIGHT && 
00055                                 (fabs(dSoll-dIst)<=MAX_DIAMETER_DIFF) &&
00056                                 (mass + r->getMass() <= MAX_MASS_PER_PALETTE) )
00057                                 return true;
00058                         else
00059                                 return false;
00060                 } else
00061                         return false;
00062         }
00063 
00064         void stackOn(Ring* r) {
00065                 assert(canStackOn(r));
00066 
00067                 lastRingAt = r->getReadyTime();
00068                 if (empty()) // Durchmesser setzen
00069                         d = r->getDiameter();
00070 
00071                 push_back(r);
00072                 height += r->getHeight(); // Höhe aktualisieren
00073                 mass += r->getMass();     // Gewicht aktualisieren
00074                 noRings += 1;
00075         }
00076 
00077         void placeAt(double nx, double ny) {
00078                 x = nx;
00079                 y = ny;
00080         }
00081 
00082         double getX() const {return x;}
00083         double getY() const {return y;}
00084         double getHeight() const {return height;}
00085 
00086         void finished() {
00087                 std::list<Ring*>::iterator i;
00088                         
00089                 for (i=begin(); i!=end(); ++i)
00090                         (*i)->finished();
00091         }
00092 };
00093 
00094 #endif

Generated on Tue Apr 26 14:42:42 2005 for rollingmill by doxygen 1.3.6