Ejemplo n.º 1
0
WorldPacket const* WorldPackets::CombatLog::SpellHealLog::Write()
{
    *this << TargetGUID;
    *this << CasterGUID;
    *this << int32(SpellID);
    *this << int32(Health);
    *this << int32(OverHeal);
    *this << int32(Absorbed);
    WriteBit(Crit);
    WriteBit(CritRollMade.is_initialized());
    WriteBit(CritRollNeeded.is_initialized());
    WriteLogDataBit();
    WriteBit(SandboxScaling.is_initialized());
    FlushBits();

    if (CritRollMade)
        *this << *CritRollMade;

    if (CritRollNeeded)
        *this << *CritRollNeeded;

    WriteLogData();

    if (SandboxScaling)
        *this << *SandboxScaling;

    return &_worldPacket;
}
Ejemplo n.º 2
0
CLogFile::~CLogFile()
{
	WriteLogData();
	if (log_data) {
		//	HeapFree(hHeap, 0, log_data);
		VirtualFree(log_data, 0, MEM_RELEASE);
	}
	DeleteCriticalSection(&cs);
}
Ejemplo n.º 3
0
WorldPacket const* WorldPackets::CombatLog::SpellExecuteLog::Write()
{
    *this << Caster;
    *this << SpellID;
    *this << uint32(Effects.size());

    for (SpellLogEffect const& effect : Effects)
    {
        *this << effect.Effect;

        *this << uint32(effect.PowerDrainTargets.size());
        *this << uint32(effect.ExtraAttacksTargets.size());
        *this << uint32(effect.DurabilityDamageTargets.size());
        *this << uint32(effect.GenericVictimTargets.size());
        *this << uint32(effect.TradeSkillTargets.size());
        *this << uint32(effect.FeedPetTargets.size());

        for (SpellLogEffectPowerDrainParams const& powerDrainTarget : effect.PowerDrainTargets)
        {
            *this << powerDrainTarget.Victim;
            *this << powerDrainTarget.Points;
            *this << powerDrainTarget.PowerType;
            *this << powerDrainTarget.Amplitude;
        }

        for (SpellLogEffectExtraAttacksParams const& extraAttacksTarget : effect.ExtraAttacksTargets)
        {
            *this << extraAttacksTarget.Victim;
            *this << extraAttacksTarget.NumAttacks;
        }

        for (SpellLogEffectDurabilityDamageParams const& durabilityDamageTarget : effect.DurabilityDamageTargets)
        {
            *this << durabilityDamageTarget.Victim;
            *this << durabilityDamageTarget.ItemID;
            *this << durabilityDamageTarget.Amount;
        }

        for (SpellLogEffectGenericVictimParams const& genericVictimTarget : effect.GenericVictimTargets)
            *this << genericVictimTarget.Victim;

        for (SpellLogEffectTradeSkillItemParams const& tradeSkillTarget : effect.TradeSkillTargets)
            *this << tradeSkillTarget.ItemID;

        for (SpellLogEffectFeedPetParams const& feedPetTarget : effect.FeedPetTargets)
            *this << feedPetTarget.ItemID;
    }

    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    return &_worldPacket;
}
Ejemplo n.º 4
0
WorldPacket const* WorldPackets::CombatLog::EnvironmentalDamageLog::Write()
{
    *this << Victim;
    *this << uint8(Type);
    *this << int32(Amount);
    *this << int32(Resisted);
    *this << int32(Absorbed);
    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    return &_worldPacket;
}
Ejemplo n.º 5
0
WorldPacket const* WorldPackets::CombatLog::SpellDamageShield::Write()
{
    *this << Attacker;
    *this << Defender;
    *this << int32(SpellID);
    *this << int32(TotalDamage);
    *this << int32(OverKill);
    *this << int32(SchoolMask);
    *this << int32(LogAbsorbed);
    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    return &_worldPacket;
}
Ejemplo n.º 6
0
WorldPacket const* WorldPackets::CombatLog::SpellEnergizeLog::Write()
{
    *this << CasterGUID;
    *this << TargetGUID;

    *this << int32(SpellID);
    *this << int32(Type);
    *this << int32(Amount);

    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    return &_worldPacket;
}
Ejemplo n.º 7
0
/*! @brief Calculate the odometry estimate from the previous estimation
    @param leftPos Left foot positional data.
    @param rightPos Right foot positional data.
    @param forceLeft The force in newtons of the left foot.
    @param forceRight The force in newtons of the right foot.
    @param gps External position data.
    @param compass External heading data.
 */
