Important Update:

- DeviceCore:
  - Allow different event output types: None, Simple or JSON
  - Add date & time to JSON events
This commit is contained in:
Charl Wentzel
2019-07-15 17:29:45 +02:00
parent 91a7707fef
commit df371d4f10
2 changed files with 118 additions and 32 deletions

View File

@@ -20,12 +20,14 @@
// Enumerated types
typedef enum { dtNone = 0, dtBool = 1, dtUnsigned16 = 2, dtSigned16 = 3, dtUnsigned32_HL = 4, dtUnsigned32_LH = 5,
dtSigned32_HL = 6, dtSigned32_LH = 7, dtFloat32_L = 8, dtFloat32_B = 9, dtString = 10 } EDeviceDataType;
// Constants
const char DataTypeCount = 10;
const char DataTypeName[][20] = { "None", "Boolean", "Unsigned16", "Signed16", "Unsigned32_HL", "Unsigned32_LH",
"Signed32_HL", "Signed32_LH", "Float32_L", "Float32_B", "String" };
typedef enum { et_None = 0, et_Simple = 1, et_JSON = 2 } EEventType;
const char EventTypeCount = 3;
const char EventTypeName[][10] = { "None", "Simple", "JSON" };
//---------------------------------------------------------------------------
// Structure prototypes
@@ -152,6 +154,12 @@ protected:
int PollRetry = 0; // No of polling retries that has timed out
int MaxRetries = 3; // Max allowed retries
// Event output
EEventType EventOutputType = et_None;
CDataMember * EventData = NULL;
const int EventMsgLen = 1000;
char EventMsg[1000] = {0};
// Manage Devices
bool DestroyDevice( TDevice ** Device );
@@ -298,6 +306,12 @@ protected:
if (!strcasecmp( TypeName, DataTypeName[Type])) break;
return (Type == DataTypeCount)? dtNone : (EDeviceDataType)Type;
}
inline EEventType GetEventType( const char * TypeName ) {
int Type;
for (Type = 0; Type < EventTypeCount; Type++)
if (!strcasecmp( TypeName, EventTypeName[Type])) break;
return (Type == EventTypeCount)? et_None : (EEventType)Type;
}
bool CompareParamString( const char * ParamValue, const int ParamLen, const char * Value, const int Len );