Переглянути джерело

Z991239-5890 #comment 事件转换逻辑调整优化

80274480 9 місяців тому
батько
коміт
3fef7481ca

+ 7 - 1
Module/mod_evtconverter/CustomerApproachEvent.hpp

@@ -1,3 +1,6 @@
+#ifndef _CUSTOMER_APPROACH_EVENT_HPP
+#define _CUSTOMER_APPROACH_EVENT_HPP
+
 #pragma once
 
 #include "slot.h"
@@ -858,4 +861,7 @@ rvc_trigger_t CustomerApproachTriggerList[] = {
 	trigAgentEvent,
 	trigLeaveToControlEvent,
 	trigCallHangupEvent
-};
+};
+
+
+#endif

+ 6 - 1
Module/mod_evtconverter/SipphoneEvent.hpp

@@ -1,3 +1,6 @@
+#ifndef _SIPPHONE_EVENT_HPP
+#define _SIPPHONE_EVENT_HPP
+
 #pragma once
 
 #include "slot.h"
@@ -341,4 +344,6 @@ rvc_trigger_t SipphoneTriggerList[] = {
 	trigHangupEvent1,
 	trigHangupEvent2,
 	trigHangupEvent3
-};
+};
+
+#endif

+ 42 - 28
Module/mod_evtconverter/evtengine.cpp

@@ -10,9 +10,6 @@
 #include "fileutil.h"
 #include "scew.h"
 
-#include "SipphoneEvent.hpp"
-#include "CustomerApproachEvent.hpp"
-
 #if 0
 <?xml version="1.0" encoding="utf-8"?>
 	<Transfer xmlns="test">
@@ -47,10 +44,6 @@
 #define MAX_PATH 260
 #endif
 
-//#ifndef RVC_USE_XML
-//#define RVC_USE_XML 1
-//#endif // !RVC_USE_XML
-
 
 typedef struct evt_filter_key_t evt_filter_key_t;
 typedef struct evt_filter_t evt_filter_t;
@@ -64,7 +57,7 @@ typedef struct evt_slot_rule_t evt_slot_rule_t;
 typedef struct evt_trigger_t evt_trigger_t;
 typedef struct evt_slotvar_t evt_slotvar_t;
 
-static int nIslog = 0;
+static int nIslog = 1;
 
 struct evt_filter_key_t 
 {
@@ -2584,24 +2577,27 @@ on_error:
 }
 
 
