#ifndef INCLUDE_NODE_PORT_H_
#define INCLUDE_NODE_PORT_H_
#include <string.h>
#include <math.h>

class NodePort
{
protected:
	char mLabel[64];
public:
	NodePort(const char *label){ setLabel(label); }
	virtual ~NodePort(){}

	const char *getLabel(){ return mLabel; }
	void setLabel(const char *label){ strcpy(mLabel, label); }
};

class NodeDigitalInput : public NodePort
{
	bool mState;
public:
	NodeDigitalInput(const char* label) :
		NodePort(label),
		mState(false)
	{}
	virtual ~NodeDigitalInput(){}

	bool getState(){ return mState; }
	virtual void setState(bool state){ mState = state; }
};

class NodeAnalogInput : public NodePort
{
	double mValue;
	double mGain;
	double mOffset;
	char mUnit[16];
public:
	NodeAnalogInput(const char* label, const char *unit, double gain = 1, double offset = 0) :
		NodePort(label),
		mValue(NAN),
		mGain(gain),
		mOffset(offset)
	{
		strcpy(mUnit, unit);
	}
	virtual ~NodeAnalogInput(){}

	double getValue(){ return mValue; }
	virtual void setValue(double value){ mValue = value; }
	double getGain(){ return mGain; }
	double getOffset(){ return mOffset; }
	const char *getUnit(){ return mUnit; }
};

#endif /* INCLUDE_SAM_PORT_H_ */
