MCPcopy Create free account
hub / github.com/collin80/SavvyCAN / doModifiers

Method doModifiers

framesenderwindow.cpp:461–516  ·  view source on GitHub ↗

given an index into the sendingData list we run the modifiers that it has set up The index into the sendingData list

Source from the content-addressed store, hash-verified

459/// </summary>
460/// <param name="idx">The index into the sendingData list</param>
461void FrameSenderWindow::doModifiers(int idx)
462{
463 int shadowReg = 0; //shadow register we use to accumulate results
464 int first=0, second=0;
465
466 FrameSendData *sendData = &sendingData[idx];
467 Modifier *mod;
468 ModifierOp op;
469
470 if (sendData->modifiers.count() == 0) return; //if no modifiers just leave right now
471
472 qDebug() << "Executing mods";
473
474 for (int i = 0; i < sendData->modifiers.count(); i++)
475 {
476 mod = &sendData->modifiers[i];
477 for (int j = 0; j < mod->operations.count(); j++)
478 {
479 op = mod->operations.at(j);
480 if (op.first.ID == -1)
481 {
482 first = shadowReg;
483 }
484 else first = fetchOperand(idx, op.first);
485 second = fetchOperand(idx, op.second);
486 switch (op.operation)
487 {
488 case ADDITION:
489 shadowReg = first + second;
490 break;
491 case AND:
492 shadowReg = first & second;
493 break;
494 case DIVISION:
495 shadowReg = first / second;
496 break;
497 case MULTIPLICATION:
498 shadowReg = first * second;
499 break;
500 case OR:
501 shadowReg = first | second;
502 break;
503 case SUBTRACTION:
504 shadowReg = first - second;
505 break;
506 case XOR:
507 shadowReg = first ^ second;
508 break;
509 case MOD:
510 shadowReg = first % second;
511 }
512 }
513 //Finally, drop the result into the proper data byte
514 sendData->data[mod->destByte] = (unsigned char) shadowReg;
515 }
516}
517
518int FrameSenderWindow::fetchOperand(int idx, ModifierOperand op)

Callers

nothing calls this directly

Calls 1

atMethod · 0.80

Tested by

no test coverage detected