-static int load_strategy_array(evt_engine_t* engine)
+static int load_strategy_array(evt_engine_t* engine, slot_trigger_elem_t* pelement)
 {
-	const char* ns = "SipphoneEvent";
+	const char* ns = pelement->slotns;
 	int rc = Error_Param;
 
-	for (int islot = 0; islot < sizeof(SipphoneSlotList) / sizeof(rvc_slot_t); islot++) {
-		if (load_slot_arrays(engine, ns, &SipphoneSlotList[islot]) != 0) {
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ns = %s.", pelement->slotns);
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sizeof(pelement->slotarr) = %d.", sizeof(pelement->slotarr));
+	for (int islot = 0; islot < sizeof(pelement->slotarr) / sizeof(rvc_slot_t); islot++) {
+		if (load_slot_arrays(engine, ns, &pelement->slotarr[islot]) != 0) {
 			if (nIslog) {
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load slot list failed!");
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load slot array failed!");
 			}
 			return rc;
 		}
 	}
 
-	for (int itrigger = 0; itrigger < sizeof(SipphoneTriggerList) / sizeof(rvc_trigger_t); itrigger++) {
-		if (load_trigger_arrays(engine, ns, &SipphoneTriggerList[itrigger]) != 0) {
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sizeof(pelement->triggerarr) = %d.", sizeof(pelement->triggerarr));
+	for (int itrigger = 0; itrigger < sizeof(pelement->triggerarr) / sizeof(rvc_trigger_t); itrigger++) {
+		if (load_trigger_arrays(engine, ns, &pelement->triggerarr[itrigger]) != 0) {
 			if (nIslog) {
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load trigger list failed!");
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load trigger array failed!");
 			}
 			return rc;
 		}
@@ -2650,7 +2646,6 @@ int evt_engine_load(evt_engine_t *engine, int nfile, const char **files)
 	int i;
 	int rc = 0;
 
-#ifdef RVC_USE_XML
 	for (i = 0; i < nfile; ++i) {
 		const char* filename = files[i];
 		assert(filename);
@@ -2667,30 +2662,49 @@ int evt_engine_load(evt_engine_t *engine, int nfile, const char **files)
 			}
 		}
 	}
-#else
-	rc = load_strategy_array(engine);
+
+	rc = build_ref(engine);
 	if (rc != 0) {
-		if (nIslog) {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load strategy array failed!");
+		if (nIslog){
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("build ref failed!");
 		}
 		return rc;
 	}
-	else {
-		if (nIslog) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load strategy array success!");
-		}
+
+	if (nIslog){
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("build ref ok!");
 	}
-#endif // RVC_USE_XML
 
+	return rc;
+}
+
+int evt_engine_load(evt_engine_t* engine, int icount, slot_trigger_elem_t* parr) 
+{
+	int rc = 0;
+
+	for (int i = 0; i < icount; ++i) {
+		rc = load_strategy_array(engine, &parr[i]);
+		if (rc != 0) {
+			if (nIslog) {
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load strategy array failed!");
+			}
+			return rc;
+		}
+		else {
+			if (nIslog) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load strategy array success!");
+			}
+		}
+	}
 	rc = build_ref(engine);
 	if (rc != 0) {
-		if (nIslog){
+		if (nIslog) {
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("build ref failed!");
 		}
 		return rc;
 	}
 
-	if (nIslog){
+	if (nIslog) {
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("build ref ok!");
 	}
 

+ 10 - 0
Module/mod_evtconverter/evtengine.h

@@ -5,6 +5,15 @@
 
 #include "SpBase.h"
 
+#include "slot.h"
+#include "trigger.h"
+
+typedef struct slot_trigger_elem_s {
+	char* slotns;
+	rvc_slot_t* slotarr;
+	rvc_trigger_t* triggerarr;
+}slot_trigger_elem_t;
+
 typedef struct evt_engine_t evt_engine_t;
 
 typedef void (*evt_engine_timer_func)(int timer_id, void *user_data);
@@ -27,6 +36,7 @@ typedef struct evt_engine_callback_t
 int evt_engine_create(const evt_engine_callback_t *callback, evt_engine_t **p_engine);
 void evt_engine_destroy(evt_engine_t *engine);
 int evt_engine_load(evt_engine_t *engine, int nfile, const char **files);
+int evt_engine_load(evt_engine_t* engine, int icount, slot_trigger_elem_t* parr);
 int evt_engine_unload(evt_engine_t *engine);
 int evt_engine_process_log(evt_engine_t *engine, 
 							const CAutoArray<CUUID> &SubIDs,

+ 30 - 8
Module/mod_evtconverter/mod_evtconverter.cpp

@@ -5,6 +5,17 @@
 #include "fileutil.h"
 #include "modVer.h"
 
+#include "SipphoneEvent.hpp"
+#include "CustomerApproachEvent.hpp"
+
+//#ifndef RVC_USE_XML
+//#define RVC_USE_XML 1
+//#endif // !RVC_USE_XML
+
+static slot_trigger_elem_t slot_trigger_arr[] = {
+	{"SipphoneEvent", SipphoneSlotList, SipphoneTriggerList},
+	{"CustomerApproachEvent", CustomerApproachSlotList, CustomerApproachTriggerList}
+};
 
 class CEventConverterEntity : public CEntityBase, public ISysVarListener, public ILogListener
 {
@@ -38,15 +49,15 @@ public:
 
 		m_eDeviceType = RvcGetDeviceType();
 		CAutoArray<CSimpleStringA> ConfigFiles;
-		ConfigFiles.Init(1);
-		const int num = 1;
+		ConfigFiles.Init(2);
+		const int num = 2;
 		ConfigFiles[0] = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "SipphoneEvent.xml", strConfigDir.GetData());
-		//if (eCardStore == m_eDeviceType) {
-		//	ConfigFiles[1] = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "CustomerApproachEventCardStore.xml", strConfigDir.GetData());
-		//} 
-		//else {
-		//	ConfigFiles[1] = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "CustomerApproachEvent.xml", strConfigDir.GetData());
-		//}
+		if (eCardStore == m_eDeviceType) {
+			ConfigFiles[1] = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "CustomerApproachEventCardStore.xml", strConfigDir.GetData());
+		} 
+		else {
+			ConfigFiles[1] = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "CustomerApproachEvent.xml", strConfigDir.GetData());
+		}
 
 		CSmartPointer<IConfigInfo> spConfigCenterSetting;
 		Error = spEntityFunction->OpenConfig(Config_CenterSetting, spConfigCenterSetting);
@@ -84,6 +95,7 @@ public:
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create engine ok!");
 		}
 
+#ifdef RVC_USE_XML
 		if (num > 0) {
 			const char **files = new const char*[num];
 			for (int i = 0; i < num; ++i) {
@@ -99,7 +111,17 @@ public:
 				return (ErrorCodeEnum)rc;
 			}
 		}
+#else
+		if (num > 0) {
 
+			rc = evt_engine_load(engine, num, slot_trigger_arr);
+
+			if (rc != 0) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load config failed!");
+				return (ErrorCodeEnum)rc;
+			}
+	}
+#endif
 		rc = evt_engine_start(engine);
 		if (rc != 0) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start engine failed!");

+ 6 - 1
Module/mod_evtconverter/slot.h

@@ -1,3 +1,6 @@
+#ifndef _RVC_SLOT_H
+#define _RVC_SLOT_H
+
 #pragma once
 #include <stdio.h>
 
@@ -33,4 +36,6 @@ typedef struct rvc_slot_s {
 	rvc_slotvar_t Vars[RVC_SLOT_MAX_NUM];
 	rvc_slotfilter_t Filters[RVC_SLOT_MAX_NUM];
 	rvc_slotreset_t Reset[RVC_SLOT_MAX_NUM];
-}rvc_slot_t;
+}rvc_slot_t;
+
+#endif

+ 6 - 1
Module/mod_evtconverter/trigger.h

@@ -1,3 +1,6 @@
+#ifndef _RVC_TRIGGER_H
+#define _RVC_TRIGGER_H
+
 #pragma once
 #include <stdio.h>
 
@@ -28,4 +31,6 @@ typedef struct rvc_trigger_s {
 	rvc_triggerslot_t Slots[RVC_TRIG_MAX_NUM];
 	rvc_triggersysvar_t SysVars[RVC_TRIG_MAX_NUM];
 	char* strDelayer;
-}rvc_trigger_t;
+}rvc_trigger_t;
+
+#endif