void Warden::SendModuleToClient() { sLog->outDebug(LOG_FILTER_WARDEN, "Send module to client"); // Create packet structure WardenModuleTransfer packet; uint32 sizeLeft = _module->CompressedSize; uint32 pos = 0; uint16 burstSize; while (sizeLeft > 0) { burstSize = sizeLeft < 500 ? sizeLeft : 500; packet.Command = WARDEN_SMSG_MODULE_CACHE; packet.DataSize = burstSize; memcpy(packet.Data, &_module->CompressedData[pos], burstSize); sizeLeft -= burstSize; pos += burstSize; EncryptData((uint8*)&packet, burstSize + 3); WorldPacket pkt1(SMSG_WARDEN_DATA, burstSize + 3); pkt1.append((uint8*)&packet, burstSize + 3); _session->SendPacket(&pkt1); } }
void WardenBase::SendModuleToClient() { sLog->outStaticDebug("Send module to client"); // Create packet structure WardenModuleTransfer pkt; uint32 size_left = Module->CompressedSize; uint32 pos = 0; uint16 burst_size; while (size_left > 0) { burst_size = size_left < 500 ? size_left : 500; pkt.Command = WARDEN_SMSG_MODULE_CACHE; pkt.DataSize = burst_size; memcpy(pkt.Data, &Module->CompressedData[pos], burst_size); size_left -= burst_size; pos += burst_size; EncryptData((uint8*)&pkt, burst_size + 3); WorldPacket pkt1(SMSG_WARDEN_DATA, burst_size + 3); pkt1.append((uint8*)&pkt, burst_size + 3); Client->SendPacket(&pkt1); } }
void send_can() { if (this->can_timer.has_expired()) { switch (this->can_module_i) { case 0: { Can::Addr::bms0::cmu1_volts0 pkt0(0); pkt0.frame().cell0 = this->voltage_sensor.voltages[0]; pkt0.frame().cell1 = this->voltage_sensor.voltages[1]; pkt0.frame().cell2 = this->voltage_sensor.voltages[2]; pkt0.frame().cell3 = this->voltage_sensor.voltages[3]; this->common_can_out.tx(pkt0); Can::Addr::bms0::cmu1_volts1 pkt1(0); pkt1.frame().cell4 = this->voltage_sensor.voltages[4]; pkt1.frame().cell5 = this->voltage_sensor.voltages[5]; pkt1.frame().cell6 = this->voltage_sensor.voltages[6]; pkt1.frame().cell7 = this->voltage_sensor.voltages[7]; this->common_can_out.tx(pkt1); break; } case 1: { Can::Addr::bms0::cmu2_volts0 pkt0(0); pkt0.frame().cell0 = this->voltage_sensor.voltages[8]; pkt0.frame().cell1 = this->voltage_sensor.voltages[9]; pkt0.frame().cell2 = this->voltage_sensor.voltages[10]; pkt0.frame().cell3 = this->voltage_sensor.voltages[11]; this->common_can_out.tx(pkt0); Can::Addr::bms0::cmu2_volts1 pkt1(0); pkt1.frame().cell4 = this->voltage_sensor.voltages[12]; pkt1.frame().cell5 = this->voltage_sensor.voltages[13]; pkt1.frame().cell6 = this->voltage_sensor.voltages[14]; pkt1.frame().cell7 = this->voltage_sensor.voltages[15]; this->common_can_out.tx(pkt1); break; } case 2: { Can::Addr::bms0::cmu3_volts0 pkt0(0); pkt0.frame().cell0 = this->voltage_sensor.voltages[16]; pkt0.frame().cell1 = this->voltage_sensor.voltages[17]; pkt0.frame().cell2 = this->voltage_sensor.voltages[18]; pkt0.frame().cell3 = this->voltage_sensor.voltages[19]; this->common_can_out.tx(pkt0); Can::Addr::bms0::cmu3_volts1 pkt1(0); pkt1.frame().cell4 = this->voltage_sensor.voltages[20]; pkt1.frame().cell5 = this->voltage_sensor.voltages[21]; pkt1.frame().cell6 = this->voltage_sensor.voltages[22]; pkt1.frame().cell7 = this->voltage_sensor.voltages[23]; this->common_can_out.tx(pkt1); break; } case 3: { Can::Addr::bms0::cmu4_volts0 pkt0(0); pkt0.frame().cell0 = this->voltage_sensor.voltages[24]; pkt0.frame().cell1 = this->voltage_sensor.voltages[25]; pkt0.frame().cell2 = this->voltage_sensor.voltages[26]; pkt0.frame().cell3 = this->voltage_sensor.voltages[27]; this->common_can_out.tx(pkt0); Can::Addr::bms0::cmu4_volts1 pkt1(0); pkt1.frame().cell4 = this->voltage_sensor.voltages[28]; pkt1.frame().cell5 = this->voltage_sensor.voltages[29]; pkt1.frame().cell6 = this->voltage_sensor.voltages[30]; pkt1.frame().cell7 = this->voltage_sensor.voltages[31]; this->common_can_out.tx(pkt1); break; } case 4: { Can::Addr::bms1::pack_soc soc_pkt(0); soc_pkt.frame().soc_Ah = 0; soc_pkt.frame().soc_percentage = 0; this->common_can_out.tx(soc_pkt); Can::Addr::bms1::precharge pcg_pkt(0); // precharge pcg_pkt.frame().precharge_state = this->state.precharge; this->common_can_out.tx(pcg_pkt); } case 5: { // min max volts temps // pack volt current Can::Addr::bms1::pack_volt_curr pack_volt_curr_pkt(0); for (uint8_t i=0; i<NU_BPS_N_MODULES; ++i) { pack_volt_curr_pkt.frame().pack_voltage += this->voltage_sensor.voltages[i]; } pack_volt_curr_pkt.frame().pack_current = this->current_sensor.currents[0]; this->common_can_out.tx(pack_volt_curr_pkt); // statuses Can::Addr::bms1::extended_status stat(0); stat.frame().pack_flags0 = this->state.trip_code; this->common_can_out.tx(stat); } } ++this->can_module_i %= 6; this->can_timer.reset(); } }