00001 #ifndef _sensor_h_ 00002 #define _sensor_h_ 00003 #include "adevs.h" 00004 #include "ElectricalSensorInterface.h" 00005 00009 class Sensor 00010 { 00011 public: 00018 typedef enum { TIME_TR , STATE_TR } SensorType; 00025 Sensor(SensorType type, 00026 adevs::Devs<adevs::PortValue<BasicEvent*> >* device_model = NULL): 00027 type(type), 00028 device_model(device_model) 00029 { 00030 } 00035 adevs::Devs<adevs::PortValue<BasicEvent*> >* getDeviceModel() 00036 { 00037 return device_model; 00038 } 00043 virtual double distFromTrip(ElectricalSensorInterface* evars) = 0; 00050 virtual void trip(ElectricalSensorInterface* evars) = 0; 00052 SensorType getType() const { return type; } 00054 virtual ~Sensor() 00055 { 00056 } 00057 private: 00058 const SensorType type; 00059 adevs::Devs<adevs::PortValue<BasicEvent*> >* device_model; 00060 }; 00061 00065 class SensorEvent: 00066 public BasicEvent 00067 { 00068 public: 00069 SensorEvent(Sensor* cause): 00070 BasicEvent(),cause(cause){} 00071 Sensor* getCause() { return cause; } 00072 BasicEvent* clone() const { return new SensorEvent(cause); } 00073 private: 00074 Sensor* cause; 00075 }; 00076 00077 #endif