Тогда это для Вас будет полезно :) #include <stdio.h>
#include <string.h>
#include "HTI_typedef.h"
#include "HTI_ports.h"
#include "HTI_globals.h"
#include "HTI_objects.h"
#include "HTI_loader.h"
//#include "HTI_domp_serial.h"
#include "HTI_objects_impl.h"
#include "HTI_motors.h"
#include "HTI_macro.h"
#if ((defined CANRS)|(defined CANUSB))
void GetName (DompParserResultType * dpr) {}
void GetVar (DompParserResultType * dpr) {}
void SetVar (DompParserResultType * dpr) {}
#else
#define OBJECT_GETNAME(obj) object_methods[obj][0](dpr)
#define OBJECT_GETVAR(obj) object_methods[obj][1](dpr)
#define OBJECT_SETVAR(obj) object_methods[obj][2](dpr)
#define DEBUG_GETNAME(obj) debug_methods[25 - (obj)][0]()
#define DEBUG_GETVAR(obj) debug_methods[25 - (obj)][1]()
#define DEBUG_SETVAR(obj) debug_methods[25 - (obj)][2]()
#ifdef HTIP
#define OBJECT_GETNAME_HP(obj) object_methods_hp[obj][0](dpr)
#define OBJECT_GETVAR_HP(obj) object_methods_hp[obj][1](dpr)
#define OBJECT_SETVAR_HP(obj) object_methods_hp[obj][2](dpr)
#endif
#define DECLARE_METHODS(dummy, obj_name) { obj_name##GetName, obj_name##GetVar, obj_name##SetVar }
__flash METHOD object_methods[][3] =
{ DECLARE_METHODS(A, system),
#if (defined(HTIM))
DECLARE_METHODS(B, obj_moa),
DECLARE_METHODS(C, obj_mob),
DECLARE_METHODS(D, obj_pca),
DECLARE_METHODS(E, obj_pcb),
DECLARE_METHODS(F, obj_pcx),
#endif
#if (defined(HTIP))
DECLARE_METHODS(B, obj_moa),
DECLARE_METHODS(C, obj_mob),
#endif
#ifdef HTIT
DECLARE_METHODS(B, obj_tca),
DECLARE_METHODS(C, obj_tcb),
DECLARE_METHODS(D, obj_tcc),
DECLARE_METHODS(E, obj_tch),
DECLARE_METHODS(F, obj_tcp),
DECLARE_METHODS(G, obj_moa),
DECLARE_METHODS(H, obj_dv),
#endif
};
#ifdef HTIP
__flash METHOD object_methods_hp[][3] =
{ DECLARE_METHODS(A, system_hp),
DECLARE_METHODS(B, obj_moa_hp),
DECLARE_METHODS(C, obj_mob_hp),
};
#endif
__flash uint OBJECTS_QUANTITY = COUNT_ELEMENTS(object_methods);
#ifdef USE_DEBUG_OBJECTS
__flash PROCEDURE debug_methods[][3] =
{
DECLARE_METHODS(Z, debug_info_),
// DECLARE_METHODS(Y, debug_motor_),
};
__flash uint DEBUG_QUANTITY = COUNT_ELEMENTS(debug_methods);
#endif
void GetName(DompParserResultType * dpr)
{ //dpr->tx_op_code = TxGetNameOpCode;
#ifndef HTIP
if (OBJECTS_QUANTITY > dpr->object) OBJECT_GETNAME(dpr->object);
#else
if (OBJECTS_QUANTITY > dpr->object) {
if (dpr->address==2) OBJECT_GETNAME_HP(dpr->object);
else if (dpr->address==3) OBJECT_GETNAME(dpr->object);}
#endif
else
#ifdef USE_DEBUG_OBJECTS
if (DEBUG_QUANTITY > 25 - unit) DEBUG_GETNAME(object); else
#endif
AbsentO();
// if (NameOpCode == var_status) CopyFlashToVarBuf(dpr->name); // to be moved to domp
}
void GetVar(DompParserResultType * dpr)
{
#ifndef HTIP
if (OBJECTS_QUANTITY > dpr->object) OBJECT_GETVAR(dpr->object);
#else
if (OBJECTS_QUANTITY > dpr->object) {
if (dpr->address==2) OBJECT_GETVAR_HP(dpr->object);
else if (dpr->address==3) OBJECT_GETVAR(dpr->object);}
#endif
else
#ifdef USE_DEBUG_OBJECTS
if (DEBUG_QUANTITY > 25 - unit) DEBUG_GETVAR(object); else
#endif
AbsentO();
}
void SetVar(DompParserResultType * dpr)
{
#ifndef HTIP
if (OBJECTS_QUANTITY > dpr->object)
// if ((!(dpr->object==0)|| (dpr->property==6)
OBJECT_SETVAR(dpr->object);
#else
if (OBJECTS_QUANTITY > dpr->object) {
if (dpr->address==2) OBJECT_SETVAR_HP(dpr->object);
else if (dpr->address==3) OBJECT_SETVAR(dpr->object);}
#endif
else
#ifdef USE_DEBUG_OBJECTS
if (DEBUG_QUANTITY > 25 - unit) DEBUG_SETVAR(object); else
#endif
AbsentO();
}
#endif