/*
 * ModBusObject1_1.hpp
 *
 *  Created on: 27 θών. 2017 γ.
 *      Author: Ilia Tikhomirov
 */

#ifndef MODBUSOBJECT1_1_HPP_
#define MODBUSOBJECT1_1_HPP_

#ifdef __cplusplus

#include <stddef.h>

/**************************************************************************************************************************/
/*MODBUS FRAM TEMPLATES */
/**************************************************************************************************************************/

template <class T> class ModBusIB;
template <class T> class ModBusIR;
template <class T> class ModBusOB;
template <class T> class ModBusOR;

template <class T1, class T2 = void, class T3 = void, class T4 = void>
class ModBusFram;

template <class T>
class ModBusFram<ModBusIB<T>, void,  void, void >
{
public:
	T InputBits;
};

template <class T1, class T2, class T3, class T4>
class ModBusFram<ModBusIB<T1>, ModBusIR<T2>,  ModBusOB<T3>, ModBusOR<T4> >
{
public:
	T1 InputBits;
	T2 InputRegs;
	T3 OutputBits;
	T4 OutputRegs;
};

/**************************************************************************************************************************/
/*MODBUS SRAM TEMPLATES */
/**************************************************************************************************************************/

template <class T1, class T2 = void, class T3 = void, class T4 = void>
class ModBusSram;


template <class T1, class T2, class T3, class T4>
class ModBusSram<ModBusIB<T1>, ModBusIR<T2>,  ModBusOB<T3>, ModBusOR<T4> >
{
public:
	T1 InputBits;
	T2 InputRegs;
	T3 OutputBits;
	T4 OutputRegs;
};

template <class T1, class T2>
class ModBusSram<ModBusIB<T1>,  ModBusOB<T2> >
{
public:
	T1 InputBits;
	T2 OutputBits;
};

template <class T1, class T2 = void>
class ModBusDirect;

template <class T1, class T2, class T5, class T6, class T7, class T8>
class ModBusDirect<ModBusSram<ModBusIB<T1>, ModBusOB<T2> >,  ModBusFram<ModBusIB<T5>, ModBusIR<T6>, ModBusOB<T7>, ModBusOR<T8> > >
{
public:
	ModBusSram<ModBusIB<T1>, ModBusOB<T2> >											Sram;
	ModBusFram<ModBusIB<T5>, ModBusIR<T6>, ModBusOB<T7>, ModBusOR<T8> > 			Fram;

	struct
	{
		T5 Bits;
		T6 Regs;
	} Defaults;

	void DefaultsApply()
	{
		Fram.InputBits = Defaults.Bits;
		Fram.InputRegs = Defaults.Regs;
	}
};

#endif

#endif /* MODBUSOBJECT1_1_HPP_ */
