// Note: Instrumentation statements are highlighted in green
#ifndef __DEVICES_HPP
#define __DEVICES_HPP
// Disable warning "identifier was truncated to '255' characters in the browser information"
#pragma warning (disable : 4786)
#include <vutility.hpp>
#include <iostream>
using namespace std;
using namespace visibility;
///////////////////////////////////////////////////////////////////////////////
// Device type flags and device status flags
///////////////////////////////////////////////////////////////////////////////
const unsigned short UNDEFINED_DEVICE = 0x0001;
const unsigned short DOOR_LOCK = 0x0002;
const unsigned short WINDOW_LOCK = 0x0003;
const unsigned short MOTION_DETECTOR = 0x0004;
const unsigned short SMOKE_DETECTOR = 0x0005;
const unsigned short LIGHT_CONTROLLER = 0x0006;
const unsigned short THERMOSTAT = 0x0007;
const unsigned short ELECTRICAL_OUTLET = 0x0008;
const unsigned short ALL_DEVICES = 0xFFFF;
const unsigned long NON_OPERATIONAL = 0x0001;
const unsigned long DEVICE_ON = 0x0002;
const unsigned long DEVICE_OK = 0x0004;
const unsigned long DEVICE_ACTIVE = 0x0008;
const unsigned long DEVICE_CLOSED = 0x0010;
const unsigned long DEVICE_LOCKED = 0x0020;
const unsigned long DEVICE_SECURED = 0x0040;
const unsigned long DEVICE_TRIGGERED = 0x0080;
const unsigned long TURN_ON = 0x0001;
const unsigned long TURN_OFF = 0x0002;
const unsigned long ACTIVATE = 0x0003;
const unsigned long DEACTIVATE = 0x0004;
const unsigned long SECURE = 0x0005;
const unsigned long UNSECURE = 0x0006;
///////////////////////////////////////////////////////////////////////////////
// Bitset definitions
///////////////////////////////////////////////////////////////////////////////
VBITSET_START(DeviceStatus)
VINCLUSIVE_VALUE(NON_OPERATIONAL, "Non operational", 0)
VINCLUSIVE_VALUE(DEVICE_ON, "On", 0)
VINCLUSIVE_VALUE(DEVICE_OK, "Ok", 0)
VINCLUSIVE_VALUE(DEVICE_ACTIVE, "Active", 0)
VINCLUSIVE_VALUE(DEVICE_CLOSED, "Closed", 0)
VINCLUSIVE_VALUE(DEVICE_LOCKED, "Locked", 0)
VINCLUSIVE_VALUE(DEVICE_SECURED, "Secured", 0)
VINCLUSIVE_VALUE(DEVICE_TRIGGERED, "Triggered", 0)
VBITSET_END
VBITSET_START(DeviceType)
VEXCLUSIVE_VALUE(DOOR_LOCK, ALL_DEVICES, "Door lock", 0)
VEXCLUSIVE_VALUE(WINDOW_LOCK, ALL_DEVICES, "Window lock", 0)
VEXCLUSIVE_VALUE(MOTION_DETECTOR, ALL_DEVICES, "Motion detector", 0)
VEXCLUSIVE_VALUE(SMOKE_DETECTOR, ALL_DEVICES, "Smoke detector", 0)
VEXCLUSIVE_VALUE(LIGHT_CONTROLLER, ALL_DEVICES, "Light", 0)
VEXCLUSIVE_VALUE(ELECTRICAL_OUTLET, ALL_DEVICES, "Electrical outlet", 0)
VEXCLUSIVE_VALUE(THERMOSTAT, ALL_DEVICES, "Thermostat", 0)
VBITSET_END
///////////////////////////////////////////////////////////////////////////////
// DeviceController
///////////////////////////////////////////////////////////////////////////////
class DeviceController : public VObject // Add VObject to the inheritance chain
{
DECLARE_VISIBILITY(DeviceController) // Instrumentation statement
public: // data
unsigned short type;
string name;
unsigned long status;
float xLocation;
float yLocation;
public: // functions
DeviceController(void);
DeviceController(char * _name, unsigned short _type);
DeviceController(const DeviceController & that);
virtual ~DeviceController(void);
virtual void populateEditView(void);
virtual DeviceController * createCopy(void);
DeviceController & operator=(const DeviceController &that);
virtual ostream & operator<<(ostream & stream);
virtual istream & operator>>(istream & stream);
virtual bool processCommand(unsigned long command) {return false;};
virtual unsigned short getPosition(float x_origin, float y_origin,
float & object_x, float & object_y,
unsigned short coord_type);
virtual unsigned short setPosition(float x_origin, float y_origin,
float object_x, float object_y,
unsigned short coord_type);
};
DECLARE_VISIBILITY_CREATOR(DeviceController) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// DoorLock class
///////////////////////////////////////////////////////////////////////////////
class DoorLock : public DeviceController
{
DECLARE_VISIBILITY(DoorLock) // Instrumentation statement
public: // functions
DoorLock(void);
DoorLock(const DoorLock & that);
virtual ~DoorLock(void) {};
virtual DeviceController * createCopy(void);
virtual bool processCommand(unsigned long command);
void lock(void);
void unlock(void);
void alarmOn(void);
void alarmOff(void);
};
DECLARE_VISIBILITY_CREATOR(DoorLock) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// WindowLock class
///////////////////////////////////////////////////////////////////////////////
class WindowLock : public DeviceController
{
DECLARE_VISIBILITY(WindowLock) // Instrumentation statement
public: // functions
WindowLock(void);
WindowLock(const WindowLock & that);
virtual ~WindowLock(void) {};
virtual DeviceController * createCopy(void);
virtual bool processCommand(unsigned long command);
void lock(void);
void unlock(void);
void alarmOn(void);
void alarmOff(void);
};
DECLARE_VISIBILITY_CREATOR(WindowLock) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// MotionDetector class
///////////////////////////////////////////////////////////////////////////////
class MotionDetector : public DeviceController
{
DECLARE_VISIBILITY(MotionDetector) // Instrumentation statement
public: // functions
MotionDetector(void);
MotionDetector(const MotionDetector & that);
virtual ~MotionDetector(void) {};
virtual DeviceController * createCopy(void);
virtual bool processCommand(unsigned long command);
void turnOn(void);
void turnOff(void);
};
DECLARE_VISIBILITY_CREATOR(MotionDetector) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// SmokeDetector class
///////////////////////////////////////////////////////////////////////////////
class SmokeDetector : public DeviceController
{
DECLARE_VISIBILITY(SmokeDetector) // Instrumentation statement
public: // functions
SmokeDetector(void);
SmokeDetector(const SmokeDetector & that);
virtual ~SmokeDetector(void) {};
virtual DeviceController * createCopy(void);
virtual bool processCommand(unsigned long command);
void turnOn(void);
void turnOff(void);
};
DECLARE_VISIBILITY_CREATOR(SmokeDetector) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// LightController class
///////////////////////////////////////////////////////////////////////////////
class LightController : public DeviceController
{
DECLARE_VISIBILITY(LightController) // Instrumentation statement
public: // functions
unsigned short brightness;
unsigned short wattage;
LightController(void);
LightController(const LightController & that);
virtual ~LightController(void) {};
virtual DeviceController * createCopy(void);
LightController & operator=(const LightController &that);
virtual ostream & operator<<(ostream & stream);
virtual istream & operator>>(istream & stream);
virtual bool processCommand(unsigned long command);
void turnOn(void);
void turnOff(void);
};
DECLARE_VISIBILITY_CREATOR(LightController) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// ElectricalOutlet class
///////////////////////////////////////////////////////////////////////////////
class ElectricalOutlet : public DeviceController
{
DECLARE_VISIBILITY(ElectricalOutlet) // Instrumentation statement
public: // functions
ElectricalOutlet(void);
ElectricalOutlet(const ElectricalOutlet & that);
virtual ~ElectricalOutlet(void) {};
virtual DeviceController * createCopy(void);
virtual bool processCommand(unsigned long command);
void turnOn(void);
void turnOff(void);
};
DECLARE_VISIBILITY_CREATOR(ElectricalOutlet) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// Thermostat class
///////////////////////////////////////////////////////////////////////////////
class Thermostat : public DeviceController
{
DECLARE_VISIBILITY(Thermostat) // Instrumentation statement
public: // functions
float minTemp;
float maxTemp;
float currentTemp;
Thermostat(void);
Thermostat(const Thermostat & that);
virtual ~Thermostat(void) {};
virtual DeviceController * createCopy(void);
Thermostat & operator=(const Thermostat &that);
virtual ostream & operator<<(ostream & stream);
virtual istream & operator>>(istream & stream);
virtual bool processCommand(unsigned long command);
};
DECLARE_VISIBILITY_CREATOR(Thermostat) // Instrumentation statement
///////////////////////////////////////////////////////////////////////////////
// DeviceList class
///////////////////////////////////////////////////////////////////////////////
class DeviceList : public vptr_list<DeviceController *>
{
public:
DeviceList(void);
DeviceList(DeviceList & device_list);
virtual ~DeviceList(void);
DeviceList & operator=(const DeviceList &device_list);
void clear(void);
};
///////////////////////////////////////////////////////////////////////////////
// DeviceTypes class
///////////////////////////////////////////////////////////////////////////////
class DeviceTypes : public DeviceList
{
public:
DeviceTypes(void);
DeviceTypes(DeviceTypes & device_types);
virtual ~DeviceTypes(void) {};
};
#endif // __DEVICES_HPP
|