Changeset 18341 for branches/fscctrl_safety_limits/src
- Timestamp:
- 10/07/15 17:08:29 (9 years ago)
- Location:
- branches/fscctrl_safety_limits/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fscctrl_safety_limits/src/HeadersFSC.h
r17639 r18341 10 10 kDisconnected = 1, 11 11 kConnected = 2, 12 kHighCurrent = 3, 13 kOverCurrent = 0xff+1, 12 14 }; 13 15 } … … 46 48 uint16_t time_ms; 47 49 } __attribute__((__packed__)); 50 51 52 struct SecurityCurrentLimits 53 { 54 double ethernet_switch; 55 double FFC; 56 double FLP; 57 double FAD_digital; 58 double FAD_negative; 59 double FAD_positive; 60 double FPA_digital; 61 double FPA_negative; 62 double FPA_positive; 63 }; 48 64 } 49 65 -
branches/fscctrl_safety_limits/src/fscctrl.cc
r18194 r18341 41 41 vector<Interpolator2D::vec> fPositionsSensors; 42 42 vector<Interpolator2D::vec> fPositionsBias; 43 FSC::SecurityCurrentLimits fSecurityCurrentLimits; 44 bool fSecurityLimitsExceeded; 43 45 44 46 virtual void UpdateTemp(float, const vector<float> &) … … 437 439 */ 438 440 441 CheckCurrentLimits(currents); 439 442 if (fIsVerbose) 440 443 { 444 /* 441 445 for (size_t i=0; i<resist.size(); i++) 442 446 //if (resist[i]>800 && resist[i]<2000) … … 446 450 else 447 451 Out() << setw(2) << i << " - " << setw(4) << (int)resist[i] << ": " << "----" << endl; 452 */ 453 PrintTemperaturesNicely(temperatures); 454 PrintVoltagesNicely(voltages, currents); 455 Out() << "\n" << "fSecurityLimitsExceeded:" << fSecurityLimitsExceeded << endl; 448 456 } 449 457 … … 456 464 fNumConsecutiveMessages++; 457 465 466 458 467 return true; 459 468 } 469 470 void PrintTemperaturesNicely(const vector<float> &t) 471 { 472 /* 473 "FSC_CONTROL/TEMPERATURE", "F:1;F:31;F:8;F:8;F:4;F:4;F:4", 474 "|t[s]:FSC uptime" 475 "|T_sens[deg C]:Sensor compartment temperatures" 476 "|T_crate[deg C]:Temperatures crate 0 (back/front), 1 (b/f), 2 (b/f), 3 (b/f)" 477 "|T_ps[deg C]:Temp power supplies crate 0 (back/front), 1, 2, 3" 478 "|T_aux[deg C]:Auxiliary power supply temperatures FTM (top/bottom), FSC (t/b)" 479 "|T_back[deg C]:FTM backpanel temperatures FTM (top/bottom), FSC (top/bottom)" 480 "|T_eth[deg C]:Ethernet switches temperatures top (front/back), bottom (f/b)"), 481 // sensor compartment temperatures 482 0, 1, 2, 3, 4, 5, 6, 56, 57, 58, 59, 60, 483 61, 62, 32, 33, 34, 35, 36, 63, 37, 38, 39, 24, 484 25, 26, 27, 28, 29, 30, 31, 485 // crate temperatures (0-3, back/front) 486 12, 13, 52, 53, 44, 46, 20, 21, 487 //crate power supply temperatures (0-3) 488 8, 9, 48, 49, 40, 41, 16, 17, 489 // aux power supplies (FTM-side top/bot, FSC-side top/bot) 490 45, 50, 19, 42, 491 // backpanel (FTM-side top/bot, FSC-side top/bot) 492 11, 51, 18, 43, 493 // switch boxes (top front/back, bottom front/back) 494 15, 14, 47, 10, 495 */ 496 //Out() << "0 1 2 3 4 5 6 7 " << endl; 497 //Out() << "01234567890123456789012345678901234567890123456789012345678901234567890123456789" << endl; 498 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 499 Out() << "T_sens:"; 500 for (int i=0; i<31; i++){ 501 if (i%16==0){ 502 Out() << "\n"; 503 } 504 Out() << setw(4) << setprecision(1) << fixed << t[i] << " "; 505 } 506 Out() << endl; 507 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 508 509 Out() << "T_crate: (B:back, F:front)" << endl; 510 Out() << "0: B| F|1: B| F|2: B| F|3: B| F|" << endl; 511 for (int i=31; i<31+8; i++){ 512 Out() << setw(4) << setprecision(1) << fixed << t[i] << "|"; 513 } 514 Out() << endl; 515 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 516 517 Out() << "T_ps: crate power supplies (B:back, F:front)" << endl; 518 Out() << "0: B| F|1: B| F|2: B| F|3: B| F|" << endl; 519 for (int i=31+8; i<31+8+8; i++){ 520 Out() << setw(4) << setprecision(1) << fixed << t[i] << "|"; 521 } 522 Out() << endl; 523 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 524 Out() << "T_aux: auxiliary power supplies" << endl; 525 Out() << "FTM top| bot|FSC top| bot|" << endl; 526 for (int i=31+8+8; i<31+8+8+4; i++){ 527 Out() << setw(7) << setprecision(1) << fixed << t[i] << "|"; 528 } 529 Out() << endl; 530 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 531 Out() << "T_back: backpanel temperatures" << endl; 532 Out() << "FTM top| bot|FSC top| bot|" << endl; 533 for (int i=31+8+8+4; i<31+8+8+4+4; i++){ 534 Out() << setw(7) << setprecision(1) << fixed << t[i] << "|"; 535 } 536 Out() << endl; 537 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 538 Out() << "T_ethernet: switch boxes" << endl; 539 Out() << "top front| back|bot front| back|" << endl; 540 for (int i=31+8+8+4; i<31+8+8+4+4; i++){ 541 Out() << setw(9) << setprecision(1) << fixed << t[i] << "|"; 542 } 543 Out() << endl; 544 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 545 } 546 547 void PrintVoltagesNicely(const vector<float> &v, const vector<float> &c) 548 { 549 /* 550 551 F:4;F:4;F:4;F:4;F:4;F:4;F:2;F:2;F:1;F:1", 552 553 "|FAD_Ud[V]:FAD digital (crate 0-3)" 554 "|FAD_Up[V]:FAD positive (crate 0-3)" 555 "|FAD_Un[V]:FAD negative (crate 0-3)" 556 "|FPA_Ud[V]:FPA digital (crate 0-3)" 557 "|FPA_Up[V]:FPA positive (crate 0-3)" 558 "|FPA_Un[V]:FPA negative (crate 0-3)" 559 560 "|ETH_U[V]:Ethernet switch (pos/neg)" 561 "|FTM_U[V]:FTM - trigger master (pos/neg)" 562 "|FFC_U[V]:FFC" 563 "|FLP_U[V]:FLP - light pulser"), 564 */ 565 const char* const voltage_names[] = { 566 "FAD_d | ", 567 "FAD_p | ", 568 "FAD_n | ", 569 "FPA_d | ", 570 "FPA_p | ", 571 "FPA_n | ", 572 "Etherne| ", 573 "FTM | ", 574 "FFC | ", 575 "FLP | ", 576 }; 577 const int length_per_group[] = { 578 4, 4, 4, 4, 4, 4, 2, 2, 1, 1, 579 }; 580 581 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 582 583 Out() << " | Voltages | Currents" << endl; 584 Out() << "-------| 0 | 1 | 2 | 3 | | 0 | 1 | 2 | 3 |" << endl; 585 586 int pos=0; 587 for (int i=0; i<10; i++) 588 { 589 Out() << voltage_names[i]; 590 for (int j=0; j<length_per_group[i]; j++) 591 { 592 Out() << setw(6) << setprecision(2) << fixed << v[pos++] << "| "; 593 } 594 pos -= length_per_group[i]; 595 for (int j=0; j<4-length_per_group[i]; j++) 596 { 597 Out() << " "; 598 } 599 Out() << "|"; 600 for (int j=0; j<length_per_group[i]; j++) 601 { 602 Out() << setw(6) << setprecision(2) << fixed << c[pos++] << "| "; 603 } 604 Out() << endl; 605 } 606 607 Out() << ". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . -." << endl; 608 609 610 } 611 612 bool CheckCurrentLimits(const vector<float> ¤ts) 613 { 614 /* 615 F:4;F:4;F:4;F:4;F:4;F:4;F:2;F:2;F:1;F:1", 616 "|FAD_Id[A]:FAD digital (crate 0-3)" 617 "|FAD_Ip[A]:FAD positive (crate 0-3)" 618 "|FAD_In[A]:FAD negative (crate 0-3)" 619 "|FPA_Id[A]:FPA digital (crate 0-3)" 620 "|FPA_Ip[A]:FPA positive (crate 0-3)" 621 "|FPA_In[A]:FPA negative (crate 0-3)" 622 "|ETH_I[A]:Ethernet switch (pos/neg)" 623 "|FTM_I[A]:FTM - trigger master (pos/neg)" 624 "|FFC_I[A]:FFC" 625 "|FLP_I[A]:FLP - light pulser") 626 */ 627 fSecurityLimitsExceeded = false; 628 629 const double current_limits[] = { 630 fSecurityCurrentLimits.FAD_digital, 631 fSecurityCurrentLimits.FAD_positive, 632 fSecurityCurrentLimits.FAD_negative, 633 fSecurityCurrentLimits.FPA_digital, 634 fSecurityCurrentLimits.FPA_positive, 635 fSecurityCurrentLimits.FPA_negative, 636 fSecurityCurrentLimits.ethernet_switch, 637 INFINITY, 638 fSecurityCurrentLimits.FFC, 639 fSecurityCurrentLimits.FLP, 640 }; 641 642 const int channels_per_group[] = { 643 4, 4, 4, 4, 4, 4, 2, 2, 1, 1, 644 }; 645 646 const int groups = 10; 647 648 const char* const group_names[] = { 649 "FAD_digital", 650 "FAD_positive", 651 "FAD_negative", 652 "FPA_digital", 653 "FPA_positive", 654 "FPA_negative", 655 "ethernet_switch", 656 "", 657 "FFC", 658 "FLP", 659 }; 660 661 const char* const channel_names[][4] = { 662 {"crate 0", "crate 1", "crate 2", "crate 3"}, 663 {"crate 0", "crate 1", "crate 2", "crate 3"}, 664 {"crate 0", "crate 1", "crate 2", "crate 3"}, 665 {"crate 0", "crate 1", "crate 2", "crate 3"}, 666 {"crate 0", "crate 1", "crate 2", "crate 3"}, 667 {"crate 0", "crate 1", "crate 2", "crate 3"}, 668 {"FTM side", "FSC side"}, 669 {""}, 670 {"-"}, 671 {"-"}, 672 }; 673 674 675 int offset=0; 676 for (int g=0; g<groups; g++){ 677 for (int c=0; c<channels_per_group[g]; c++) 678 { 679 int id = offset+c; 680 if (abs(currents[id]) > abs(current_limits[g])){ 681 Out() << "current limit exeeded!! "; 682 Out() << "group: "<< group_names[g]; 683 Out() << " channel: "<< channel_names[g][c]; 684 Out() << " value: "<< currents[id]; 685 Out() << " limit: "<< current_limits[g]; 686 Out() << endl; 687 fSecurityLimitsExceeded = true; 688 } 689 690 } 691 offset += channels_per_group[g]; 692 } 693 return fSecurityLimitsExceeded; 694 } 695 696 460 697 461 698 void StartRead() … … 569 806 } 570 807 808 void SetSecurityCurrentLimits(const FSC::SecurityCurrentLimits &lim) 809 { 810 fSecurityCurrentLimits = lim; 811 } 812 571 813 void SetPositionsBias(const vector<Interpolator2D::vec> &vec) 572 814 { 573 815 fPositionsBias = vec; 816 } 817 818 bool IsSecurityLimitExceeded() const 819 { 820 return fSecurityLimitsExceeded; 574 821 } 575 822 … … 788 1035 int Execute() 789 1036 { 790 return fFSC.IsOpen() ? State::kConnected : State::kDisconnected; 1037 if (fFSC.IsSecurityLimitExceeded()) 1038 { 1039 return State::kOverCurrent; 1040 } 1041 else if(fFSC.IsOpen()) 1042 { 1043 return State::kConnected; 1044 } 1045 else 1046 { 1047 return State::kDisconnected; 1048 } 1049 1050 //return fFSC.IsOpen() ? State::kConnected : State::kDisconnected; 791 1051 } 792 1052 … … 822 1082 T::AddStateName(State::kConnected, "Connected", 823 1083 "Ethernet connection to FSC established."); 1084 1085 T::AddStateName(State::kHighCurrent, "HighPowerConsumption", 1086 "FSC board measures high power consumption, c.f. FSC current limits in config-file or config-DB."); 1087 1088 T::AddStateName(State::kOverCurrent, "OverCurrent", 1089 "FSC board measures *too* power consumption, c.f. FSC current limits in config-file or config-DB."); 824 1090 825 1091 // Verbosity commands … … 869 1135 fFSC.SetPositionsSensors(v1); 870 1136 fFSC.SetPositionsBias(v2); 1137 1138 FSC::SecurityCurrentLimits lim; 1139 lim.ethernet_switch = conf.Get<double>("ethernet_switch"); 1140 lim.FFC = conf.Get<double>("FFC"); 1141 lim.FLP = conf.Get<double>("FLP"); 1142 lim.FAD_digital = conf.Get<double>("FAD_digital"); 1143 lim.FAD_negative = conf.Get<double>("FAD_negative"); 1144 lim.FAD_positive = conf.Get<double>("FAD_positive"); 1145 lim.FPA_digital = conf.Get<double>("FPA_digital"); 1146 lim.FPA_negative = conf.Get<double>("FPA_negative"); 1147 lim.FPA_positive = conf.Get<double>("FPA_positive"); 1148 fFSC.SetSecurityCurrentLimits(lim); 871 1149 872 1150 SetEndpoint(conf.Get<string>("addr")); … … 896 1174 ("quiet,q", po_bool(true), "Disable printing contents of all received messages (except dynamic data) in clear text.") 897 1175 ; 1176 1177 po::options_description current_limits("Security current limits"); 1178 current_limits.add_options() 1179 ("ethernet_switch", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1180 ("FFC", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1181 ("FLP", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1182 ("FAD_digital", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1183 ("FAD_negative", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1184 ("FAD_positive", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1185 ("FPA_digital", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1186 ("FPA_negative", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1187 ("FPA_positive", var<double>()->required(), "(signed) floating point number, the max/min current, for pos/neg currents in A.") 1188 ; 898 1189 899 1190 conf.AddOptions(control); 1191 conf.AddOptions(current_limits); 900 1192 } 901 1193
Note:
See TracChangeset
for help on using the changeset viewer.