⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moduleinit.cpp

📁 电力故障信息采集,主要是针对南自的保护装置,这个程序用在Linux操作系统下
💻 CPP
字号:
#include "moduleinit.h"#include "publicclass.h"#include "ysdataprocess.h"extern CPublicClass g_PublicClass;extern void* DeviceCommunicateMainThread(void* lp);CModuleInit :: CModuleInit(){    }CModuleInit ::~CModuleInit(){    }//此处直接从数据库中形成列表bool CModuleInit::StartDevices(void* ppNode){	if(ppNode) return false;	BCDataProcess dp;	DeviceInfoListType devicelist;	long hdbc = -1;	//for debug 	dp.GetDevicesFromModule(hdbc, g_PublicClass.m_ModuleName, "", devicelist);//得到一级设备	int count = (int)devicelist.count();	if (count == 0)	{		printf("No Running Device in list\n");		return false;	}	printf("Running Device in list = %d\n", count);	//启动一级保护通讯线程	st_deviceinfo dst;	DeviceInfoListType::iterator it;	printf("bool CModuleInit::StartDevices(void* ppNode)\n");	for (int i=0; i<count; i++)	{	printf("bool CModuleInit::StartDevices\n");		it = devicelist.at(i);		memset(&dst, 0x00, sizeof(st_deviceinfo));		memcpy(&dst, &(*it), sizeof(st_deviceinfo));		if (StartSomeTopDevice(&dst) == 0) continue;	}		return true;}//////////////////////////启动设备列表中的独立或顶级设备线程//////////////////////////////////int CModuleInit::StartSomeTopDevice(void* dlist){	CDeviceNode* pNode = NULL;	st_deviceinfo DevBuff;	memcpy(&DevBuff, (char*)dlist, sizeof(st_deviceinfo));	//按设备编号查找	int index = 0, ret = 0;	pthread_t threadid = 0;	pNode = g_PublicClass.m_NodeManage.FindDevicebyEquipNo(DevBuff.m_MachineNo, 0, index);	if (!pNode)	{		//产生顶级设备接点		pNode = new CDeviceNode();		pNode->m_ModuleState = 0;		pNode->m_Level = 0;		memcpy(&pNode->m_deviceinfo, &DevBuff, sizeof(st_deviceinfo));		g_PublicClass.m_NodeManage.m_DeviceNode.append(pNode);			//启动设备通讯线程		usleep(1);		ret = pthread_create(&threadid, NULL, DeviceCommunicateMainThread, pNode);		pNode->m_deviceinfo.m_ThreadId = threadid;//线程号付给接点线程号	}	//得到该模块下的二级模块	BCDataProcess dp;	DeviceInfoListType devicelist;	long hdbc = -1;	dp.GetDevicesFromModule(hdbc, g_PublicClass.m_ModuleName, pNode->m_deviceinfo.m_RecordIndex, devicelist);//得到二级设备	printf("devicelist count=%d ParentIndex=%s\n", devicelist.count(), pNode->m_deviceinfo.m_RecordIndex);	if (pNode->m_deviceinfo.m_PlFlag==0 && devicelist.count()==0)	{		devicelist.append(pNode->m_deviceinfo);	}	dp.AddChildDevices(pNode, devicelist, threadid);	pNode->m_ModuleState = 1;	printf("device process child devs=%d\n", pNode->m_ChildDevList.count());	return 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -