/*
 * ainput.h
 *
 *  Created on: 11 Jul 2013
 *      Author: john
 */

#ifndef AINPUT_H_
#define AINPUT_H_

#include <port.h>

class cObjectAInput: public cObjectPort
{
public:
   enum eAnalogInputType
	   {
			PORT_ANALOG_IN_TYPE_UNKNOWN,
			PORT_ANALOG_IN_TYPE_DUMB,//SampleRate in minutes, all logic in rsmd
			PORT_ANALOG_IN_TYPE_SMART,//SampleRate in seconds, all logic in rsmd
			PORT_ANALOG_IN_TYPE_GENIUS//SampleRate in seconds, all logic on device
	   };

	cObjectAInput();
	cObjectAInput(cObjectAInput *obj);
	~cObjectAInput();
	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 *);
	bool operator <(cObject &);
	char * printKey();
	cObject * clone();
	float getAlarmHighError() const;
	void setAlarmHighError(float alarmHighError);
	float getAlarmHighWarn() const;
	void setAlarmHighWarn(float alarmHighWarn);
	float getAlarmLowError() const;
	void setAlarmLowError(float alarmLowError);
	float getAlarmLowWarn() const;
	void setAlarmLowWarn(float alarmLowWarn);
	float getCalculatedValue() const;
	void setCalculatedValue(float calculatedValue);
	const char* getDisplayUnit() const;
	void setDisplayUnit(const char* displayUnit);
	float getGain() const;
	void setGain(float gain);
	float getOffset() const;
	void setOffset(float offset);
	uint32_t getReportRate() const;
	void setReportRate(uint32_t reportRate);
	float getSampledValue() const;
	void setSampledValue(float sampledValue);
	uint32_t getSampleRate() const;
	void setSampleRate(uint32_t sampleRate);
	uint32_t getLastSampleSeq() const;
	void setLastSampleSeq(uint32_t lastSampleSeq);
	uint32_t getSampleCounter() const;
	void setSampleCounter(uint32_t sampleCounter);
	float getAcceptableNoise() const;
	void setAcceptableNoise(float noise);
	eAnalogInputType getAnalogInputType() const;
	void setAnalogInputType(eAnalogInputType analogInputType);


private:

   void populate_tags(KTag* tag);

   float mSampledValue;
   float mOffset;
   float mGain;
   float mCalculatedValue;
   float mAlarmLowWarn;
   float mAlarmLowError;
   float mAlarmHighWarn;
   float mAlarmHighError;
   uint32_t mSampleRate;
   uint32_t mReportRate;
   char * mDisplayUnit;
   uint32_t mLastSampleSeq;
   uint32_t mSampleCounter;
   float mAcceptableNoise;//Value added in order to calculate noise thresholds
   eAnalogInputType mAnalogInputType;

};

#endif /* AINPUT_H_ */
