// 将ADC数据保存到文件中
void CADCDataSaveToFileThread::OnSaveADCToFile(unsigned int uiADCSaveDataNum)
{
	CString strOutput = "";
	CString strTemp = "";
	if(m_bOpenADCSaveFile == FALSE)
	{
		OnOpenADCSaveFile();
	}

	// 输出各仪器采样数据
	for (unsigned int i=0; i<uiADCSaveDataNum; i++)
	{
		ProcessMessages();
		for (int j=0; j<GraphViewNum; j++)
		{
			ProcessMessages();
			
			strTemp.Format(_T("%2.*lf\t"),DecimalPlaces, m_dADCSaveToFileProcBuf[j][i]);
			strOutput += strTemp;
		}
		strOutput += "\r\n";
	}
	for (int i=0; i<GraphViewNum; i++)
	{
		memset(m_dADCSaveToFileProcBuf[i], 0, uiADCSaveDataNum);
	}
	fprintf(m_pFileSave,"%s", strOutput); 

	m_uiADCDataToSaveNum += uiADCSaveDataNum;
	if (m_uiADCDataToSaveNum == m_uiADCFileLength)
	{
		m_uiADCDataToSaveNum = 0;
		OnCloseADCSaveFile();
	}
}
Ejemplo n.º 2
0
// 关闭采样后保存剩余数据
void CADCDataRecThread::OnSaveRemainADCData(unsigned int uiADCDataNeedToSave)
{
    unsigned int uiDataLength = 0;
    CString strOutput = "";
    CString strTemp ="";
    if (m_pFileSave == NULL)
    {
        return;
    }
    for (unsigned int i=0; i<uiADCDataNeedToSave; i++)
    {
        ProcessMessages();
        for (int j=0; j<GraphViewNum; j++)
        {
            ProcessMessages();
            if (m_pSelectObject[j] == 1)
            {
                if (m_pSelectObjectNoise[j] == 0)
                {
                    uiDataLength = m_dADCSave[j].size();
                    if (uiDataLength == 0 )
                    {
                        strOutput += "\t\t";
                        continue;
                    }
                    if (uiDataLength > i)
                    {
                        strTemp.Format("%2.*lf\t",DecimalPlaces, m_dADCSave[j][i]);
                        strOutput += strTemp;
                    }
                    else
                    {
                        strOutput += "\t\t";
                    }
                }
                else
                {
                    strOutput += "\t\t";
                }
            }
            else
            {
                strOutput += "\t\t";
            }
        }
        strOutput += "\r\n";
    }
    fprintf(m_pFileSave,"%s", strOutput);
    // 清空接收缓冲区

    for (unsigned int i=0; i<GraphViewNum; i++)
    {
        ProcessMessages();
        m_dADCSave[i].clear();
    }
    OnCloseADCSaveFile();
}
Ejemplo n.º 3
0
// 检查接收帧是否为重发帧
BOOL CADCDataRecThread::OnCheckFrameIsRetransmission(unsigned int uiInstrumentNb, unsigned int uiIPAim, unsigned short usDataPointNow)
{
    CString str = "";
    unsigned short usLostDataFrameCount = 0;	// 丢失帧计数
    unsigned short usADCDataNb = ReceiveDataSize;	// ADC一帧的数据个数
    unsigned short usDataPointMove = 0;	// 记录指针偏移量
    m_structADC ADCFindFromStruct;

    // 接收到的ADC数据不是重发数据
    if (m_oADCLostMap[uiInstrumentNb].Lookup(usDataPointNow, ADCFindFromStruct) == NULL)
    {
        if (usDataPointNow > m_usDataPointPrevious[uiInstrumentNb])
        {
            usDataPointMove  = usDataPointNow - m_usDataPointPrevious[uiInstrumentNb];
        }
        else
        {
            usDataPointMove  = 2048 + usDataPointNow - m_usDataPointPrevious[uiInstrumentNb];
        }

        usLostDataFrameCount = usDataPointMove/usADCDataNb - 1;

        // 有ADC采集数据丢帧则加入ADC数据重发队列
        if (usLostDataFrameCount > 0)
        {
            for (unsigned short m=0; m<usLostDataFrameCount; m++)
            {
                ProcessMessages();
                m_structADC ADCDataStruct;
                unsigned short usDataPointNb = (m_usDataPointPrevious[uiInstrumentNb] + (m+1)*usADCDataNb)%2048;
                ADCDataStruct.uiDataCount = m_uiADCDataFrameCount[uiInstrumentNb] + m;
                ADCDataStruct.uiRetransmissionNum = 0;
                m_oADCLostMap[uiInstrumentNb].SetAt(usDataPointNb, ADCDataStruct);
                for (int i=0; i<ReceiveDataSize; i++)
                {
                    ProcessMessages();
                    m_dSampleTemp[uiInstrumentNb].push_back(0.0);
                }
            }
            m_uiADCDataFrameCount[uiInstrumentNb] += usLostDataFrameCount;
        }

        m_usDataPointPrevious[uiInstrumentNb] = usDataPointNow;
        return FALSE;

    }
    else
    {
        // 如果为重发数据则ADC应接收数据个数不变
        m_uiADCDataFrameCount[uiInstrumentNb]--;
        m_uiADCRetransmissionNb = ADCFindFromStruct.uiDataCount;
        m_oADCLostMap[uiInstrumentNb].RemoveKey(usDataPointNow);
        return TRUE;
    }
}
// 创建并打开ADC保存数据文件
void CADCDataRecThread::OnOpenADCSaveFile(void)
{
	m_uiADCSaveFileNum++;
	CString strFileName = _T("");
	CString strOutput = _T("");
	CString strTemp = _T("");
	errno_t err;
	CString str = _T("");
	SYSTEMTIME  sysTime;
	unsigned int uiADCDataFrameCount = 0;
	strFileName += m_csSaveFilePath;
	strTemp.Format(_T("\\%d.text"), m_uiADCSaveFileNum);
	strFileName += strTemp;
	// 将ADC采样数据保存成ANSI格式的文件
	if((err = fopen_s(&m_pFileSave,strFileName,"w+"))!=NULL)
	{
		AfxMessageBox(_T("ADC数据存储文件创建失败!"));	
		return;
	}

	GetLocalTime(&sysTime);
	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		if (m_pSelectObject[i] == 1)
		{
			if (m_pSelectObjectNoise[i] == 0)
			{
				uiADCDataFrameCount = m_uiADCDataFrameCount[i];
				break;
			}
		}
	}
	str.Format(_T("%04d年%02d月%02d日%02d:%02d:%02d:%03d 由第%d个数据包开始记录ADC采样数据:\r\n\r\n"), sysTime.wYear,sysTime.wMonth,sysTime.wDay,
		sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds, uiADCDataFrameCount);
	strOutput += str;

	// 输出仪器标签
	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		strTemp.Format(_T("%s\t\t"),m_cSelectObjectName[i]);
		strOutput += strTemp;
	}
	strOutput += _T("\r\n");

	fprintf(m_pFileSave, _T("%s"), strOutput); 
	m_bOpenADCSaveFile = TRUE;
}
// 被选择仪器的ADC数据个数的最小值
unsigned int CADCDataSaveToFile::OnADCRecDataMinNum(unsigned int* upADCDataNum, int* pSelectObject,
													int* pSelectObjectNoise)
{
	unsigned int uiMinSize = 10000;
	bool bSelect = false;
	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		if (pSelectObject[i] == 1)
		{
			if (pSelectObjectNoise[i] == 0)
			{
				if (uiMinSize > upADCDataNum[i])
				{
					uiMinSize = upADCDataNum[i];
					bSelect = true;
				}
			}
		}
	}
	if (bSelect == false)
	{
		uiMinSize = 0;
	}
	return uiMinSize;
}
Ejemplo n.º 6
0
/*
================
rvDebuggerClient::WaitFor

Waits the given amount of time for the specified message to be received by the 
debugger client.
================
*/
bool rvDebuggerClient::WaitFor ( EDebuggerMessage msg, int time )
{
	int start;
	
	// Cant wait if not connected
	if ( !mConnected )
	{
		return false;
	}
	
	start    = Sys_Milliseconds ( );
	mWaitFor = msg;
	
	while ( mWaitFor != DBMSG_UNKNOWN && Sys_Milliseconds()-start < time )
	{
		ProcessMessages ( );
		Sleep ( 0 );
	}
	
	if ( mWaitFor != DBMSG_UNKNOWN )
	{
		mWaitFor = DBMSG_UNKNOWN;
		return false;
	}
	
	return true;
}
Ejemplo n.º 7
0
// ADC数据需要重新发送帧对应的最小个数
unsigned int CADCDataRecThread::OnADCRetransimissionMinNb(unsigned int uiInstrumentNb)
{
    unsigned int uimin = 0;								// 最小值
    POSITION pos = m_oADCLostMap[uiInstrumentNb].GetStartPosition();	// 得到索引表起始位置
    unsigned int uiKey;									// 索引键
    unsigned int uiCount = 0;							// 计数

    while(NULL != pos)
    {
        ProcessMessages();
        m_structADC ADCStructTemp;
        m_oADCLostMap[uiInstrumentNb].GetNextAssoc(pos, uiKey, ADCStructTemp);	// 得到仪器对象
        uiCount++;
        if (uiCount == 1)
        {
            uimin = ADCStructTemp.uiDataCount;
        }
        else
        {
            if (uimin > ADCStructTemp.uiDataCount)
            {
                uimin = ADCStructTemp.uiDataCount;
            }
        }
    }
    return uimin;
}
// 删除所有仪器
//************************************
// Method:    DeleteAllInstrument
// FullName:  CInstrumentList::DeleteAllInstrument
// Access:    public 
// Returns:   void
// Qualifier:
// Parameter: void
//************************************
void CInstrumentList::DeleteAllInstrument(void)
{
	CInstrument* pInstrument = NULL;	// 仪器对象指针
	POSITION pos = NULL;				// 位置	
	unsigned int uiKey = 0;					// 索引键	
	unsigned int icount = m_oInstrumentMap.GetCount();
	if (icount == 0)
	{
		return;
	}
	pos = m_oInstrumentMap.GetStartPosition();	// 得到索引表起始位置
	while(NULL != pos)
	{
		ProcessMessages();
		pInstrument = NULL;		
		m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument);	// 得到仪器对象
		if(NULL != pInstrument)	
		{
			// 显示设备断开连接的图标
			OnShowDisconnectedIcon(pInstrument->m_uiIPAddress);
			// 将仪器从索引表中删除
			DeleteInstrumentFromMap(uiKey);
			// 重置仪器
			pInstrument->OnReset();
			// 仪器加在空闲仪器队列尾部
			m_olsInstrumentFree.AddTail(pInstrument);
			m_uiCountFree++;
		}
	}
}
// 设备根据首包时刻排序
//************************************
// Method:    SetInstrumentLocation
// FullName:  CInstrumentList::SetInstrumentLocation
// Access:    public 
// Returns:   void
// Qualifier:
// Parameter: CInstrument * pInstrumentAdd
//************************************
void CInstrumentList::SetInstrumentLocation(CInstrument* pInstrumentAdd)
{
	CInstrument* pInstrument = NULL;	// 仪器对象指针
	POSITION pos = NULL;				// 位置	
	unsigned int uiKey = 0;					// 索引键	
	unsigned int uiLocation = 0;
	pos = m_oInstrumentMap.GetStartPosition();	// 得到索引表起始位置
	while(NULL != pos)
	{
		ProcessMessages();
		pInstrument = NULL;		
		m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument);	// 得到仪器对象
		if(NULL != pInstrument)	
		{
			if (pInstrument->m_uiSN != pInstrumentAdd->m_uiSN)
			{
				if (pInstrumentAdd->m_uiHeadFrameTime > pInstrument->m_uiHeadFrameTime)
				{
					uiLocation++;
				}
			}
		}
	}
	if (uiLocation == pInstrumentAdd->m_uiLocation)
	{
		// 首包计数器加一
		pInstrumentAdd->m_iHeadFrameCount++;
	}
	else
	{
		pInstrumentAdd->m_iHeadFrameCount = 0;
		pInstrumentAdd->m_uiLocation = uiLocation;
	}
	TRACE2(_T("仪器SN%04x,仪器位置%d\r\n"), pInstrumentAdd->m_uiSN, pInstrumentAdd->m_uiLocation);
}
Ejemplo n.º 10
0
//--------------------------------------------------------------------------------------
// Updates the manoeuvre. This mostly consists of processing any messages received from
// the participating entities and reacting accordingly. This can include the sending
// out of follow-up orders for entities that have completed a stage of the manoeuvre. Eventually
// the function should also check whether the goal of the manoeuvre has been achieved in 
// order to initiate termination.
// Param1: The time passed since the last update.
// Returns a behaviour status representing the state of the manoeuvre.
//--------------------------------------------------------------------------------------
BehaviourStatus GuardedFlagCapture::Update(float deltaTime)
{
	// Keep track of who has reached the target and let those defend until all have arrived
	SortOutProcessedMessages();
	ProcessMessages();

	m_timer += deltaTime;

	if(m_updateMovementTargetsInterval != 0.0f && m_timer >= m_updateMovementTargetsInterval)
	{
		UpdateMovementTargets();
		m_timer = 0.0f;
	}

	if(!IsActive() || HasFailed() || (GetNumberOfParticipants() < GetMinNumberOfParticipants()))
	{
		// The manoeuvre will fail if something failed during the initiation or if it wasn't
		// initiated at all.
		return StatusFailure;
	}else if(HasSucceeded())
	{
		return StatusSuccess;
	}

	return StatusRunning;
}
Ejemplo n.º 11
0
/**
 *  Nachrichtenschleife.
 *
 *  @author FloSoft
 */