std::vector<float> OdometryEstimator::CalculateNextStep(const std::vector<float>& leftPos, const std::vector<float>& rightPos,
                                                        float forceLeft, float forceRight, std::vector<float>& gps, float compass)
{
    std::vector<float> result;
    LegIdentifier currSupport = SelectSupportLeg(forceLeft, forceRight);

    // Calculate left foot motion
    std::vector<float> LOdom(3);
    LOdom[0] = m_x_multiplier * (m_left_foot_position[0] - leftPos[0]);
    LOdom[1] = m_y_multiplier * (m_left_foot_position[1] - leftPos[1]);
    LOdom[2] = m_turn_multiplier * (m_left_foot_position[5] - leftPos[5]);

    // Calculate right foot motion
    std::vector<float> ROdom(3);
    ROdom[0] = m_x_multiplier * (m_right_foot_position[0] - rightPos[0]);
    ROdom[1] = m_y_multiplier * (m_right_foot_position[1] - rightPos[1]);
    ROdom[2] = m_turn_multiplier * (m_right_foot_position[5] - rightPos[5]);

    // Set results based on the support foot.
    if(currSupport == left)
        result = LOdom;
    else if(currSupport == right)
        result = ROdom;
    else
        result.resize(3,0.0f);

    // If external position data is available write to log.
    if(m_logging_enabled)
    {
        WriteLogData(gps, compass, LOdom, ROdom, forceLeft, forceRight, currSupport);
    }

    // Save historical data
    m_left_foot_position = leftPos;
    m_right_foot_position = rightPos;
    return result;
}
Ejemplo n.º 8
0
WorldPacket const* WorldPackets::CombatLog::SpellPeriodicAuraLog::Write()
{
    *this << TargetGUID;
    *this << CasterGUID;
    *this << int32(SpellID);
    *this << uint32(Effects.size());

    for (SpellLogEffect const& effect : Effects)
    {
        *this << int32(effect.Effect);
        *this << int32(effect.Amount);
        *this << int32(effect.OverHealOrKill);
        *this << int32(effect.SchoolMaskOrPower);
        *this << int32(effect.AbsorbedOrAmplitude);
        *this << int32(effect.Resisted);
        WriteBit(effect.Crit);
        WriteBit(effect.DebugInfo.is_initialized());
        WriteBit(effect.SandboxScaling.is_initialized());
        FlushBits();

        if (effect.SandboxScaling)
            *this << *effect.SandboxScaling;

        if (effect.DebugInfo)
        {
            *this << float(effect.DebugInfo->CritRollMade);
            *this << float(effect.DebugInfo->CritRollNeeded);
        }

    }

    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    return &_worldPacket;
}
Ejemplo n.º 9
0
BOOL CLogFile::SetLogFile(LPCTSTR filename, LogFileType type, DWORD size, DWORD count, DWORD time)
{
	if(!CreateUpperDirectory(filename))
		return FALSE; 

	WriteLogData();

	_tcscpy(log_file_name, filename);
	file_type = type;
	max_log_size = min(size, MAX_LOG_SIZE);
	max_log_count = count;
	max_log_time = time;
	if (log_data) {
		/*
		LPTSTR temp = (LPTSTR)HeapReAlloc(hHeap, 0, log_data, max_log_size);
		if (temp == NULL)
		HeapFree(hHeap, 0, log_data);
		log_data = temp;
		*/
		LPTSTR temp = (LPTSTR)VirtualAlloc(NULL, max_log_size, MEM_COMMIT, PAGE_READWRITE);
		if (temp)
			memcpy(temp, log_data, log_size);
		VirtualFree(log_data, 0, MEM_RELEASE);
		log_data = temp;
	}
	else if (max_log_size > 0) {
		//		log_data = (LPTSTR)HeapAlloc(hHeap, 0, max_log_size);
		log_data = (LPTSTR)VirtualAlloc(NULL, max_log_size, MEM_COMMIT, PAGE_READWRITE);
	}

	if (max_log_size > 0 && log_data == NULL) {
		return FALSE;
	}

	return TRUE;
}
Ejemplo n.º 10
0
WorldPacket const* WorldPackets::CombatLog::SpellNonMeleeDamageLog::Write()
{
    *this << Me;
    *this << CasterGUID;
    *this << CastID;
    *this << int32(SpellID);
    *this << int32(Damage);
    *this << int32(Overkill);
    *this << uint8(SchoolMask);
    *this << int32(ShieldBlock);
    *this << int32(Resisted);
    *this << int32(Absorbed);
    WriteBit(Periodic);
    WriteBits(Flags, 7);
    WriteBit(false); // Debug info
    WriteLogDataBit();
    WriteBit(SandboxScaling.is_initialized());
    FlushBits();
    WriteLogData();
    if (SandboxScaling)
        *this << *SandboxScaling;

    return &_worldPacket;
}
Ejemplo n.º 11
0
BOOL CLogFile::PutLog(LPCTSTR log_message)
{
	DWORD len = _tcslen(log_message) * sizeof(TCHAR);
	BOOL result = TRUE;

	EnterCriticalSection(&cs);
	if (file_type != LOGFILE_ONE_FILE) {
		BOOL write = FALSE;
		SYSTEMTIME st;

		GetLocalTime(&st);
		switch (file_type) {
		case LOGFILE_PER_YEAR:
			if (st.wYear != last_date.wYear)
				write = TRUE;
			break;
		case LOGFILE_PER_MONTH:
			if (st.wMonth != last_date.wMonth || st.wYear != last_date.wYear)
				write = TRUE;
			break;
		case LOGFILE_PER_DAY:
			if (st.wDay != last_date.wDay || st.wMonth != last_date.wMonth || st.wYear != last_date.wYear)
				write = TRUE;
			break;
		case LOGFILE_PER_HOUR:
			if (st.wHour != last_date.wHour || st.wDay != last_date.wDay || st.wMonth != last_date.wMonth || st.wYear != last_date.wYear)
				write = TRUE;
			break;
		case LOGFILE_PER_TENMIN:
			if (st.wMinute / 10 != last_date.wMinute / 10 || st.wHour != last_date.wHour || st.wDay != last_date.wDay || st.wMonth != last_date.wMonth || st.wYear != last_date.wYear)
				write = TRUE;
			break;
		}
		if (write)
			result = WriteLogData();
		last_date = st;
	}

	if (log_size + len >= max_log_size - 1)
		result = WriteLogData();
	if (result) {
		if (len >= max_log_size)
			result = WriteLogFile(log_message);
		else {
			if (log_data) {
				memcpy(log_data + log_size / sizeof(TCHAR), log_message, len);
				log_size += len;
				log_count++;

				if (logCountExpired() || logTimeExpired()) {
					result = WriteLogData();
					if (result == FALSE) {
						log_size -= len;
						log_count--;
					}
				}
			}
		}
	}
	LeaveCriticalSection(&cs);

	return result;
}
Ejemplo n.º 12
0
DWORD WINAPI CommMonitor( LPSTR lpData)
{
//监控串口接收数据,并完成数据格式分析,将结果放入结果队列
	CommData
	SYSTEMTIME SystemTime;
	int	 nItemCount,TrayNum,CupNum;//样本项目号,盘号,杯号
	BYTE  SampleIDLen ;//数据包功能号,样本ID长度
	WORD	wSampleNo;
	bool blogfile;
	int  i,ByteRecieved;
	bool isdataPacket=FALSE;
	char  DataBuffer[200];// 数据缓冲区!
	CHAR    TempWorkingID[c_MaxWorkingIDLength+1];//样本号,chj
	char LSampleID[5];
	Init()
	
	ResetOpPointer()				
	
	ResetRxPointer()																																																																																																															
	

 	nItemCount =0;
	FillDevName()					
	SetCommWaitMask(EV_RXCHAR)
	PurgeComm( hComm, PURGE_RXCLEAR );	
	blogfile=NewLogFile("Syn_ELISE.txt");
	WriteCommChar(XON)
	while (TRUE)
	{
		WaitEvent(EV_RXCHAR)		
		do
		{
			ReadFile(hComm, &RxChar, 1, &dwReadLength, NULL);	
			if(RxChar==STX)
				isdataPacket=TRUE;
			if(isdataPacket)
			{
				DataBuffer[i]=RxChar;
				i++;
			}
			if(RxChar==ENQ||RxChar==EOT)
			{
				break;
			}
			if(((RxChar==ETX)|(RxChar==ETB))&(isdataPacket))
			{
				//DataBuffer[i]=RxChar;
				ByteRecieved=i;
				break;
			}	
		}while(dwReadLength==1);
		i=0;
		if((RxChar==ETX))
		{
			while(DataBuffer[i]!=STX)	i++;
		}
		lpOpPointer=&DataBuffer[i];
		if (blogfile)
		{
			WriteLogData(hLogFile,lpOpPointer,ByteRecieved);
		}

		switch (RxChar) 
		{
		case ENQ:
		//	Sleep(300);
			TransmitCommChar(hComm,ACK);
			break;
		case ETB:
		case ETX:
			//先进行校验的计算,若为正常接受则进行结果处理!
			//目前,由于资料校验和的计算方法与结果包中数据不符!尚未加校验计算
			/*
			    需要到仪器上读出数据包进行分析
			*/
			switch(*(lpOpPointer+2))
			{
			case 'H':
				break;
			case 'P':
				break;
			case 'O':
				nItemCount=0;
				TrayNum=(int)StrToInt(lpOpPointer+c_TrayNumEOff,c_TrayNumLen);				
				CupNum=(int)StrToInt(lpOpPointer+c_CupNumEOff,c_CupNumLen);			
				wSampleNo =(int)StrToInt(lpOpPointer+c_SequenceNoOff,c_SequenceNoLen);
				_itoa(wSampleNo,LSampleID,10);
				TempWorkingID[0]=lpDevice->DevItemType;
				memset(&TempWorkingID[1],0x30,5);
				SampleIDLen=strlen(LSampleID);
				strncpy(&TempWorkingID[6-SampleIDLen],&LSampleID[0],SampleIDLen);
				TempWorkingID[6]='\0';
						
				break;	//继续接收	
			case 'R':
				FillSampleID(nItemCount, wSampleNo)	
				strncpy(OutResult[nItemCount].WorkingID,TempWorkingID,7);//填写工作单号
				OutResult[nItemCount].ItemNo=nItemCount+1;
				FillItemName(nItemCount,lpOpPointer+c_ItemNameOff ,c_ItemNameLen)	

				if (OutResult[nItemCount].ItemID[1]==124)//'|'  如果项目名称长度为1则添加字符串尾标志-ASCII 码值为 0
				{
					OutResult[nItemCount].ItemID[1]='\0';			
					FillResult(nItemCount,lpOpPointer+c_ResultOff-2,c_ResultLen)
				}
				else
					FillResult(nItemCount,lpOpPointer+c_ResultOff,c_ResultLen)

				OutResult[nItemCount].ItemNo=nItemCount+1;
//填日期
				GetSystemTime(&SystemTime); 
				FillDate(nItemCount, SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond)
				nItemCount++;
				(*lpResultProcessRoutine)(lpDevice->nDevNO, &OutResult[nItemCount-1], 1);
				lpDevice->dwRecordCount+=1;  
				break;
			case 'L':
				break;
			}
		//	Sleep(300);
			TransmitCommChar(hComm,ACK);
			break;
		case EOT:
			//结果入队列
		default:
			TransmitCommChar(hComm,ACK);
			break;
		}
Ejemplo n.º 13
0
DWORD WINAPI CommMonitor( LPSTR lpData)
{
    //监控串口接收数据,并完成数据格式分析,将结果放入结果队列
	int		nItemCount,SampleIDLen,nDataOff,nResultLen,iSampleID;
	bool	bLogFile;
	char    TempWorkingID[7];
	LPSTR   lpPointer;
	//应答包
	char * p_Ack="\x2\x6\x3";
	char * p_Nak="\x2\x16\x3";
	char * p_IntSessionTXT="\x2I\x20\x3";
	char * p_ReleaseMaster="\x2M\x20\x20\x20\x20\x20\x3";
	char  PackageType;
	char SampleID[10];
	SYSTEMTIME SystemTime;
	CommData
    //通信类型1'、1''、2、3、4、5
	
	Init()
	ResetOpPointer()				

	FillDevName()					
	SetCommWaitMask(EV_RXFLAG)
	PurgeComm( hComm, PURGE_RXCLEAR );	
	memset(lpOpPointer , 0, c_RxBufferLength );
	if(NewLogFile("AEROSET.txt"))
	{
		bLogFile=TRUE;
	}

	while (TRUE)
	{


		WaitEvent(EV_RXFLAG)//等待接受数据包
		GetInQueueLength(dwReadLength)//分析数据
		ReadCommBlock(dwReadLength)
		PackageType=*(lpOpPointer+1);//数据包的类型
		if(bLogFile)
		{
			WriteLogData(hLogFile,lpOpPointer,dwReadLength);
		}
		//校验接收到的数据,若正确,则处理,否则给否定应答。
		/*
			checksum  calculation
		*/

		/*结果的数据块中可能包含病人信息、ID信息、结果数据等组。*/
		PackageType=*(lpOpPointer+1);
		switch(PackageType)
		{
		case 'Q':
			WriteCommBlock(p_Ack,3)//肯定应答
			//WriteCommChar(ACK)
			break;

		case 'R':
			//结果处理
			WriteCommBlock(p_Ack,3)//肯定应答
			iSampleID=StrToInt(lpOpPointer+c_SampleIDOff,c_SamlpeIDLen);
			itoa(iSampleID,&SampleID[0],10);
			SampleIDLen=strlen(SampleID);
			TempWorkingID[0]=lpDevice->DevItemType;
			if(SampleIDLen>=6)
			{
				strncpy(&TempWorkingID[1],&SampleID[SampleIDLen-5],5);
			}
			else
				strncpy(&TempWorkingID[6-SampleIDLen],SampleID,SampleIDLen);
			TempWorkingID[6]='\0';
			GetLocalTime(&SystemTime);
			nItemCount=0;
			for(nDataOff =c_DataOff; *(lpOpPointer+nDataOff)!=ETB ;)
			{
				strncpy(OutResult[nItemCount].WorkingID,TempWorkingID,7);
				OutResult[nItemCount].ItemNo=nItemCount+1;
				lpPointer=lpOpPointer+nDataOff;
				DeleSpace(4)
				strncpy(OutResult[nItemCount].ItemID,lpPointer,nResultLen);
				OutResult[nItemCount].ItemID[nResultLen]='\0';
				lpPointer=lpOpPointer+nDataOff+c_ResultOff;
				DeleSpace(c_ResultLen )
				FillResult(nItemCount, lpPointer ,nResultLen ) 
				FillDate(nItemCount, SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond)
				nDataOff = nDataOff + c_OneDataLen;
				nItemCount++;
			}
			if(nItemCount>0)
			{
				(*lpResultProcessRoutine)(lpDevice->nDevNO, OutResult, nItemCount);
				lpDevice->dwRecordCount+=nItemCount;
			}
		
			//WriteCommChar(ACK)
		///	WriteCommBlock(p_Ack,3)//肯定应答
			break;
		case ACK:
		case NAK:
			break;
       
		}
	

		ResetRxPointer()		
	

	}
	if(bLogFile)
	{
		CloseLogFile(hLogFile);
	}
	return TRUE;
} // end of CommWatchProc()
Ejemplo n.º 14
0
WorldPacket const* WorldPackets::CombatLog::AttackerStateUpdate::Write()
{
    ByteBuffer attackRoundInfo;
    attackRoundInfo << uint32(HitInfo);
    attackRoundInfo << AttackerGUID;
    attackRoundInfo << VictimGUID;
    attackRoundInfo << int32(Damage);
    attackRoundInfo << int32(OverDamage);
    attackRoundInfo << uint8(SubDmg.is_initialized());
    if (SubDmg)
    {
       attackRoundInfo << int32(SubDmg->SchoolMask);
       attackRoundInfo << float(SubDmg->FDamage);
       attackRoundInfo << int32(SubDmg->Damage);
        if (HitInfo & (HITINFO_FULL_ABSORB | HITINFO_PARTIAL_ABSORB))
            attackRoundInfo << int32(SubDmg->Absorbed);
        if (HitInfo & (HITINFO_FULL_RESIST | HITINFO_PARTIAL_RESIST))
            attackRoundInfo << int32(SubDmg->Resisted);
    }

    attackRoundInfo << uint8(VictimState);
    attackRoundInfo << uint32(AttackerState);
    attackRoundInfo << uint32(MeleeSpellID);
    if (HitInfo & HITINFO_BLOCK)
        attackRoundInfo << int32(BlockAmount);

    if (HitInfo & HITINFO_RAGE_GAIN)
        attackRoundInfo << int32(RageGained);

    if (HitInfo & HITINFO_UNK1)
    {
        attackRoundInfo << uint32(UnkState.State1);
        attackRoundInfo << float(UnkState.State2);
        attackRoundInfo << float(UnkState.State3);
        attackRoundInfo << float(UnkState.State4);
        attackRoundInfo << float(UnkState.State5);
        attackRoundInfo << float(UnkState.State6);
        attackRoundInfo << float(UnkState.State7);
        attackRoundInfo << float(UnkState.State8);
        attackRoundInfo << float(UnkState.State9);
        attackRoundInfo << float(UnkState.State10);
        attackRoundInfo << float(UnkState.State11);
        attackRoundInfo << uint32(UnkState.State12);
    }

    if (HitInfo & (HITINFO_BLOCK | HITINFO_UNK12))
        attackRoundInfo << float(Unk);

    attackRoundInfo << uint8(SandboxScaling.Type);
    attackRoundInfo << uint8(SandboxScaling.TargetLevel);
    attackRoundInfo << uint8(SandboxScaling.Expansion);
    attackRoundInfo << uint8(SandboxScaling.Class);
    attackRoundInfo << uint8(SandboxScaling.TargetMinScalingLevel);
    attackRoundInfo << uint8(SandboxScaling.TargetMaxScalingLevel);
    attackRoundInfo << int16(SandboxScaling.PlayerLevelDelta);
    attackRoundInfo << int8(SandboxScaling.TargetScalingLevelDelta);

    WriteLogDataBit();
    FlushBits();
    WriteLogData();

    *this << uint32(attackRoundInfo.size());
    _worldPacket.append(attackRoundInfo);
    _fullLogPacket.append(attackRoundInfo);

    return &_worldPacket;
}