]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/centralstation.cpp
Pass sensor events through blocks
[r2c2.git] / source / libr2c2 / centralstation.cpp
index 6a8de96694f3d9ada60020ff06dc4a018a676de6..dd0cbcf58ef13709cd25989324090cd19a0cf5db 100644 (file)
@@ -250,15 +250,6 @@ bool CentralStation::get_sensor(unsigned addr) const
 
 void CentralStation::tick()
 {
-       Time::TimeStamp t = Time::now();
-       for(SensorMap::iterator i=sensors.begin(); i!=sensors.end(); ++i)
-               if(i->second.off_timeout && t>i->second.off_timeout)
-               {
-                       i->second.state = false;
-                       i->second.off_timeout = Time::TimeStamp();
-                       signal_sensor.emit(i->first, i->second.state);
-               }
-
        while(Message msg = receive())
        {
                if(msg.footer.code)
@@ -599,17 +590,11 @@ void CentralStation::process_object(unsigned id, const Message::AttribMap &attri
                                        unsigned addr = base*16+j+1;
                                        Sensor &sensor = sensors[addr];
                                        bool s = state&(1<<j);
-                                       if(s)
+                                       if(s!=sensor.state)
                                        {
-                                               sensor.off_timeout = Time::TimeStamp();
-                                               if(!sensor.state)
-                                               {
-                                                       sensor.state = true;
-                                                       signal_sensor.emit(addr, sensor.state);
-                                               }
+                                               sensor.state = s;
+                                               signal_sensor.emit(addr, sensor.state);
                                        }
-                                       else if(sensor.state)
-                                               sensor.off_timeout = Time::now()+700*Time::msec;
                                }
                        }
                }