int LobbyServer::Run(void)
{
    // Clients testen (auf timeout usw)
    if(!CheckClientTimeouts())
        return 2;

    // neue Clients verbinden
    if(!CheckForNewClients())
        return 3;

    // Daten weiterleiten
    if(!ProcessMessages())
        return 4;

    // ggf. stoppen
    if(stop == true)
        return 100;

#ifdef _WIN32
    Sleep(20);
#else
    usleep(20);
#endif

    return 0;
}
Ejemplo n.º 12
0
	ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
	{
		if (target_type == TYPE_CHANNEL)
			return ProcessMessages(user, static_cast<Channel*>(dest));

		return MOD_RES_PASSTHRU;
	}
Ejemplo n.º 13
0
bool PerigeeMove::InitIt()
{
	// on Windows Vista, verify we have permissions to do this, and prompt to elevate otherwise
	if (!m_options.skip_inventory && 
		VistaHelper::IsVistaOrNewer() && !VistaHelper::IsAdmin())
	{	
		CString prompt;
		prompt.LoadString( IDS_PREPARING_TO_MOVE_FILES );
		m_progress.SetSourceDest(prompt, _T(""));
		int count = 0;
		for(file_list::iterator it = m_files.begin(); it != m_files.end(); ++it)
		{
			if (!VistaHelper::CheckAccess(it->source, GENERIC_READ | DELETE, m_token))
			{
				CString message;
				message.Format(IDS_ELEVATION_REQUIRED_TO_MOVE_FILE, it->source);
				DoElevatePrompt(message);
				if (m_cancel)
					return false;
			}
			if (0 == (++count & 0x3f))
			{
				ProcessMessages();
				m_cancel = m_cancel || m_progress.m_CancelRequest;
			}
		}
	}

	return true;
}
// 设备根据首包时刻排序
void CInstrumentList::SetInstrumentLocation(CInstrument* pInstrumentAdd)
{
	CInstrument* pInstrument = NULL;	// 仪器对象指针
	POSITION pos = NULL;				// 位置	
	unsigned int uiKey;					// 索引键	
	pos = m_oInstrumentMap.GetStartPosition();	// 得到索引表起始位置
	while(NULL != pos)
	{
		ProcessMessages();
		pInstrument = NULL;		
		m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument);	// 得到仪器对象
		if(NULL != pInstrument)	
		{
			if (pInstrumentAdd->m_uiHeadFrameTime > pInstrument->m_uiHeadFrameTime)
			{
				pInstrumentAdd->m_uiLocation++;
			}
			else
			{
				pInstrument->m_uiLocation++;
				// 按照首包时刻位置设置仪器IP地址
				pInstrument->m_uiIPAddress = 71 + (pInstrument->m_uiLocation)*10;
			}
		}
	}
	// 按照首包时刻位置设置新加入仪器的IP地址
	pInstrumentAdd->m_uiIPAddress = 71 + (pInstrumentAdd->m_uiLocation)*10;
	pInstrument = NULL;
	delete pInstrument;
}
Ejemplo n.º 15
0
int
RoutingNode::RequestNeighborConnectionInfo()
{
	neighborsIter it = neighbors.begin();
	while (it != neighbors.end())
	{
		char buffer[512];
		bzero(buffer,512);
		sprintf(buffer, "@%d~%d~%d", myID, RoutingMessage::REQCONINFO, it->first);
		SendMessage(server, buffer);
		bzero(buffer,512);
	
		#if logging > 1
			cout << "Waiting for connection ACK of " << it->first << "...\n";
		#endif

		//wait for ack
		//replace with message-type parser at some point
		while (buffer[6] != '1' && buffer[7] != '7')
		{
			bzero(buffer,512);
			int n = recvfrom(mySocket,buffer,512,0,(struct sockaddr *)&neighbor, &sockLen);
		}

		messages.clear();
		parser.ParseMessage(buffer, fromNode, messages);
		ProcessMessages();
		it++;
	}
}
// 计算出最大的待处理数据个数
unsigned int CADCDataSaveToFileThread::OnCalMaxNeedToSaveDataNum(void)
{
	unsigned int uiMax = 0;
	unsigned int uiNum = 0;
	unsigned int uiClearZeroNum = 0;
	for (unsigned int i=0; i<GraphViewNum; i++)
	{
		ProcessMessages();
		if (m_pSelectObject[i] == 1)
		{
			if (m_pSelectObjectNoise[i] == 0)
			{
				uiNum = m_uiADCFrameSaveToFileProcNum[i] * ADCFrameNumNeedToSave + m_uiADCFrameRemain[i];
				uiClearZeroNum = ADCDataSaveToFileBufSize - uiNum * ReceiveDataSize;
				if(uiClearZeroNum > 0)
				{
					memset(&m_dADCSaveToFileProcBuf[i][ADCDataSaveToFileBufSize - uiClearZeroNum], 0, uiClearZeroNum);
				}
				if (uiNum > uiMax)
				{
					uiMax = uiNum;
				}
			}
		}
	}
	for (int i=0; i<GraphViewNum; i++)
	{
		m_uiADCFrameSaved[i] += uiMax;
	}
	uiMax = uiMax * ReceiveDataSize;
	return uiMax;
}
Ejemplo n.º 17
0
int
RoutingNode::GetMyID()
{
	#if logging > 1
		cout << "Getting Id...\n";
	#endif

	int n;
	char buffer[512];
	bzero(buffer,512);
	unsigned int length = sizeof(struct sockaddr_in);
	struct sockaddr_in from;

	n = sendto(mySocket,"!", strlen("!"),0,(const struct sockaddr *)&server,length);

	if (n < 0) 
		perror("Sendto");

	n = recvfrom(mySocket,buffer,512,0,(struct sockaddr *)&from, &length);

	if (n < 0) 
		perror("recvfrom");

	parser.ParseMessage(buffer, fromNode, messages);
	ProcessMessages();
}
void CTabADCDataShow::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
	if (nIDEvent == TabADCDataShowADCTimerNb)
	{
		CString str = _T("");
		CString strshow = _T("");
		double dbTemp = 0.0;
		if (m_pADCDataShow != NULL)
		{	
			for (int i=1; i<=InstrumentNum; i++)
			{
				ProcessMessages();
				m_Sec_ADCDataShow.Lock();
				dbTemp = m_pADCDataShow[i-1];
				m_Sec_ADCDataShow.Unlock();
				str.Format(_T("ADC%d = %2.*lf"), i, DecimalPlaces, dbTemp);
				strshow += str;
				if(i % ADCDataShowPerLineNum == 0)
				{
					strshow += _T("\r\n");
				}
				else
				{
					strshow += _T("\t");
				}	
			}
		}
		GetDlgItem(IDC_EDIT_ADCDATA)->SetWindowText(strshow);
	}
	CDialog::OnTimer(nIDEvent);
}
Ejemplo n.º 19
0
int
RoutingNode::GetMyNeighbors()
{
	#if logging > 1
		cout << "Getting neighbors...\n";
	#endif

	unsigned int length = sizeof(neighbor);
	char buffer[512];
	bzero(buffer,512);
	int n;

	//once we have our information from the manager, let's hog some cpu
	//remove this crap when stuff gets more reliable
	fcntl(mySocket, F_SETFL, O_NONBLOCK);

	//replace with message-type parser at some point
	while (buffer[6] != '2' && buffer[7] != '1')
	{
		n = recvfrom(mySocket,buffer,512,0,(struct sockaddr *)&neighbor, &length);
		//commented out for code submission
		//if (n > 0) cout << buffer << endl;
	}

	fcntl(mySocket, F_SETFL, ~O_NONBLOCK);

	parser.ParseMessage(buffer, fromNode, messages);
	ProcessMessages();

	if (n < 0) 
		perror("recvfrom");
}
// 清理过期的尾包时刻查询结果
//************************************
// Method:    ClearExperiedTailTimeResult
// FullName:  CInstrumentList::ClearExperiedTailTimeResult
// Access:    public 
// Returns:   void
// Qualifier:
// Parameter: void
//************************************
void CInstrumentList::ClearExperiedTailTimeResult(void)
{
	CInstrument* pInstrument = NULL;	// 仪器	
	POSITION pos = NULL;	// 位置	
	unsigned int uiKey = 0;	// 索引键

	// 得到索引表起始仪器位置
	pos = m_oInstrumentMap.GetStartPosition();
	// 当前位置有仪器
	while(NULL != pos)
	{
		ProcessMessages();
		pInstrument = NULL;
		// 得到仪器
		m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument);
		if(NULL != pInstrument)	// 得到仪器
		{
			// 发送尾包时刻查询但是在下一个尾包接收之前未回复的设置过期标志
			if (pInstrument->m_bSendTailTimeFrame == true)
			{
				if (pInstrument->m_bTailTimeReturnOK == false)
				{
					pInstrument->m_bTailTimeExpired = true;
				}
			}
			pInstrument->m_bSendTailTimeFrame = false;
			pInstrument->m_bTailTimeReturnOK = false;
		}
	}
}
Ejemplo n.º 21
0
  void BulkRound::HandleBulkData(QDataStream &stream, const Id &from)
  {
    qDebug() << GetGroup().GetIndex(GetLocalId()) << GetLocalId().ToString() <<
      ": received bulk data from " << GetGroup().GetIndex(from) << from.ToString();

    if(IsLeader() || !_app_broadcast) {
      if(_state != DataSharing) {
        throw QRunTimeError("Received a misordered BulkData message");
      }
    } else if(_app_broadcast && _state != ProcessingLeaderData) {
      throw QRunTimeError("Waiting for data from leader, received something else.");
    }

    int idx = GetGroup().GetIndex(from);
    if(!_messages[idx].isEmpty()) {
      throw QRunTimeError("Already have bulk data.");
    }

    QByteArray payload;
    stream >> payload;

    if(payload.size() != _expected_bulk_size) {
      throw QRunTimeError("Incorrect bulk message length");
    }

    _messages[idx] = payload;

    if(++_received_messages == GetGroup().Count()) {
      ProcessMessages();
      Finish();
    }
  }
