]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Ahora si que anda 10 puntos.
authorRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 3 Dec 2003 21:47:03 +0000 (21:47 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 3 Dec 2003 21:47:03 +0000 (21:47 +0000)
Model/include/splitter.h
Model/src/splitter.cpp

index a76c1179bb8e352eed39548340146c30ac2da20d..04d1c9f60de06a2c3b99eaad437d7d43b895dd6f 100644 (file)
@@ -23,6 +23,8 @@ public:
        virtual void update(int dir=OUT);
        virtual void simulate();
 protected:
+       int out_ready;
+       int out_on_zero;
 private:
        Splitter(const Splitter &):Transport("null") {}
        Splitter &operator = (const Splitter &) { return *this; }
index a2737894b6423758465aa960ca7c62b12bfe0864..38742f66e708d832b1f3b318b87b957bc9010645 100644 (file)
@@ -10,6 +10,7 @@ Splitter::Splitter(const std::string &_name):Transport(_name)
        out_slots = 2;
        max_flow = actual_flow = 0.0f;
        updated = true;
+       out_on_zero = out_ready = 0;
 }
 
 Splitter::~Splitter()
@@ -37,7 +38,8 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data)
 
                        if (max_flow < actual_flow) actual_flow = max_flow;
 
-                       actual_flow /= 2.0f;
+                       if (out_on_zero == 0)
+                               actual_flow /= 2.0f;
 
                        send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_flow);
 
@@ -55,11 +57,21 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data)
 #endif
                        if (pos == OUT) {
                                if (max == 0) {
-                                       actual_flow = max_flow;
+                                       out_on_zero++;
+                                       switch (out_on_zero) {
+                                               case 1:
+                                                       if (out_ready == 0) {
+                                                               actual_flow = max_flow;
+                                                       }
+                                               break;
+                                               case 2:
+                                                       actual_flow = 0.0;
+                                       }
                                } else {
                                        if (max < actual_flow)  actual_flow = max;
                                        if (max_flow < actual_flow) actual_flow = max_flow;
                                }
+                               out_ready++;
                        } else {
                                        if (((2*max) < actual_flow) && (max != 0))
                                                actual_flow = 2*max;
@@ -98,5 +110,6 @@ void Splitter::simulate()
 #endif
        updated = false;
        color_updated = false;
+       out_on_zero = out_ready = 0;
 }