| 659 | } |
| 660 | |
| 661 | void FrameSenderWindow::processTriggerText(int line) |
| 662 | { |
| 663 | qDebug() << "processTriggerText"; |
| 664 | QString trigger; |
| 665 | |
| 666 | //Example line: |
| 667 | //id0x200 5ms 10x bus0,1000ms |
| 668 | //trigger has two levels of syntactic parsing. First you split by comma to get each |
| 669 | //actual trigger. Then you split by spaces to get the tokens within each trigger |
| 670 | //trigger = ui->tableSender->item(line, 5)->text().toUpper().trimmed().replace(" ", ""); |
| 671 | trigger = ui->tableSender->item(line, 7)->text().toUpper(); |
| 672 | if (trigger != "") |
| 673 | { |
| 674 | QStringList triggers = trigger.split(','); |
| 675 | sendingData[line].triggers.clear(); |
| 676 | sendingData[line].triggers.reserve(triggers.length()); |
| 677 | for (int k = 0; k < triggers.length(); k++) |
| 678 | { |
| 679 | Trigger thisTrigger; |
| 680 | //start out by setting defaults - should be moved to constructor for class Trigger. |
| 681 | thisTrigger.bus = -1; //-1 means we don't care which |
| 682 | thisTrigger.ID = -1; //the rest of these being -1 means nothing has changed it |
| 683 | thisTrigger.maxCount = -1; |
| 684 | thisTrigger.milliseconds = -1; |
| 685 | thisTrigger.currCount = 0; |
| 686 | thisTrigger.msCounter = 0; |
| 687 | thisTrigger.readyCount = true; |
| 688 | |
| 689 | QStringList trigToks = triggers[k].split(' '); |
| 690 | for (int x = 0; x < trigToks.length(); x++) |
| 691 | { |
| 692 | QString tok = trigToks.at(x); |
| 693 | if (tok.left(2) == "ID") |
| 694 | { |
| 695 | thisTrigger.ID = Utility::ParseStringToNum(tok.right(tok.length() - 3)); |
| 696 | if (thisTrigger.maxCount == -1) thisTrigger.maxCount = 10000000; |
| 697 | |
| 698 | if (thisTrigger.milliseconds == -1) thisTrigger.milliseconds = 0; //by default don't count, just send it upon trigger |
| 699 | thisTrigger.readyCount = false; //won't try counting until trigger hits |
| 700 | } |
| 701 | else if (tok.endsWith("MS")) |
| 702 | { |
| 703 | thisTrigger.milliseconds = Utility::ParseStringToNum(tok.left(tok.length()-2)); |
| 704 | if (thisTrigger.maxCount == -1) thisTrigger.maxCount = 10000000; |
| 705 | if (thisTrigger.ID == -1) thisTrigger.ID = 0; |
| 706 | } |
| 707 | else if (tok.endsWith("X")) |
| 708 | { |
| 709 | thisTrigger.maxCount = Utility::ParseStringToNum(tok.left(tok.length() - 1)); |
| 710 | if (thisTrigger.ID == -1) thisTrigger.ID = 0; |
| 711 | if (thisTrigger.milliseconds == -1) thisTrigger.milliseconds = 10; |
| 712 | } |
| 713 | else if (tok.startsWith("BUS")) |
| 714 | { |
| 715 | thisTrigger.bus = Utility::ParseStringToNum(tok.right(tok.length() - 3)); |
| 716 | } |
| 717 | } |
| 718 | //now, find anything that wasn't set and set it to defaults |