// 根据IP地址显示设备断开连接的图标
//************************************
// Method:    OnShowDisconnectedIcon
// FullName:  CInstrumentList::OnShowDisconnectedIcon
// Access:    protected 
// Returns:   void
// Qualifier:
// Parameter: unsigned int uiIPAddress
//************************************
void CInstrumentList::OnShowDisconnectedIcon(unsigned int uiIPAddress)
{
	CButton* iconbutton = NULL;
	CStatic* iconstatic = NULL;
	CButton* pButton = NULL;

	for (int i=0 ;i<= InstrumentNum; i++)
	{
		ProcessMessages();
		if (uiIPAddress == (IPSetAddrStart + i * IPSetAddrInterval))
		{
			if (i == 0)
			{
				iconstatic =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_LAUX);
				iconstatic->SetIcon(m_iconLAUXDisconnected);
			}
			else
			{
				iconbutton = (CButton*)m_pwnd->GetDlgItem(m_iButtonIDFDU[i-1]);
				iconbutton->SetIcon(m_iconFDUDisconnected);
				pButton = (CButton*)m_pwnd->GetDlgItem(m_iCheckIDInstrumentFDU[i-1]);
				pButton->SetCheck(0);
			}
			break;
		}
	}
}
Ejemplo n.º 23
0
// 停止
void CTabSample::OnStop(void)
{
	CButton* iconbutton = NULL;
	CStatic* iconstatic = NULL;
	CButton* pButton = NULL;

	iconstatic =(CStatic*)this->GetDlgItem(IDC_STATIC_LAUX);
	iconstatic->SetIcon(m_iconLAUXDisconnected);
	iconstatic = NULL;

	for (int i=0; i<GraphViewNum; i++)
	{
		ProcessMessages();
		iconbutton = (CButton*)this->GetDlgItem(m_iButtonIDFDU[i]);
		iconbutton->SetIcon(m_iconFDUDisconnected);
		iconbutton = NULL;
		pButton = (CButton*)GetDlgItem(m_iCheckIDInstrumentFDU[i]);
		pButton->SetCheck(0);
		pButton = NULL;
		pButton = (CButton*)GetDlgItem(m_iCheckIDNoiseFDU[i]);
		pButton->SetCheck(0);
		pButton = NULL;
	}
	delete iconstatic;
	delete iconbutton;
	delete pButton;

	GetDlgItem(IDC_EDIT_SENDPORT)->EnableWindow(TRUE);
	GetDlgItem(IDC_CHECK_HEARTBEAT)->EnableWindow(FALSE);
}
Ejemplo n.º 24
0
unsigned int CADCDataRecThread::OnADCRecDataMinNum(void)
{
    unsigned int uiMinSize = 10000;
    bool bSelect = false;
    for (int i=0; i<GraphViewNum; i++)
    {
        ProcessMessages();
        if (m_pSelectObject[i] == 1)
        {
            if (m_pSelectObjectNoise[i] == 0)
            {
                if (uiMinSize > m_dADCSave[i].size())
                {
                    uiMinSize = m_dADCSave[i].size();
                }
                bSelect = true;
            }
        }
    }
    if (bSelect == false)
    {
        uiMinSize = 0;
    }
    return uiMinSize;
}
// 计算出最小的待处理个数
unsigned int CADCDataSaveToFileThread::OnCalMinProcNum(void)
{
	unsigned int uiMin = 0;
	unsigned int uiCount = 0;
	for (unsigned int i=0; i<GraphViewNum; i++)
	{
		ProcessMessages();
		if (m_pSelectObject[i] == 1)
		{
			if (m_pSelectObjectNoise[i] == 0)
			{
				uiCount++;
				if (uiCount == 1)
				{
					uiMin = m_uiADCFrameSaveToFileProcNum[i];
				}
				else
				{
					if (m_uiADCFrameSaveToFileProcNum[i] < uiMin)
					{
						uiMin = m_uiADCFrameSaveToFileProcNum[i];
					}
				}
			}
		}
	}
	return uiMin;
}
Ejemplo n.º 26
0
	virtual void OnUserNotice(userrec* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list)
	{
		if (target_type == TYPE_CHANNEL)
		{
			ProcessMessages(user,(chanrec*)dest,text);
		}
	}
