📄 item.h
字号:
#if !defined(_ITEM34_H)
#define _ITEM34_H
#include <stdio.h>
//#include "datatype.h"
#define ItemOutStrSize 14
/*//////////////////////////////////////////////////////////////////////////
**** Item class Note ****
Item class is the base class in CS2092V3.4. Two types of item instance
can be defined upon it, and they are:
(1) related item: TextStr = NULL
(2) comment item: TextStr != NULL, which points to a char string;
Many other items can be derived from item class.
RIdx is a flag for possible related items, it is set with a public
routine by higher user, and used as return value for GetOutStr(). Normally,
RIdx!=0 means that the item is with something which is beyond item's scope,
and higher module, for example menu, having to do something with it. With
using of RIdx, item type classes become much more clear and dignity, no mess
at all.
The member function OutStrAvailable() is used to tell whether the current
item is a related item which outstring is depends on other item.
OutStrAvailable( ) == 1: normal item
OutStrAvailable( ) == 0: related item
OutStrAvailable( ) == 2: comment item
The member function DefineItem( ... ) is the base function in class.
User use pValue for item initial value, and pParStruct for relavent para-
meters for the current item modification. User can define various different
parameter structure to create new item easily with C++'s virtual function.
The member function Value( ... ) is used to return item current value
to higher module. The pointer argument void* can be used to transfer data
structure if necessary.
//////////////////////////////////////////////////////////////////////////*/
class Item
{
protected:
char* OutStr; // max ItemOutStrSize permitted
char Prefix[15]; // max 12 chars permitted
char Unit[5]; // max 4 chars permitted
int RIdx; // related item mark
int HighLight; // default = -1;
void MakeOutStr( char* VUStr );
public:
Item( );
~Item( );
void SetNameUnit( char* PreStr="", char* UnitStr="" );
void SetRelation( int RNum ) { RIdx = RNum; }
int OutStrAvailable( );
int GetHighLight( ) { return HighLight; }
void DefineItem( char* TextStr=NULL );
virtual float Value( void* pParStruct=NULL ) { return 0; };
virtual void ValueInc( ) { };
virtual void ValueDec( ) { };
virtual void ValueINC( ) { };
virtual void ValueDEC( ) { };
virtual int GetOutStr( char* StrBuf ); // return RIdx
};
/*//////////////////////////////////////////////////////////////////////////
*** Derived class from Item ***
(1) Item_i: integer type item class
(2) Item_l: long integer type item class
(3) Item_f: float type item class
(4) Item_e: enum type item class
(5) Item_w: wave data type item class
(6) Item_Fs: sampling rate type item class
(7) Item_s: internal trigger slope type item class
(8) Item_t: internal trigger level type item class
Each derived class has different parameter structure, which will be defined
below.
//////////////////////////////////////////////////////////////////////////*/
/*/////////////////////////////////////////////////////////////////////
*** Item_i Definition Note ***
(1) InitV = init value
(2) pParStruct is just for compatibility, never used
(3) It is recommanded to using (int)A_Item_i.Value( ) to get value
/////////////////////////////////////////////////////////////////////*/
class Item_i: public Item
{
int V;
int MaxV;
int MinV;
int delta;
int DELTA;
public:
Item_i( );
~Item_i( );
void DefineItem( int InitV, int Max, int Min, int d, int D );
float Value( void* pParStruct=NULL );
void ValueInc( );
void ValueDec( );
void ValueINC( );
void ValueDEC( );
int GetOutStr( char* StrBuf );
};
/*////////////////////////////////////////////////////////
*** Item_e Definition Note ***
(1) InitV = init value
(2) pParStruct is never used, just for compatility
(3) It is recommanded to using (int)A_Item_e.Value( ) to get value
////////////////////////////////////////////////////////*/
class Item_e: public Item
{
int V;
int NumStr;
char** EnumAddr;
public:
Item_e( );
~Item_e( );
void DefineItem( int EnumIdx, int NumEnum, char** EnumPtr );
float Value( void* pParStruct=NULL );
void ValueInc( );
void ValueDec( );
void ValueINC( );
void ValueDEC( );
int GetOutStr( char* StrBuf );
};
/*//////////////////////////////////////////////////////////////////////////
*** Item_f Definition Note ***
In member function DefineItem(...)
(1) InitV = init value
(2) (Max, Min) for the scope of the float variance
(3) Item_f output format: "馹.____馹"
(4) coarse setting to shift hight light position
(5) fine setting to change value:
digital position: 0..9
sign position: +, -
(6) Decimal_dot position, =0: X.XXX..; =1: XX.XX.., and so on
(7) In function DefineItem(..),
ExpPrecision=0, EffPrecision<=6
ExpPrecision=1, EffPrecision<=5
ExpPrecision=2, EffPrecision<=4
pParStruct is never used, just for compatility
/////////////////////////////////////////////////////////////////////////*/
class Item_f: public Item
{
int NumItem;
int ActItem;
int DecimalIdx; // Decimal_dot position, =0: X.XXX
Item_i* SignDigital;
int NumExp; // max = 2, min = 0;
int NumEff; // max = 6, min = 2;
public:
Item_f( );
~Item_f( );
void DefineItem( float InitV, int EffPrecision, int ExpPrecison=0 );
float Value( void* pParStruct=NULL );
void ValueInc( );
void ValueDec( );
void ValueINC( );
void ValueDEC( );
int GetOutStr( char* StrBuf );
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -