//***************************************************************************** // SCIprintErrors // // Description: Print the BMS error flags. // //***************************************************************************** void SCIprintErrors(void) { uint16 i=0; char buf[20]; int junk; uint16 tmp=0; SCIprintString("Erreurs:\n\n\r"); if(gError.slaveTimeout){ SCIprintString("Expiration de la communication avec les modules: "); for(i=0; i<N_MOD; i++) { tmp = (1<<i); if((gSlaveComState & tmp) == tmp){ if(idOf(i) == 0) // On n'a jamais reçu de paquet de cet esclave SCIprintString("? "); else junk = sprintf(buf,"%d ", idOf(i)); SCIprintString(buf); } } SCIprintString("\n\r"); } if(gError.cellMaxVolt) SCIprintString("Tension de cellules maximale atteinte\n\r"); if(gError.cellMinVolt) SCIprintString("Tension de cellules minimale atteinte\n\r"); if(gError.cellMaxTemp) SCIprintString("Température de cellule maximale atteinte\n\r"); if(gError.cellMinTemp) SCIprintString("Température de cellule minimale atteinte\n\r"); if(gError.maxPeakCurrent) SCIprintString("Courant moyen sur 10 s maximal atteint\n\r"); SCIprintString("\n\r"); }
//****************************************************************************** // Find the address of the highest and lowest cell voltage or temperature (same algorithm) // Parameters : // (input) cellTable : voltage table / temperature table // (output) lowestAddr / highestAddr : table address of the lowest / highest // (output) lowestSlaveID / highestSlaveID : ID of the slave which has the corresponding cell // (output) lowestCellNumber / highestCellNumber : cell number of the lowest / highest //****************************************************************************** void findMaxMin(uint16 cellTable[][N_CELL], int16 **lowestAddr, int16 **highestAddr, uint8 *lowestSlaveID, uint8 *highestSlaveID, uint8 *lowestCellNumber, uint8 *highestCellNumber) { uint8 i,j; int16 max, min; // signed type for supporting negative temperature measurement // Initialisation with first table element max = cellTable[0][0]; min = cellTable[0][0]; *lowestAddr = &cellTable[0][0]; *highestAddr = &cellTable[0][0]; *lowestSlaveID = idOf(0); *highestSlaveID = idOf(0); // Search the min and max for(i = 0; i < N_MOD; i++) // First dimension (array) { for(j = 0; j < N_CELL; j++) // Second dimension (array) { if(cellTable[i][j] > max) // If it is a new maximum { max = cellTable[i][j]; *highestAddr = &cellTable[i][j]; *highestSlaveID = idOf(i); *highestCellNumber = j; } else if(cellTable[i][j] < min) // If it is a new minimum { min = cellTable[i][j]; *lowestAddr = &cellTable[i][j]; *lowestSlaveID = idOf(i); *lowestCellNumber = j; } } } }
void stopCellBalancing() { uint8 i; gBalanceThreshold_mV = 0; // Build the balance vector for each battery pack (each slave circuit) for(i = 0; i < N_MOD; i++) { // Send the balancing command to the slave CAN_SendBalancingCommand(idOf(i),gParams.maxCellVoltage, 0); // Null balance vector } // Note : We could broadcast a Banlancing command instead to stop balancing, there would be less // messages sent for the same result gFlags.equilibrating = 0; }
bool DataMapper<Subclass, T, I>::save(T * model) { if (!model) { return false; } Identity id = idOf(model); QVariantMap record; buildRecordFrom(model, record); QList<QString> variables = record.keys(); if (isValidId(id)) { record[identityFieldName()] = id; QSqlQuery query = getDatabase().build(UPDATE(table()).SET(variables).WHERE(identityFieldName() + " = :" + identityFieldName()), record); query.exec(); } else { QSqlQuery query = getDatabase().build(INSERT().INTO(table()).SET(variables, true), record); if (query.exec()) { Identity id = query.lastInsertId().value<Identity>(); if (isValidId(id)) { m_identities.registerModel(id, model); } } } saveRelationsOf(model); return true; }
void SCIprintStatData(int16 volt[][N_CELL], int temp[][N_CELL]) { char buf[70]; int i,j; if(printStatTime == 0) return; if(timeFollow < (printStatTime*100)) { if((timeFollow % sendFreq) == 0) { // On donne un titre au colonnes si c'est le premier appel if(timeFollow == 0) { sprintf(buf, "timestamp(ms),no_module,no_cellule,tension(mV),temperature(0.1degC)\n\r"); SCIprintString(buf); } //On envoie les données sous le format : timestamp, no_module, no_cellule, tension, température for(i = 0; i < N_MOD; i++) { for(j = 0; j < N_CELL; j++) { sprintf(buf, "%d,%d,%d,%d,%d\n\r", timeFollow*10, idOf(i), j+1, volt[i][j], temp[i][j]); SCIprintString(buf); } } } timeFollow++; } else { printStatTime = 0; // Envoie des données terminés, on arrête d'envoyer timeFollow = 0; PITCE_PCE3 = 0; //On désactive l'interruption } }
void sendCellBalancingCommand(int16 voltageThreshold) { uint8 i,j; uint8 balancingDone = 1; int16 balVector; // Balancing vector bit 0 = first cell, bit 11 = last cell (higher voltage) // Ensure correct voltageThreshold if(voltageThreshold < gParams.minCellVoltage || voltageThreshold > gParams.maxCellVoltage) return; // Build the balance vector for each battery pack (each slave circuit) for(i = 0; i < N_MOD; i++) { balVector = 0; for(j = 0; j < N_CELL; j++) { if(gCellVolt[i][j] > voltageThreshold) { // Ensure the temperature is ok before activating discharge for this cell if(gParams.highDischargeCellTemp > gCellTemp[i][j]) { balVector |= (1 << j); // Set the corresponding bit to 1 to activate discharge on this cell } balancingDone = 0; // As long as there is a cell with a voltage higher than the threshold } } // Send the balancing command to the slave CAN_SendBalancingCommand(idOf(i),voltageThreshold, balVector); } gFlags.equilibrating = 1; if(balancingDone == 1) stopCellBalancing(); }
bool DataMapper<Subclass, T, I>::remove(T * model) { QSqlQuery query = getDatabase().build(DELETE().FROM(table()).WHERE(identityFieldName() + " = " + QString::number(idOf(model)))); return query.exec(); }
I DataMapper<Subclass, T, I>::saveReturningId(T * model) { save(model); return idOf(model); }