|
@@ -0,0 +1,233 @@
|
|
|
+#ifndef _MOD_HIGH_VOLTAGE_BASE_H__
|
|
|
+#define _MOD_HIGH_VOLTAGE_BASE_H__
|
|
|
+
|
|
|
+#include "stdafx.h"
|
|
|
+#include "SpBase.h"
|
|
|
+#include "SpTest.h"
|
|
|
+
|
|
|
+/*one of test module: use to high voltage test*/
|
|
|
+
|
|
|
+namespace HighVoltage
|
|
|
+{
|
|
|
+#define eMsg_MessageBroadcase1 0
|
|
|
+#define eMsg_MessageBroadcase2 0
|
|
|
+
|
|
|
+#define eMsgSig_MessageBroadcase1 4367746706
|
|
|
+#define eMsgSig_MessageBroadcase2 4367746606
|
|
|
+
|
|
|
+ struct MessageBroadcase1
|
|
|
+ {
|
|
|
+ CSimpleStringA context;
|
|
|
+
|
|
|
+ void Serialize(SpBuffer& Buf)
|
|
|
+ {
|
|
|
+ auto& buf = Buf & context;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ struct MessageBroadcase2
|
|
|
+ {
|
|
|
+ CSimpleStringA context;
|
|
|
+
|
|
|
+ void Serialize(SpBuffer& Buf)
|
|
|
+ {
|
|
|
+ auto& buf = Buf & context;
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
+#include "HelloService_client_g.h"
|
|
|
+#include "SampleEntity_client_g.h"
|
|
|
+
|
|
|
+
|
|
|
+class SubSampleClient : public SampleEntity::SampleService_ClientBase
|
|
|
+{
|
|
|
+public:
|
|
|
+
|
|
|
+ SubSampleClient(CEntityBase* pEntity) :SampleService_ClientBase(pEntity) {}
|
|
|
+
|
|
|
+ void OnMessage(ErrorCodeEnum Error, SampleEntity::SampleService_SubscribeOverlap_Message_Info& Msg, CSmartPointer<IReleasable> pData)
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+class CHighVoltageBase : public CEntityBase
|
|
|
+{
|
|
|
+public:
|
|
|
+ CHighVoltageBase() {}
|
|
|
+ virtual ~CHighVoltageBase() {}
|
|
|
+
|
|
|
+ virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual void OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+ }
|
|
|
+
|
|
|
+ void CHighVoltageBase::OnStarted()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ void OnExam(CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+ {
|
|
|
+ pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
+ TestCaseInvoke();
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual void TestCaseInvoke();
|
|
|
+
|
|
|
+ void UpdateSysVal()
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+
|
|
|
+ UINT64 uTimes = 0;
|
|
|
+
|
|
|
+ const char* lpcszSysValStr[] = {
|
|
|
+ "fsfjlkmfdklfasjff;iewjfofdnfksdfdsnfdsklfjsdlffdf332231u09-9=-89=-90764sdffsfdsf3erwerwo",
|
|
|
+ "wpkopmnoinvoivncoihsdjfo3h32898y12u3hujeop[pokl;k.ghsadhdjkw3oeqoiqjhiokqrjh3hoqh2j1k2jefjklajl"
|
|
|
+ };
|
|
|
+
|
|
|
+ do {
|
|
|
+
|
|
|
+ CSimpleStringA strValue;
|
|
|
+ IFFAILBREAK(GetFunction()->GetSysVar("AlwaysUpdate", strValue));
|
|
|
+ if (strValue.Compare(lpcszSysValStr[0]) == 0)
|
|
|
+ strValue = lpcszSysValStr[1];
|
|
|
+ else
|
|
|
+ strValue = lpcszSysValStr[0];
|
|
|
+ IFFAILBREAK(GetFunction()->SetSysVar("AlwaysUpdate", strValue, true));
|
|
|
+
|
|
|
+ LogEvent(Severity_Low, 0, CSimpleStringA::Format("%s operates %lld times.", __FUNCTION__, ++uTimes));
|
|
|
+
|
|
|
+
|
|
|
+ } while (true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void SendBroadCast()
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+
|
|
|
+ UINT64 uTimes = 0;
|
|
|
+
|
|
|
+ do {
|
|
|
+
|
|
|
+ HighVoltage::MessageBroadcase1 broad1;
|
|
|
+ broad1.context = "broad1::v.cmljgoeirjoaiwenaksldfnmjdsofidjvoivvksldgfmliejwofjaweofiasdkfljsdfjsd;foijoeifje";
|
|
|
+ IFFAILBREAK(SpSendBroadcast(GetFunction(), SP_MSG_OF(MessageBroadcase1), SP_MSG_SIG_OF(MessageBroadcase1), broad1));
|
|
|
+
|
|
|
+ HighVoltage::MessageBroadcase2 broad2;
|
|
|
+ broad2.context = "broad2::v.cmljgoeirjoaiwenaksldfnmjdsofidjvoivvksldgfmliejwofjaweofiasdkfljsdfjsd;foijoeifje";
|
|
|
+ IFFAILBREAK(SpSendBroadcast(GetFunction(), SP_MSG_OF(MessageBroadcase2), SP_MSG_SIG_OF(MessageBroadcase2), broad2));
|
|
|
+
|
|
|
+
|
|
|
+ LogEvent(Severity_Low, 0, CSimpleStringA::Format("%s operates %lld times.", __FUNCTION__, ++uTimes));
|
|
|
+
|
|
|
+ } while (true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void CommunicateWithRemoteEntity()
|
|
|
+ {
|
|
|
+ LOG_FUNCTION();
|
|
|
+
|
|
|
+ UINT64 uTimes = 0;
|
|
|
+ do {
|
|
|
+
|
|
|
+ SubSampleClient* sampleClient = new SubSampleClient(this);
|
|
|
+ IFFAILBREAK(sampleClient->Connect());
|
|
|
+
|
|
|
+ {
|
|
|
+ SampleEntity::SampleService_OnewayFuncOverlap_Info info;
|
|
|
+ info.req_context = "SampleService_OnewayFuncOverlap_Info::xvmx.cvmsifjwoejklfjlkdfsdjfoiwjeiofjlsfsdgjlfdg";
|
|
|
+ IFFAILBREAK(sampleClient->OnewayFuncOverlap(info));
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ SampleEntity::SampleService_OnewayFuncNormal_Info info;
|
|
|
+ info.tstring = "SampleService_OnewayFuncNormal_Info::tstring::xvmx.cvmsifjwoejklfjlkdfsdjfoiwjeiofjlsfsdgjlfdg";
|
|
|
+ info.twstring = L"SampleService_OnewayFuncNormal_Info::twstring::xvmx.cvmsifjwoejklfjlkdfsdjfoiwjeiofjlsfsdgjlfdg";
|
|
|
+ IFFAILBREAK(sampleClient->OnewayFuncNormal(info));
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ SampleEntity::SampleService_TwoWayFuncNormal_Req Req;
|
|
|
+ SampleEntity::SampleService_TwoWayFuncNormal_Ans Ans;
|
|
|
+
|
|
|
+ Req.tbool = true;
|
|
|
+ Req.tchar = 'I';
|
|
|
+ Req.tint = 123;
|
|
|
+ Req.tuint = 123;
|
|
|
+ Req.tshort = 123;
|
|
|
+ Req.tushort = 123;
|
|
|
+ Req.tuchar = 'I';
|
|
|
+ Req.tstring = "SampleService_TwoWayFuncNormal_Req::tstring::xclvmsdiofjweoij3r283908u238925j4ioijn;klgnfakjsfsfhffjeoiwjhoi";
|
|
|
+ Req.twstring = "SampleService_TwoWayFuncNormal_Req::twstring::xclvmsdiofjweoij3r283908u238925j4ioijn;klgnfakjsfsfhffjeoiwjhoi";
|
|
|
+ Req.tfloat = 123.456;
|
|
|
+ Req.tdouble = 123.456;
|
|
|
+ Req.tblob.Clear();
|
|
|
+ Req.tint64 = 123;
|
|
|
+ Req.tuint64 = 123;
|
|
|
+
|
|
|
+ IFFAILBREAK(sampleClient->TwoWayFuncNormal(Req, Ans, 10000));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ sampleClient->GetFunction()->CloseSession();
|
|
|
+
|
|
|
+ LogEvent(Severity_Low, 0, CSimpleStringA::Format("%s operates %lld times.", __FUNCTION__, ++uTimes));
|
|
|
+
|
|
|
+ } while (true);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+struct UpdateSysValTask : public ITaskSp
|
|
|
+{
|
|
|
+ UpdateSysValTask(CHighVoltageBase* pEntity) :m_pEntity(pEntity) {}
|
|
|
+ CHighVoltageBase* m_pEntity;
|
|
|
+ void Process()
|
|
|
+ {
|
|
|
+ m_pEntity->UpdateSysVal();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+struct SendBroadCastTask : public ITaskSp
|
|
|
+{
|
|
|
+ SendBroadCastTask(CHighVoltageBase* pEntity) :m_pEntity(pEntity) {}
|
|
|
+ CHighVoltageBase* m_pEntity;
|
|
|
+ void Process()
|
|
|
+ {
|
|
|
+ m_pEntity->SendBroadCast();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+struct CommunicateWithRemoteEntityTask : public ITaskSp
|
|
|
+{
|
|
|
+ CommunicateWithRemoteEntityTask(CHighVoltageBase* pEntity) :m_pEntity(pEntity) {}
|
|
|
+ CHighVoltageBase* m_pEntity;
|
|
|
+ void Process()
|
|
|
+ {
|
|
|
+ m_pEntity->CommunicateWithRemoteEntity();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+void CHighVoltageBase::TestCaseInvoke()
|
|
|
+{
|
|
|
+ {
|
|
|
+ char szProcessID[12];
|
|
|
+ sprintf(szProcessID, "%u", GetCurrentProcessId());
|
|
|
+ MessageBoxA(NULL, szProcessID, "", MB_OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_FUNCTION();
|
|
|
+ IFFAILBREAK(GetFunction()->PostThreadPoolTask(new UpdateSysValTask(this)));
|
|
|
+ IFFAILBREAK(GetFunction()->PostThreadPoolTask(new SendBroadCastTask(this)));
|
|
|
+ IFFAILBREAK(GetFunction()->PostThreadPoolTask(new CommunicateWithRemoteEntityTask(this)));
|
|
|
+}
|
|
|
+
|
|
|
+#endif //_MOD_HIGH_VOLTAGE_BASE_H__
|