/*
 * device.h
 *
 *  Created on: 4 Jun 2013
 *      Author: john
 */

#ifndef DEVICE_H_
#define DEVICE_H_

#include <object.h>

class cObjectDevice : public cObject
{

public:
   cObjectDevice();
   cObjectDevice(cObjectDevice *obj);
   ~cObjectDevice();

   cTagList * getTags();
   bool parse(KourierObject *, std::vector<KTag*>* ct = NULL);


	//potential problem with conversion as library returns double and we are casting to float.
	bool parse(json_t *dataArray); //JSON
	   //uses the append_new function for return arrays so that the json ref stays at 1
	   //returns an array of all the values
	json_t * getJSONObj(); //for JSON


   bool compIndex(cObject *obj);
   bool operator <(cObject &rhs);
   char * printKey();
   cObject * clone();

   enum eDeviceType
   {
      TYPE_UNKNOWN,
	  TYPE_DISCRETE_IO,
	  TYPE_AC_MONITOR,
	  TYPE_HUMID_TEMP_IN,
	  TYPE_HUMID_TEMP_IO,
	  TYPE_SNMP,
	  TYPE_MODBUS,
	  TYPE_DLMS,
	  TYPE_VEEDER_ROOT,
	  TYPE_CAMERA,
      TYPE_GSM
   };

   uint32_t getAnalogInCount() const;
   uint32_t getAnalogOutCount() const;
   void setAnalogInCount(uint32_t);
   void setAnalogOutCount(uint32_t);

   const char* getDeviceLabel() const;
   void setDeviceLabel(const char* deviceLabel);
   eObjectOpState getDeviceOpState() const;
   void setDeviceOpState(eObjectOpState deviceOpState);
   uint32_t getDeviceSerial() const;
   void setDeviceSerial(uint32_t);
   eObjectStatus getDeviceStatus() const;
   void setDeviceStatus(eObjectStatus s);
   eDeviceType getDeviceType() const;
   void setDeviceType(eDeviceType);
   uint32_t getDiscreteInCount() const;
   void setDiscreteInCount(uint32_t);
   uint32_t getDiscreteOutCount() const;
   void setDiscreteOutCount(uint32_t);
   uint32_t getVersion() const;
   void setVersion(uint32_t);

private:
   void populate_tags(KTag* tag);
   /* Keys */
   uint32_t mDeviceSerial;

   /*Local RW data*/
   char *mDeviceLabel;
   eObjectOpState mDeviceOpState;

   /*Local RO data */

   /*Device RW data */

   /*Device RO data*/
   eObjectStatus mDeviceStatus;
   eDeviceType mDeviceType;
   uint32_t mDiscreteInCount;
   uint32_t mDiscreteOutCount;
   uint32_t mAnalogInCount;
   uint32_t mAnalogOutCount;
   uint32_t mVersion;

};

#endif /* DEVICE_H_ */
