Esempio n. 1
0
static void AcmCmdFunc_LsDomain(CCmdSession* pSession, const char *sCmdLine, const char* sCmdArg)
{
	CArguments oArgs;
	oArgs.SetCmdLine(sCmdLine);
	int32 nArgc = oArgs.GetArgc();
	if(nArgc == 1)
	{
		CVector<uint32> oDomains;
		CAcmUdp::GetAllDomains(oDomains);
		uint32 nSize = oDomains.GetSize();
		pSession->Print("There are %u domains:\r\n", nSize);
		for(uint32 i=0; i<nSize; ++i)
		{
			uint32 nDomain = oDomains[i];
			pSession->Print("\tDomain:%u\r\n", nDomain);
		}
		pSession->Print("\r\n");
	}
	else if(nArgc == 2)
	{
		const char* sArg = oArgs.GetArgv()[1];
		uint32 nDomain = CString::Atoi(sArg);
		CAcmUdp* pUdp = CAcmUdp::QueryUdp(nDomain);
		if(pUdp == NULL)
			pSession->Print("There isn't the domain '%u'\r\n", nDomain);
		else
		{
			if(pUdp->IsMultiCast())
			{
				CIpAddr oAddr;
				CString oFileName;
				uint32 nTTL = pUdp->GetMultiCastAddr(oAddr);
				CFile::GetIpFileName(oAddr, oFileName);
				pSession->Print("The domain %u is multicast domain, and the multicast addr is %s, and the TTL is %u\r\n", nDomain, oFileName.GetStr(), nTTL);
			}
			else
				pSession->Print("The domain %u is unicast domain\r\n", nDomain);
			CAcmService* pService = (CAcmService*)CServiceManager::GetInstance()->QueryService("AcmService");
			pService->SetSession(pSession);
			pUdp->Walk();
			uint32 nSize = pService->GetWalkSize();
			pSession->Print("There are %u nodes in the domain %u\r\n", nSize, nDomain);
		}
	}
}
Esempio n. 2
0
static void AcmCmdFunc_LsSerial(CCmdSession* pSession, const char *sCmdLine, const char* sCmdArg)
{
	CArguments oArgs;
	oArgs.SetCmdLine(sCmdLine);
	int32 nArgc = oArgs.GetArgc();
	if(nArgc == 1)
		pSession->Print("This lack of domain parameters\r\n");
	else
	{
		const char* sArg = oArgs.GetArgv()[1];
		uint32 nDomain = CString::Atoi(sArg);
		CAcmUdp* pUdp = CAcmUdp::QueryUdp(nDomain);
		if(pUdp == NULL)
			pSession->Print("There isn't the domain '%u'\r\n", nDomain);
		else
		{
			CAcmSequenceModule* pModule = (CAcmSequenceModule*)pUdp->QueryModule(ACM_SERIAL_MODULE);
			if(pModule == NULL)
				pSession->Print("This domain %u doesn't support the serial function\r\n", nDomain);
			else
			{
				bool bSupportSend = pModule->SupportSend();
				bool bSupportRecv = pModule->SupportRecv();
				bool bSupportAck = pModule->SupportUniCastSend();
				uint32 nCapacity = 0, nRecvCapacity, nSendCapacity, nRecvSize, nSendSize;
				nRecvCapacity = pModule->GetRecvCapacity(nRecvSize);
				nSendCapacity = pModule->GetRecvCapacity(nSendSize);
				if(nRecvCapacity)
					nCapacity = nRecvCapacity;
				else if(nSendCapacity)
					nCapacity = nSendCapacity;
				pSession->Print("This domain %u", nDomain);
				if(bSupportSend)
				{
					pSession->Print(" supports serial send");
					if(bSupportAck)
						pSession->Print("(ack)");
				}
				if(bSupportRecv)
				{
					if(bSupportSend)
						pSession->Print(", and serial receive");
					else
						pSession->Print(" supports serial receive");
				}
				pSession->Print("\r\nThe capacity is %u\r\n", nCapacity);
				if(bSupportAck)
					pSession->Print("the send queue is %u\r\n", nSendSize);
				if(bSupportRecv)
					pSession->Print("the receive queue is %u\r\n", nRecvSize);

				CAcmService* pService = (CAcmService*)CServiceManager::GetInstance()->QueryService("AcmService");
				pService->SetSession(pSession);
				pModule->Walk(*pService);
				uint32 nSize = pService->GetWalkSize();
				pSession->Print("There are %u nodes in the serial domain %u\r\n", nSize, nDomain);
				pUdp->ReleaseModule(ACM_SERIAL_MODULE);
			}
		}
	}
}