📄 macros.h
字号:
//-------------------------------------------------------------------
// file name: macros.h
//
// - macros available within a sensor node are defined here
//
//-------------------------------------------------------------------
/**
* @name Node ID
* @ingroup group_macros
*/
//@{
/**- macro that returns a node's ID (value ranges from 0 to NNODES-1)
*
* @hideinitializer
*/
#define ID (int)parentModule()->index()
//@}
/**
* @name Graphics Related Macros
* @ingroup group_macros
*/
//@{
//
/**- macro that returns the color of a node (int value)
*- the value actually used is COLOR%MAXCOLOR
*
* @hideinitializer
*/
#define COLOR (int)(parentModule()->par("COLOR"))
/**- macro that returns the number of the graphical symbol used to display a node (int value)
*- the value actually used is KIND%MAXKIND
*
* @hideinitializer
*/
#define KIND (int)(parentModule()->par("KIND"))
// problems with using blackboard for the general parameters:
//#define COLOR *(int*)((blackboard*)this->parentModule()->submodule("sm_blackboard"))->lookupParam("gv_color")
//#define KIND *(int*)((blackboard*)this->parentModule()->submodule("sm_blackboard"))->lookupParam("gv_kind")
/**- macro that updates the color of a node
*- the value actually used is COLOR%MAXCOLOR
*
* @hideinitializer
*/
#define UPDATECOLOR(color) {\
parentModule()->par("COLOR") = color; \
char tempstring[30]; \
sprintf(tempstring,"p=%d,%d,exact;i=snode_%d_%d",PX+MX,PY+MY,COLOR % MAXCOLOR,KIND % MAXKIND); \
parentModule()->setDisplayString(tempstring); }
/**- macro that updates the kind of a node
*- the value actually used is KIND%MAXKIND
*
* @hideinitializer
*/
#define UPDATEKIND(kind) {\
parentModule()->par("KIND") = kind; \
char tempstring[30]; \
sprintf(tempstring,"p=%d,%d,exact;i=snode_%d_%d",PX+MX,PY+MY,COLOR % MAXCOLOR,kind % MAXKIND); \
parentModule()->setDisplayString(tempstring); }
/**- macro that updates both the color and the kind of a node
*- values actually used are: COLOR%MAXCOLOR, KIND%MAXKIND
*
* @hideinitializer
*/
#define UPDATEGRAPHICS(color,kind) {\
parentModule()->par("COLOR") = color; \
parentModule()->par("KIND") = kind; \
char tempstring[30]; \
sprintf(tempstring,"p=%d,%d,exact;i=snode_%d_%d",PX+MX,PY+MY,COLOR % MAXCOLOR,KIND % MAXKIND); \
parentModule()->setDisplayString(tempstring); }
/**- macro that refreshes the image and position of a node
*- slow execution speed
*
* @hideinitializer
*/
#define REFRESHIMAGE {\
char tempstring[30]; \
sprintf(tempstring,"p=%d,%d,exact;i=snode_%d_%d",PX+MX,PY+MY,COLOR % MAXCOLOR,KIND % MAXKIND); \
parentModule()->setDisplayString(tempstring); }
//@}
/**- current X position
*
* @hideinitializer
*/
#define PX (int)parentModule()->par("PX")
/**- current Y position
*
* @hideinitializer
*/
#define PY (int)parentModule()->par("PY")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -