/*
 * SysCommons.h
 *
 *  Created on: 03.02.2017
 *      Author: Justus_RETHEM
 */

#ifndef CLASSES_SYSCOMMONS_H_
#define CLASSES_SYSCOMMONS_H_
#include "../globalDefines.h"

#include "Interfaces/I_SysCommons.hpp"

class SysCommons : public I_SysCommons{
public:
	SysCommons();
	 ~SysCommons();

	#define CURNT_OFST	2276;

	double CalcVoltageFromAdcDigits(unsigned int adcDigits);
	double CalcIpercFromSgndAdcDigits(signed int adcDigits);
	int RemOfstFromCur(unsigned int);

	#define PWM_MODE	0
	#define TOL_MODE	1
	unsigned int SetToPWMmode();
	unsigned int SetToTolMode();
	unsigned int GetMode();

	void SetAvailableFlag();
	void ClrAvailableFlag();
	unsigned char GetAvailableFlag();

	void PutPosZwKrsRef(unsigned int* Uref);
	unsigned int GetPosZwKrsRawVal();

	void PutNegZwKrsRef(unsigned int* Uref);
	unsigned int GetNegZwKrsRawVal();

	void SetPosPinHigh();
	void SetPosPinLow();
	unsigned int GetPosPinCmd();
	void SetNegPinHigh();
	void SetNegPinLow();
	unsigned int GetNegPinCmd();

	unsigned char GetPosPinFeedBack();
	unsigned char GetNegPinFeedBack();

	void SetPosPortAndPin(unsigned int* portPtr, unsigned int pinMask);
	void SetNegPortAndPin(unsigned int* portPtr, unsigned int pinMask);

	void SetPosPortAndPinFeedBack(unsigned int* portPtr, unsigned int pinMask);
	void SetNegPortAndPinFeedBack(unsigned int* portPtr, unsigned int pinMask);

	void PutActualUeffSollDigit(unsigned int uEffDigit);
	unsigned int GetActualUeffSollDigit();
	void PutActualIeffSollDigit(signed int iEffDigit);
	signed int GetActualIeffSollDigit();
	void PutActualIbandDigit(signed int iEffDigit);
	signed int GetActualIbandDigit();

private:


	unsigned int* UposRefZwkrs;
	unsigned int* UnegRefZwkrs;

	unsigned int* posPortPtr;
	unsigned int  posBitMsk;
	unsigned int* negPortPtr;
	unsigned int  negBitMsk;

	unsigned int* posPortPtrFb;
	unsigned int  posBitMskFb;
	unsigned int* negPortPtrFb;
	unsigned int  negBitMskFb;

	unsigned int pwmOrTolMode;

	unsigned char availableFlag;

	unsigned int myActualUeffDigits;
	signed int myActualIeffDigits;
	signed int myActualIbandDigits;
};

#endif /* CLASSES_SYSCOMMONS_H_ */