// 删除采集站尾包之后的仪器
void CInstrumentList::TailFrameDeleteInstrument(CInstrument* pInstrumentDelete)
{
	CInstrument* pInstrument = NULL;	// 仪器对象指针
	POSITION pos = NULL;				// 位置	
	unsigned int uiKey;					// 索引键	

	pos = m_oInstrumentMap.GetStartPosition();	// 得到索引表起始位置
	while(NULL != pos)
	{
		pInstrument = NULL;		
		m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument);	// 得到仪器对象
		if(NULL != pInstrument)	
		{
			ProcessMessages();
			if (pInstrumentDelete->m_uiLocation < pInstrument->m_uiLocation)
			{
				// 显示设备断开连接的图标
				OnShowDisconnectedIcon(pInstrument->m_uiIPAddress);
				// 将仪器从索引表中删除
				DeleteInstrumentFromMap(uiKey);
				// 重置仪器
				pInstrument->OnReset();
				// 仪器加在空闲仪器队列尾部
				m_olsInstrumentFree.AddTail(pInstrument);
				m_uiCountFree++;
			}
		}
	}
	pInstrument = NULL;
	delete pInstrument;
}	
// ADC数据重发
void CADCDataRecThread::OnADCDataRetransmission(void)
{
	int icount = 0;
	for (int i=0; i<InstrumentNum; i++)
	{
		ProcessMessages();
		POSITION pos = m_oADCLostMap[i].GetStartPosition();	// 得到索引表起始位置
		unsigned int uiKey = 0;									// 索引键	
		while(NULL != pos)
		{
			ProcessMessages();
			m_structADC ADCStructTemp;	
			m_oADCLostMap[i].GetNextAssoc(pos, uiKey, ADCStructTemp);	// 得到仪器对象
			if (NULL != ADCStructTemp.uiDataCount)
			{			
				if (ADCStructTemp.uiRetransmissionNum == 0)
				{
					ADCStructTemp.uiRetransmissionNum++;
					m_oADCLostMap[i].SetAt(uiKey, ADCStructTemp);
	//				MakeADCDataRetransmissionFrame(uiKey, (IPSetAddrStart + (i + 1) * IPSetAddrInterval));
				}
				if (ADCStructTemp.uiRetransmissionNum == ADCFrameRetransmissionNum)
				{
					double dReceiveData[ReceiveDataSize];
					m_uiADCRetransmissionNb = uiKey;
					m_oADCLostMap[i].RemoveKey(uiKey);

					for (int k=0; k<ReceiveDataSize; k++)
					{
						dReceiveData[k] = 0.0;
					}
					// 已经全部接收到数据重发帧
					if(icount == 1)
					{
						OnRecOkIsRetransimissionFrame(i, IPSetAddrStart + IPSetAddrInterval * (i + 1), dReceiveData);
					}
					else
					{
						OnRecNotOkIsRetransimissionFrame(i, IPSetAddrStart + IPSetAddrInterval * (i + 1), dReceiveData);
					}
					// 将采样数据保存成文件
					OnSaveADCToFile();
				}
			}
		}
	}
}
Ejemplo n.º 29
0
	virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
	{
		if (target_type == TYPE_CHANNEL)
		{
			return ProcessMessages(user,(chanrec*)dest,text);
		}
		else return 0;
	}
Ejemplo n.º 30
0
// 该帧为普通帧且之前有重发帧
void CADCDataRecThread::OnRecNotOkIsNormalFrame(unsigned int uiInstrumentNb, double* pReceiveData)
{
    for (int k=0; k<ReceiveDataSize; k++)
    {
        ProcessMessages();
        m_dSampleTemp[uiInstrumentNb].push_back(pReceiveData[k]);
    }
}