Changeset 13838 for trunk/FACT++/src/smartfact.cc
- Timestamp:
- 05/23/12 17:06:08 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/smartfact.cc
r13820 r13838 17 17 18 18 #include "tools.h" 19 #include "DimData.h"20 19 21 20 #include "LocalControl.h" … … 30 29 31 30 #include "DimDescriptionService.h" 31 #include "DimState.h" 32 32 33 33 // ------------------------------------------------------------------------ … … 305 305 // ======================================================================== 306 306 307 class DimState : public DimInfoHandler 308 { 309 protected: 310 typedef function<void(const DimData &)> callback; 311 312 public: 313 DimState(const string &n, const string s="STATE") : server(n), 314 info(make_pair(Time(), -4)), 315 dim((n+"/"+s).c_str(), (void*)NULL, 0, this) { } 316 317 string server; 318 pair<Time, int> info; 319 string msg; 320 321 DimStampedInfo dim; 322 323 callback fCallback; 324 325 void SetCallback(const callback &cb) 326 { 327 fCallback = cb; 328 } 329 330 void infoHandler() 331 { 332 DimInfo *curr = getInfo(); // get current DimInfo address 333 if (!curr || curr != &dim) 334 return; 335 336 const bool disconnected = dim.getSize()==0; 337 338 // Make sure getTimestamp is called _before_ getTimestampMillisecs 339 const int tsec = dim.getTimestamp(); 340 const int tms = dim.getTimestampMillisecs(); 341 342 info = make_pair(Time(tsec, tms*1000), 343 disconnected ? -4 : dim.getQuality()); 344 345 msg = disconnected ? "" : dim.getString(); 346 347 if (fCallback) 348 fCallback(DimData(curr)); 349 } 350 351 const Time &time() const { return info.first; } 352 const int &state() const { return info.second; } 353 354 bool online() const { return info.second>-4; } 355 356 const string &name() const { return server; } 357 }; 358 359 class DimVersion : public DimState 360 { 361 public: 362 DimVersion() : DimState("DIS_DNS", "VERSION_NUMBER") { } 363 364 void infoHandler() 365 { 366 DimInfo *curr = getInfo(); // get current DimInfo address 367 if (!curr || curr != &dim) 368 return; 369 370 DimState::infoHandler(); 371 372 info.second = dim.getSize()==4 ? dim.getInt() : 0; 373 } 374 375 string version() const 376 { 377 if (info.second==0) 378 return "Offline"; 379 380 ostringstream out; 381 out << "V" << info.second/100 << 'r' << info.second%100; 382 return out.str(); 383 } 384 }; 385 386 class DimControl : public DimState 387 { 388 map<string, callback> fCallbacks; 389 public: 390 DimControl() : DimState("DIM_CONTROL") { } 391 392 void AddCallback(const string &script, const callback &cb) 393 { 394 fCallbacks[script] = cb; 395 } 396 397 void infoHandler() 398 { 399 DimInfo *curr = getInfo(); // get current DimInfo address 400 if (!curr || curr != &dim) 401 return; 402 403 DimState::infoHandler(); 404 405 // Evaluate msg 406 const size_t p0 = msg.find_first_of(':'); 407 if (p0==string::npos) 408 return; 409 410 const size_t p1 = msg.find_last_of('['); 411 if (p1==string::npos) 412 return; 413 414 const size_t p2 = msg.find_first_of(':', p0+1); 415 416 const size_t p3 = p2==string::npos || p2>p1 ? p1-1 : p2; 417 418 const string file = msg.substr(p0+2, p3-p0-2); 419 420 const auto func = fCallbacks.find(file); 421 if (func==fCallbacks.end()) 422 return; 423 424 // Call callback 425 func->second(DimData(curr)); 426 } 427 }; 428 429 struct DimSubscriptions 430 { 431 DimServiceInfoList fNetwork; 432 433 DimVersion fDNS; 434 DimControl fControl; 435 DimState fMcp; 436 DimState fDataLogger; 437 DimState fDriveControl; 438 DimState fMagicWeather; 439 DimState fFeedback; 440 DimState fBiasControl; 441 DimState fFtmControl; 442 DimState fFadControl; 443 DimState fFscControl; 444 DimState fRateControl; 445 DimState fRateScan; 446 DimState fChatServer; 447 448 DimStampedInfo fControlMessage; 449 450 DimStampedInfo fMcpConfiguration; 451 452 DimStampedInfo fDriveControlPointing; 453 DimStampedInfo fDriveControlTracking; 454 DimStampedInfo fDriveControlSource; 455 456 DimStampedInfo fFscControlTemperature; 457 DimStampedInfo fFscControlHumidity; 458 459 DimStampedInfo fMagicWeatherData; 460 461 DimStampedInfo fFeedbackDeviation; 462 DimStampedInfo fFeedbackCalibration; 463 464 DimStampedInfo fBiasControlVoltage; 465 DimStampedInfo fBiasControlCurrent; 466 467 DimStampedInfo fFadConnections; 468 DimStampedInfo fFadEvents; 469 470 DimStampedInfo fFtmControlTriggerRates; 471 DimStampedInfo fFtmControlStaticData; 472 DimStampedInfo fFtmControlFtuList; 473 474 DimStampedInfo fRateScanData; 475 476 DimStampedInfo fFadControlEventData; 477 478 DimSubscriptions(DimInfoHandler *h) : 479 fMcp ("MCP"), 480 fDataLogger ("DATA_LOGGER"), 481 fDriveControl ("DRIVE_CONTROL"), 482 fMagicWeather ("MAGIC_WEATHER"), 483 fFeedback ("FEEDBACK"), 484 fBiasControl ("BIAS_CONTROL"), 485 fFtmControl ("FTM_CONTROL"), 486 fFadControl ("FAD_CONTROL"), 487 fFscControl ("FSC_CONTROL"), 488 fRateControl ("RATE_CONTROL"), 489 fRateScan ("RATE_SCAN"), 490 fChatServer ("CHAT_SERVER"), 491 //--- 492 fControlMessage ("DIM_CONTROL/MESSAGE", (void*)NULL, 0, h), 493 //--- 494 fMcpConfiguration ("MCP/CONFIGURATION", (void*)NULL, 0, h), 495 //--- 496 fDriveControlPointing ("DRIVE_CONTROL/POINTING_POSITION", (void*)NULL, 0, h), 497 fDriveControlTracking ("DRIVE_CONTROL/TRACKING_POSITION", (void*)NULL, 0, h), 498 fDriveControlSource ("DRIVE_CONTROL/SOURCE_POSITION", (void*)NULL, 0, h), 499 //--- 500 fFscControlTemperature ("FSC_CONTROL/TEMPERATURE", (void*)NULL, 0, h), 501 fFscControlHumidity ("FSC_CONTROL/HUMIDITY", (void*)NULL, 0, h), 502 //--- 503 fMagicWeatherData ("MAGIC_WEATHER/DATA", (void*)NULL, 0, h), 504 //--- 505 fFeedbackDeviation ("FEEDBACK/DEVIATION", (void*)NULL, 0, h), 506 fFeedbackCalibration ("FEEDBACK/CALIBRATION", (void*)NULL, 0, h), 507 //--- 508 fBiasControlVoltage ("BIAS_CONTROL/VOLTAGE", (void*)NULL, 0, h), 509 fBiasControlCurrent ("BIAS_CONTROL/CURRENT", (void*)NULL, 0, h), 510 //--- 511 fFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, h), 512 fFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, h), 513 //--- 514 fFtmControlTriggerRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, h), 515 fFtmControlStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, h), 516 fFtmControlFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, h), 517 //--- 518 fRateScanData ("RATE_SCAN/DATA", (void*)NULL, 0, h), 519 //--- 520 fFadControlEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, h) 521 522 { 523 } 524 525 const State GetState(const DimState &s) const 526 { 527 return fNetwork.GetState(s.name(), s.state()); 528 } 529 }; 530 531 // ======================================================================== 532 // ======================================================================== 533 // ======================================================================== 534 535 536 class StateMachineSmartFACT : public StateMachineDim, public DimInfoHandler 307 class StateMachineSmartFACT : public StateMachineDim//, public DimInfoHandler 537 308 { 538 309 private: … … 601 372 // ------------- Initialize variables before the Dim stuff ------------ 602 373 603 DimSubscriptions *fDim; 374 DimServiceInfoListImp fNetwork; 375 376 DimVersion fDimDNS; 377 DimControl fDimControl; 378 DimState fDimMcp; 379 DimState fDimDataLogger; 380 DimState fDimDriveControl; 381 DimState fDimMagicWeather; 382 DimState fDimFeedback; 383 DimState fDimBiasControl; 384 DimState fDimFtmControl; 385 DimState fDimFadControl; 386 DimState fDimFscControl; 387 DimState fDimRateControl; 388 DimState fDimRateScan; 389 DimState fDimChatServer; 604 390 605 391 // ------------------------------------------------------------------- 606 607 608 // ------------------------------------------------------------------- 609 392 /* 610 393 bool HandleService(DimInfo *curr, const DimInfo &service, void (StateMachineSmartFACT::*handle)(const DimData &)) 611 394 { … … 616 399 return true; 617 400 } 618 619 620 bool CheckDataSize(const DimData&d, const char *name, size_t size, bool min=false)621 { 622 if ((!min && d. data.size()==size) || (min && d.data.size()>size))401 */ 402 403 bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false) 404 { 405 if ((!min && d.GetSize()==size) || (min && d.GetSize()>size)) 623 406 return true; 624 407 625 408 ostringstream msg; 626 msg << name << " - Received service has " << d. data.size() << " bytes, but expected ";409 msg << name << " - Received service has " << d.GetSize() << " bytes, but expected "; 627 410 if (min) 628 411 msg << "more than "; … … 636 419 637 420 template<class T> 638 void WriteBinary(const DimData&d, const string &fname, const T &t, double scale, double offset=0)421 void WriteBinary(const EventImp &d, const string &fname, const T &t, double scale, double offset=0) 639 422 { 640 423 vector<uint8_t> val(t.size(), 0); … … 652 435 653 436 ostringstream out; 654 out << d. time.JavaDate() << '\n';437 out << d.GetJavaDate() << '\n'; 655 438 out << offset << '\n'; 656 439 out << offset+scale << '\n'; … … 695 478 }; 696 479 697 void HandleControlMessageImp(const DimData&d)698 { 699 if (d. size()==0)480 void HandleControlMessageImp(const EventImp &d) 481 { 482 if (d.GetSize()==0) 700 483 return; 701 484 702 485 const string str = fControlMessageHist.size()>0 ? fControlMessageHist.back() : "<pre> : : </pre> "; 703 const string time = "<pre>"+d. time.GetAsStr("%H:%M:%S")+"</pre> ";486 const string time = "<pre>"+d.GetTimeAsStr("%H:%M:%S")+"</pre> "; 704 487 705 488 ostringstream tst; 706 tst << d. qos;489 tst << d.GetQoS(); 707 490 708 491 string msg; 709 492 msg += str.substr(0, time.length())==time ? "<pre> </pre> " : time; 710 msg += d. ptr<char>();493 msg += d.Ptr<char>(); 711 494 712 495 fControlMessageHist.push_back(msg); … … 714 497 ostringstream out; 715 498 out << setprecision(3); 716 out << d. time.JavaDate() << '\n';499 out << d.GetJavaDate() << '\n'; 717 500 out << "#ffffff\t"; 718 501 … … 725 508 } 726 509 727 void HandleControlMessage(const DimData&d)728 { 729 if (d. qos==90)510 int HandleDimControlMessage(const EventImp &d) 511 { 512 if (d.GetQoS()==90) 730 513 HandleControlMessageImp(d); 731 } 732 733 void HandleControlStateChange(const DimData &d) 734 { 735 if (d.qos==-2) 514 515 return GetCurrentState(); 516 } 517 518 void HandleControlStateChange(const EventImp &d) 519 { 520 if (d.GetQoS()==-2) 736 521 fControlMessageHist.clear(); 737 522 738 if (d. qos<0)523 if (d.GetQoS()<0) 739 524 HandleControlMessageImp(d); 740 525 } 741 526 742 void HandleMcpConfiguration(const DimData&d)527 int HandleMcpConfiguration(const EventImp &d) 743 528 { 744 529 if (!CheckDataSize(d, "Mcp:Configuration", 16, true)) 745 return ;746 747 fMcpConfigurationState = d. qos;748 fMcpConfigurationMaxTime = d. get<uint64_t>();749 fMcpConfigurationMaxEvents = d. get<uint64_t>(8);750 fMcpConfigurationName = d. ptr<char>(16);751 752 if (d. qos==12)530 return GetCurrentState(); 531 532 fMcpConfigurationState = d.GetQoS(); 533 fMcpConfigurationMaxTime = d.Get<uint64_t>(); 534 fMcpConfigurationMaxEvents = d.Get<uint64_t>(8); 535 fMcpConfigurationName = d.Ptr<char>(16); 536 537 if (d.GetQoS()==12) 753 538 fMcpConfigurationRunStart = Time(); 754 } 755 756 void WriteWeather(const DimData &d, const string &name, int i, float min, float max) 539 540 return GetCurrentState(); 541 } 542 543 void WriteWeather(const EventImp &d, const string &name, int i, float min, float max) 757 544 { 758 545 const Statistics stat(fMagicWeatherHist[i]); … … 760 547 ostringstream out; 761 548 out << setprecision(3); 762 out << d. time.JavaDate() << '\n';549 out << d.GetJavaDate() << '\n'; 763 550 764 551 out << "#ffffff\t" << fMagicWeatherHist[i].back() << '\n'; … … 772 559 } 773 560 774 void HandleMagicWeatherData(const DimData&d)561 int HandleMagicWeatherData(const EventImp &d) 775 562 { 776 563 if (!CheckDataSize(d, "MagicWeather:Data", 7*4+2)) 777 return ;564 return GetCurrentState(); 778 565 779 566 // Store a history of the last 300 entries 780 567 for (int i=kWeatherBegin; i<kWeatherEnd; i++) 781 568 { 782 fMagicWeatherHist[i].push_back(d. ptr<float>(2)[i]);569 fMagicWeatherHist[i].push_back(d.Ptr<float>(2)[i]); 783 570 if (fMagicWeatherHist[i].size()>300) 784 571 fMagicWeatherHist[i].pop_front(); … … 801 588 802 589 ostringstream out; 803 out << d. time.JavaDate() << '\n';590 out << d.GetJavaDate() << '\n'; 804 591 out << astro.color << '\t' << astro.description << '\n'; 805 592 out << setprecision(2); … … 836 623 WriteWeather(d, "gusts", kGusts, 0, 100); 837 624 WriteWeather(d, "press", kPress, 700, 1000); 838 } 839 840 void HandleDriveControlPointing(const DimData &d) 625 626 return GetCurrentState(); 627 } 628 629 int HandleDrivePointing(const EventImp &d) 841 630 { 842 631 if (!CheckDataSize(d, "DriveControl:Pointing", 16)) 843 return ;844 845 fDriveControlPointingZd = d. get<double>();846 847 const double az = d. get<double>(8);632 return GetCurrentState(); 633 634 fDriveControlPointingZd = d.Get<double>(); 635 636 const double az = d.Get<double>(8); 848 637 849 638 static const char *dir[] = … … 859 648 860 649 ostringstream out; 861 out << d. time.JavaDate() << '\n';650 out << d.GetJavaDate() << '\n'; 862 651 863 652 out << setprecision(5); … … 866 655 867 656 ofstream(fPath+"/drive-pointing.txt") << out.str(); 868 } 869 870 void HandleDriveControlTracking(const DimData &d) 657 658 return GetCurrentState(); 659 } 660 661 int HandleDriveTracking(const EventImp &d) 871 662 { 872 663 if (!CheckDataSize(d, "DriveControl:Tracking", 56)) 873 return ;874 875 const double Ra = d. get<double>(0*8);876 const double Dec = d. get<double>(1*8);877 const double Zd = d. get<double>(3*8);878 const double Az = d. get<double>(4*8);664 return GetCurrentState(); 665 666 const double Ra = d.Get<double>(0*8); 667 const double Dec = d.Get<double>(1*8); 668 const double Zd = d.Get<double>(3*8); 669 const double Az = d.Get<double>(4*8); 879 670 880 671 const double zd = Zd * M_PI / 180; 881 const double dzd = d. get<double>(5*8) * M_PI / 180;882 const double daz = d. get<double>(6*8) * M_PI / 180;672 const double dzd = d.Get<double>(5*8) * M_PI / 180; 673 const double daz = d.Get<double>(6*8) * M_PI / 180; 883 674 884 675 // Correct: … … 896 687 897 688 ostringstream out; 898 out << d. time.JavaDate() << '\n';689 out << d.GetJavaDate() << '\n'; 899 690 900 691 out << kHtmlWhite << '\t' << fDriveControlSourceName << '\n'; … … 923 714 924 715 ofstream(fPath+"/tracking.txt") << out.str(); 925 } 926 927 void HandleDriveControlSource(const DimData &d) 716 717 return GetCurrentState(); 718 } 719 720 int HandleDriveSource(const EventImp &d) 928 721 { 929 722 if (!CheckDataSize(d, "DriveControl:Source", 7*4+2, true)) 930 return ;931 932 const double *ptr = d. ptr<double>();723 return GetCurrentState(); 724 725 const double *ptr = d.Ptr<double>(); 933 726 934 727 const double ra = ptr[0]; // Ra[h] … … 937 730 const double wang = ptr[5]; // Wobble angle [deg] 938 731 939 fDriveControlSourceName = d. ptr<char>(6*8);732 fDriveControlSourceName = d.Ptr<char>(6*8); 940 733 941 734 ostringstream out; 942 out << d. time.JavaDate() << '\n';735 out << d.GetJavaDate() << '\n'; 943 736 944 737 out << "#ffffff\t" << fDriveControlSourceName << '\n'; … … 951 744 952 745 ofstream(fPath+"/source.txt") << out.str(); 953 } 954 955 void HandleFeedbackCalibration(const DimData &d) 746 747 return GetCurrentState(); 748 } 749 750 int HandleFeedbackCalibration(const EventImp &d) 956 751 { 957 752 if (!CheckDataSize(d, "Feedback:Calibration", 3*4*416)) 958 753 { 959 754 fFeedbackCalibration.clear(); 960 return ;961 } 962 963 const float *ptr = d. ptr<float>();755 return GetCurrentState(); 756 } 757 758 const float *ptr = d.Ptr<float>(); 964 759 fFeedbackCalibration.assign(ptr+2*416, ptr+3*416); 965 } 966 967 void HandleFeedbackDeviation(const DimData &d) 760 761 return GetCurrentState(); 762 } 763 764 int HandleFeedbackDeviation(const EventImp &d) 968 765 { 969 766 if (!CheckDataSize(d, "Feedback:Deviation", 2*4*416+8)) 970 return ;971 972 const float *ptr = d. ptr<float>();767 return GetCurrentState(); 768 769 const float *ptr = d.Ptr<float>(); 973 770 vector<float> dev(ptr+416, ptr+416+320); 974 771 … … 985 782 986 783 ostringstream out; 987 out << d. time.JavaDate() << '\n';784 out << d.GetJavaDate() << '\n'; 988 785 out << kHtmlWhite << '\t' << fFeedbackUserOffset << '\n'; 989 786 out << setprecision(3); … … 994 791 out << kHtmlWhite << '\t' << stat.max << '\n'; 995 792 ofstream(fPath+"/feedback.txt") << out.str(); 996 } 997 998 void HandleBiasControlVoltage(const DimData &d) 793 794 return GetCurrentState(); 795 } 796 797 int HandleBiasVoltage(const EventImp &d) 999 798 { 1000 799 if (!CheckDataSize(d, "BiasControl:Voltage", 1664)) 1001 800 { 1002 801 fBiasControlVoltageVec.clear(); 1003 return ;1004 } 1005 1006 fBiasControlVoltageVec.assign(d. ptr<float>(), d.ptr<float>()+320);802 return GetCurrentState(); 803 } 804 805 fBiasControlVoltageVec.assign(d.Ptr<float>(), d.Ptr<float>()+320); 1007 806 1008 807 const Statistics stat(fBiasControlVoltageVec); … … 1017 816 } 1018 817 1019 if (fDim ->fBiasControl.state()==BIAS::kVoltageOn)818 if (fDimBiasControl.state()==BIAS::kVoltageOn) 1020 819 WriteBinary(d, "biascontrol-voltage", val, 10, 65); 1021 820 else … … 1024 823 ostringstream out; 1025 824 out << setprecision(3); 1026 out << d. time.JavaDate() << '\n';825 out << d.GetJavaDate() << '\n'; 1027 826 out << kHtmlWhite << '\t' << stat.min << '\n'; 1028 827 out << kHtmlWhite << '\t' << stat.med << '\n'; … … 1031 830 ofstream(fPath+"/voltage.txt") << out.str(); 1032 831 1033 } 1034 1035 void HandleBiasControlCurrent(const DimData &d) 832 return GetCurrentState(); 833 } 834 835 int HandleBiasCurrent(const EventImp &d) 1036 836 { 1037 837 if (!CheckDataSize(d, "BiasControl:Current", 832)) 1038 return ;838 return GetCurrentState(); 1039 839 1040 840 // Convert dac counts to uA 1041 841 vector<float> v(320); 1042 842 for (int i=0; i<320; i++) 1043 v[i] = d. ptr<uint16_t>()[i] * 5000./4096;843 v[i] = d.Ptr<uint16_t>()[i] * 5000./4096; 1044 844 1045 845 const bool cal = fFeedbackCalibration.size()>0 && fBiasControlVoltageVec.size()>0; … … 1136 936 ostringstream out; 1137 937 out << setprecision(2); 1138 out << d. time.JavaDate() << '\n';938 out << d.GetJavaDate() << '\n'; 1139 939 out << col0 << '\t' << (cal?"yes":"no") << '\n'; 1140 940 out << col1 << '\t' << stat.min << '\n'; … … 1144 944 out << kHtmlWhite << '\t' << power_tot << "W [" << power_apd << "mW]\n"; 1145 945 ofstream(fPath+"/current.txt") << out.str(); 1146 } 1147 1148 void HandleFadEvents(const DimData &d) 946 947 return GetCurrentState(); 948 } 949 950 int HandleFadEvents(const EventImp &d) 1149 951 { 1150 952 if (!CheckDataSize(d, "FadControl:Events", 4*4)) 1151 953 { 1152 954 fFadControlNumEvents = -1; 1153 return; 1154 } 1155 1156 fFadControlNumEvents = d.get<uint32_t>(); 1157 } 1158 1159 void HandleFadConnections(const DimData &d) 955 return GetCurrentState(); 956 } 957 958 fFadControlNumEvents = d.Get<uint32_t>(); 959 960 return GetCurrentState(); 961 } 962 963 int HandleFadConnections(const EventImp &d) 1160 964 { 1161 965 if (!CheckDataSize(d, "FadControl:Connections", 41)) 1162 966 { 1163 967 //fStatusEventBuilderLabel->setText("Offline"); 1164 return ;968 return GetCurrentState(); 1165 969 } 1166 970 1167 971 string rc(40, '-'); // orange/red [45] 1168 972 1169 const uint8_t *ptr = d. ptr<uint8_t>();973 const uint8_t *ptr = d.Ptr<uint8_t>(); 1170 974 1171 975 int c[4] = { '.', '.', '.', '.' }; … … 1198 1002 ostringstream out; 1199 1003 out << setprecision(3); 1200 out << d. time.JavaDate() << '\n';1004 out << d.GetJavaDate() << '\n'; 1201 1005 out << col[0] << '\t' << rc.substr( 0, 10) << '\n'; 1202 1006 out << col[1] << '\t' << rc.substr(10, 10) << '\n'; … … 1204 1008 out << col[3] << '\t' << rc.substr(30, 10) << '\n'; 1205 1009 ofstream(fPath+"/fad.txt") << out.str(); 1206 } 1207 1208 void HandleFtmControlTriggerRates(const DimData &d) 1010 1011 return GetCurrentState(); 1012 } 1013 1014 int HandleFtmTriggerRates(const EventImp &d) 1209 1015 { 1210 1016 if (!CheckDataSize(d, "FtmControl:TriggerRates", 24+160+640+8)) 1211 return ;1017 return GetCurrentState(); 1212 1018 1213 1019 // New run started 1214 if (d. get<float>(20)<0)1215 return ;1216 1217 fFtmControlTriggerRateCam = d. get<float>(20);1218 1219 const float *brates = d. ptr<float>(24); // Board rate1220 const float *prates = d. ptr<float>(24+160); // Patch rate1020 if (d.Get<float>(20)<0) 1021 return GetCurrentState(); 1022 1023 fFtmControlTriggerRateCam = d.Get<float>(20); 1024 1025 const float *brates = d.Ptr<float>(24); // Board rate 1026 const float *prates = d.Ptr<float>(24+160); // Patch rate 1221 1027 1222 1028 // Store a history of the last 60 entries … … 1236 1042 ostringstream out; 1237 1043 out << setprecision(3); 1238 out << d. time.JavaDate() << '\n';1044 out << d.GetJavaDate() << '\n'; 1239 1045 out << "#ffffff\t" << fFtmControlTriggerRateCam << '\n'; 1240 1046 … … 1245 1051 1246 1052 out.str(""); 1247 out << d. time.JavaDate() << '\n';1053 out << d.GetJavaDate() << '\n'; 1248 1054 out << kHtmlWhite << '\t' << bstat.min << '\n'; 1249 1055 out << kHtmlWhite << '\t' << bstat.med << '\n'; … … 1253 1059 1254 1060 out.str(""); 1255 out << d. time.JavaDate() << '\n';1061 out << d.GetJavaDate() << '\n'; 1256 1062 out << kHtmlWhite << '\t' << pstat.min << '\n'; 1257 1063 out << kHtmlWhite << '\t' << pstat.med << '\n'; … … 1259 1065 out << kHtmlWhite << '\t' << pstat.max << '\n'; 1260 1066 ofstream(fPath+"/patchrates.txt") << out.str(); 1261 } 1262 1263 void HandleFtmControlStaticData(const DimData &d) 1067 1068 return GetCurrentState(); 1069 } 1070 1071 int HandleFtmStaticData(const EventImp &d) 1264 1072 { 1265 1073 if (!CheckDataSize(d, "FtmControl:StaticData", 740)) 1266 return ;1267 1268 const uint16_t *ptr = d. ptr<uint16_t>(260);1074 return GetCurrentState(); 1075 1076 const uint16_t *ptr = d.Ptr<uint16_t>(260); 1269 1077 vector<uint16_t> vec(ptr, ptr+160); 1270 1078 … … 1274 1082 1275 1083 ostringstream out; 1276 out << d. time.JavaDate() << '\n';1084 out << d.GetJavaDate() << '\n'; 1277 1085 out << kHtmlWhite << '\t' << stat.min << '\n'; 1278 1086 out << kHtmlWhite << '\t' << stat.med << '\n'; … … 1280 1088 out << kHtmlWhite << '\t' << stat.max << '\n'; 1281 1089 ofstream(fPath+"/thresholds.txt") << out.str(); 1282 } 1283 1284 void HandleFtmControlFtuList(const DimData &d) 1090 1091 return GetCurrentState(); 1092 } 1093 1094 int HandleFtmFtuList(const EventImp &d) 1285 1095 { 1286 1096 if (!CheckDataSize(d, "FtmControl:FtuList", sizeof(FTM::DimFtuList))) 1287 return ;1288 1289 const FTM::DimFtuList &sdata = d. ref<FTM::DimFtuList>();1097 return GetCurrentState(); 1098 1099 const FTM::DimFtuList &sdata = d.Ref<FTM::DimFtuList>(); 1290 1100 1291 1101 ostringstream out; 1292 out << d. time.JavaDate() << '\n';1102 out << d.GetJavaDate() << '\n'; 1293 1103 1294 1104 int cnt = 0; … … 1315 1125 1316 1126 ofstream(fPath+"/ftu.txt") << out.str(); 1317 } 1318 1319 void HandleFadControlEventData(const DimData &d) 1127 1128 return GetCurrentState(); 1129 } 1130 1131 int HandleFadEventData(const EventImp &d) 1320 1132 { 1321 1133 if (!CheckDataSize(d, "FadControl:EventData", 23040)) 1322 return ;1323 1324 //const float *avg = d. ptr<float>();1325 //const float *rms = d. ptr<float>(1440*sizeof(float));1326 const float *dat = d. ptr<float>(1440*sizeof(float)*2);1327 //const float *pos = d. ptr<float>(1440*sizeof(float)*3);1134 return GetCurrentState(); 1135 1136 //const float *avg = d.Ptr<float>(); 1137 //const float *rms = d.Ptr<float>(1440*sizeof(float)); 1138 const float *dat = d.Ptr<float>(1440*sizeof(float)*2); 1139 //const float *pos = d.Ptr<float>(1440*sizeof(float)*3); 1328 1140 1329 1141 vector<float> max(320, -2); … … 1339 1151 } 1340 1152 1341 switch (d. qos)1153 switch (d.GetQoS()) 1342 1154 { 1343 1155 case 0: WriteBinary(d, "fadcontrol-eventdata", max, 2, -1); break; … … 1345 1157 default: WriteBinary(d, "fadcontrol-eventdata", max, 0.25, 0); break; 1346 1158 } 1347 } 1348 1349 void HandleFscControlTemperature(const DimData &d) 1159 1160 return GetCurrentState(); 1161 } 1162 1163 int HandleFscTemperature(const EventImp &d) 1350 1164 { 1351 1165 if (!CheckDataSize(d, "FscControl:Temperature", 240)) 1352 return ;1353 1354 const float *ptr = d. ptr<float>(4);1166 return GetCurrentState(); 1167 1168 const float *ptr = d.Ptr<float>(4); 1355 1169 1356 1170 double avg = 0; … … 1391 1205 ostringstream out; 1392 1206 out << setprecision(3); 1393 out << d. time.JavaDate() << '\n';1207 out << d.GetJavaDate() << '\n'; 1394 1208 out << "#ffffff\t" << fFscControlHumidityAvg << '\n'; 1395 1209 out << "#ffffff\t" << min << '\n'; … … 1404 1218 WriteBinary(d, "fsccontrol-temperature-hist", 1405 1219 fFscControlTemperatureHist, 10); 1406 } 1407 1408 void HandleFscControlHumidity(const DimData &d) 1220 1221 return GetCurrentState(); 1222 } 1223 1224 int HandleFscHumidity(const EventImp &d) 1409 1225 { 1410 1226 if (!CheckDataSize(d, "FscControl:Humidity", 5*4)) 1411 return ;1412 1413 const float *ptr = d. ptr<float>(4);1227 return GetCurrentState(); 1228 1229 const float *ptr = d.Ptr<float>(4); 1414 1230 1415 1231 double avg = 0; … … 1424 1240 1425 1241 fFscControlHumidityAvg = avg/num; 1426 } 1427 1428 void HandleRateScanData(const DimData &d) 1242 1243 return GetCurrentState(); 1244 } 1245 1246 int HandleRateScanData(const EventImp &d) 1429 1247 { 1430 1248 if (!CheckDataSize(d, "RateScan:Data", 824)) 1431 return ;1432 1433 const uint64_t id = d. get<uint64_t>();1434 const float *rate = d. ptr<float>(20);1249 return GetCurrentState(); 1250 1251 const uint64_t id = d.Get<uint64_t>(); 1252 const float *rate = d.Ptr<float>(20); 1435 1253 1436 1254 if (fRateScanDataId!=id) … … 1458 1276 ostringstream out; 1459 1277 out << setprecision(3); 1460 out << d. time.JavaDate() << '\n';1278 out << d.GetJavaDate() << '\n'; 1461 1279 out << "#ffffff\t" << pow(10, fRateScanDataHist[0].back()) << '\n'; 1462 1280 out << "#ffffff\t" << max << '\n'; … … 1465 1283 1466 1284 out.str(""); 1467 out << d. time.JavaDate() << '\n';1285 out << d.GetJavaDate() << '\n'; 1468 1286 out << "#ffffff\t" << int(fRateScanBoard) << '\n'; 1469 1287 out << "#ffffff\t" << pow(10, fRateScanDataHist[fRateScanBoard+1].back()) << '\n'; 1470 1288 1471 1289 ofstream(fPath+"/ratecan_board.txt") << out.str(); 1290 1291 return GetCurrentState(); 1472 1292 } 1473 1293 1474 1294 // ------------------------------------------------------------------- 1475 1295 1476 void HandleDoTest(const DimData&d)1296 void HandleDoTest(const EventImp &d) 1477 1297 { 1478 1298 ostringstream out; 1479 out << d. time.JavaDate() << '\t' << fDim->fControl.online() << '\n';1480 switch (d. qos)1299 out << d.GetJavaDate() << '\t' << fDimControl.online() << '\n'; 1300 switch (d.GetQoS()) 1481 1301 { 1482 1302 case -3: out << kHtmlWhite << "\tNot running\n"; break; 1483 1303 case -2: out << kHtmlBlue << "\tLoading\n"; break; 1484 1304 case -1: out << kHtmlBlue << "\tStarted\n"; break; 1485 default: out << kHtmlGreen << "\tRunning [" << d. qos<< "]\n"; break;1305 default: out << kHtmlGreen << "\tRunning [" << d.GetQoS() << "]\n"; break; 1486 1306 } 1487 1307 … … 1490 1310 1491 1311 // ------------------------------------------------------------------- 1492 1493 void infoHandler()1494 {1495 DimInfo *curr = getInfo(); // get current DimInfo address1496 if (!curr)1497 return;1498 1499 if (HandleService(curr, fDim->fMcpConfiguration, &StateMachineSmartFACT::HandleMcpConfiguration))1500 return;1501 if (HandleService(curr, fDim->fMagicWeatherData, &StateMachineSmartFACT::HandleMagicWeatherData))1502 return;1503 if (HandleService(curr, fDim->fDriveControlPointing, &StateMachineSmartFACT::HandleDriveControlPointing))1504 return;1505 if (HandleService(curr, fDim->fDriveControlTracking, &StateMachineSmartFACT::HandleDriveControlTracking))1506 return;1507 if (HandleService(curr, fDim->fDriveControlSource, &StateMachineSmartFACT::HandleDriveControlSource))1508 return;1509 if (HandleService(curr, fDim->fFeedbackDeviation, &StateMachineSmartFACT::HandleFeedbackDeviation))1510 return;1511 if (HandleService(curr, fDim->fFeedbackCalibration, &StateMachineSmartFACT::HandleFeedbackCalibration))1512 return;1513 if (HandleService(curr, fDim->fBiasControlVoltage, &StateMachineSmartFACT::HandleBiasControlVoltage))1514 return;1515 if (HandleService(curr, fDim->fBiasControlCurrent, &StateMachineSmartFACT::HandleBiasControlCurrent))1516 return;1517 if (HandleService(curr, fDim->fFadConnections, &StateMachineSmartFACT::HandleFadConnections))1518 return;1519 if (HandleService(curr, fDim->fFadEvents, &StateMachineSmartFACT::HandleFadEvents))1520 return;1521 if (HandleService(curr, fDim->fFtmControlTriggerRates, &StateMachineSmartFACT::HandleFtmControlTriggerRates))1522 return;1523 if (HandleService(curr, fDim->fFtmControlStaticData, &StateMachineSmartFACT::HandleFtmControlStaticData))1524 return;1525 if (HandleService(curr, fDim->fFtmControlFtuList, &StateMachineSmartFACT::HandleFtmControlFtuList))1526 return;1527 if (HandleService(curr, fDim->fFadControlEventData, &StateMachineSmartFACT::HandleFadControlEventData))1528 return;1529 if (HandleService(curr, fDim->fFscControlTemperature, &StateMachineSmartFACT::HandleFscControlTemperature))1530 return;1531 if (HandleService(curr, fDim->fFscControlHumidity, &StateMachineSmartFACT::HandleFscControlHumidity))1532 return;1533 if (HandleService(curr, fDim->fControlMessage, &StateMachineSmartFACT::HandleControlMessage))1534 return;1535 if (HandleService(curr, fDim->fRateScanData, &StateMachineSmartFACT::HandleRateScanData))1536 return;1537 }1538 1312 1539 1313 bool CheckEventSize(size_t has, const char *name, size_t size) … … 1548 1322 } 1549 1323 1324 const State GetState(const DimState &s) const 1325 { 1326 return fNetwork.GetState(s.name(), s.state()); 1327 } 1328 1550 1329 void PrintState(const DimState &state) const 1551 1330 { 1552 const State rc = fDim->GetState(state);1331 const State rc = GetState(state); 1553 1332 1554 1333 Out() << state.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - "; … … 1568 1347 int Print() const 1569 1348 { 1570 Out() << fDim ->fDNS.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - ";1571 Out() << kBold << "DIM_DNS: " << fDim ->fDNS.version() << endl;1572 1573 PrintState(fDim ->fMcp);1574 PrintState(fDim ->fControl);1575 PrintState(fDim ->fDataLogger);1576 PrintState(fDim ->fDriveControl);1577 PrintState(fDim ->fFadControl);1578 PrintState(fDim ->fFtmControl);1579 PrintState(fDim ->fBiasControl);1580 PrintState(fDim ->fFeedback);1581 PrintState(fDim ->fRateControl);1582 PrintState(fDim ->fFscControl);1583 PrintState(fDim ->fMagicWeather);1584 PrintState(fDim ->fRateScan);1585 PrintState(fDim ->fChatServer);1349 Out() << fDimDNS.time().GetAsStr("%H:%M:%S.%f").substr(0, 12) << " - "; 1350 Out() << kBold << "DIM_DNS: " << fDimDNS.version() << endl; 1351 1352 PrintState(fDimMcp); 1353 PrintState(fDimControl); 1354 PrintState(fDimDataLogger); 1355 PrintState(fDimDriveControl); 1356 PrintState(fDimFadControl); 1357 PrintState(fDimFtmControl); 1358 PrintState(fDimBiasControl); 1359 PrintState(fDimFeedback); 1360 PrintState(fDimRateControl); 1361 PrintState(fDimFscControl); 1362 PrintState(fDimMagicWeather); 1363 PrintState(fDimRateScan); 1364 PrintState(fDimChatServer); 1586 1365 1587 1366 return GetCurrentState(); … … 1593 1372 return kHtmlWhite+"\t—\n"; 1594 1373 1595 if (&state==&fDim ->fControl)1374 if (&state==&fDimControl) 1596 1375 { 1597 1376 ostringstream out; … … 1600 1379 } 1601 1380 1602 const State rc = fDim->GetState(state);1381 const State rc = GetState(state); 1603 1382 1604 1383 // Sate not found in list, server online (-3: offline; -2: not found) … … 1630 1409 //poll_one(); 1631 1410 1632 if (fDim ->fDNS.state()==0)1411 if (fDimDNS.state()==0) 1633 1412 return kStateDimNetworkNA; 1634 1413 … … 1640 1419 1641 1420 ostringstream out; 1642 out << now.JavaDate() << '\t' << fDim ->fControl.online() << '\n';1421 out << now.JavaDate() << '\t' << fDimControl.online() << '\n'; 1643 1422 out << setprecision(3); 1644 1423 1645 1424 // -------------- System status -------------- 1646 if (fDim ->fMcp.state()>=5) // Idle1425 if (fDimMcp.state()>=5) // Idle 1647 1426 { 1648 1427 string col = kHtmlBlue; … … 1651 1430 fMcpConfigurationState!=11 && // Trigger On 1652 1431 fMcpConfigurationState!=12) // Taking Data*/ 1653 if (fDim ->fMcp.state()!= 5 && // Idle1654 fDim ->fMcp.state()!=11 && // Trigger On1655 fDim ->fMcp.state()!=12) // Taking Data1432 if (fDimMcp.state()!= 5 && // Idle 1433 fDimMcp.state()!=11 && // Trigger On 1434 fDimMcp.state()!=12) // Taking Data 1656 1435 col = kHtmlYellow; 1657 1436 else 1658 if (fDim ->fFadControl.state()==FAD::kWritingData)1437 if (fDimFadControl.state()==FAD::kWritingData) 1659 1438 col = kHtmlGreen; 1660 1439 1661 1440 out << col << '\t'; 1662 1441 1663 if (fDim ->fRateControl.state()!=5 && fDim->fRateScan.state()!=5)1442 if (fDimRateControl.state()!=5 && fDimRateScan.state()!=5) 1664 1443 { 1665 switch (fDim ->fMcp.state()/*fMcpConfigurationState*/)1444 switch (fDimMcp.state()/*fMcpConfigurationState*/) 1666 1445 { 1667 1446 // kStateIdle … … 1679 1458 } 1680 1459 else 1681 if (fDim ->fRateControl.state()==5/*kStateSettingGlobalThreshold*/)1460 if (fDimRateControl.state()==5/*kStateSettingGlobalThreshold*/) 1682 1461 out << "Calibrating threshold"; 1683 1462 else 1684 1463 1685 if (fDim ->fRateScan.state()==5/*kStateSettingGlobalThreshold*/)1464 if (fDimRateScan.state()==5/*kStateSettingGlobalThreshold*/) 1686 1465 out << "Rate scan in progress"; 1687 1466 1688 if (fDim ->fMcp.state()>10 && fDim->fRateControl.state()!=5)1467 if (fDimMcp.state()>10 && fDimRateControl.state()!=5) 1689 1468 { 1690 1469 if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12) … … 1732 1511 1733 1512 // ------------------ Drive ----------------- 1734 if (fDim ->fDriveControl.state()>=5) // Armed, Moving, Tracking1513 if (fDimDriveControl.state()>=5) // Armed, Moving, Tracking 1735 1514 { 1736 1515 const double dev = fDriveControlTrackingDevHist.size()>0 ? fDriveControlTrackingDevHist.back() : 0; 1737 const State rc = fDim->GetState(fDim->fDriveControl);1516 const State rc = GetState(fDimDriveControl); 1738 1517 string col = kHtmlGreen; 1739 1518 if (rc.index==6) // Moving … … 1753 1532 out << fDriveControlPointingZd << '\t'; 1754 1533 out << fDriveControlPointingAz << '\t'; 1755 if (fDim ->fDriveControl.state()==7)1534 if (fDimDriveControl.state()==7) 1756 1535 { 1757 1536 out << fDriveControlSourceName << '\t'; … … 1767 1546 1768 1547 // ------------------- FSC ------------------ 1769 if (fDim ->fFscControl.state()>1 && fFscControlTemperatureHist.size()>0)1548 if (fDimFscControl.state()>1 && fFscControlTemperatureHist.size()>0) 1770 1549 { 1771 1550 out << kHtmlGreen << '\t' << fFscControlTemperatureHist.back() << '\n'; … … 1775 1554 1776 1555 // --------------- MagicWeather ------------- 1777 if (fDim ->fMagicWeather.state()==3 && fMagicWeatherHist[kWeatherBegin].size()>0)1556 if (fDimMagicWeather.state()==3 && fMagicWeatherHist[kWeatherBegin].size()>0) 1778 1557 { 1779 1558 /* … … 1804 1583 1805 1584 // --------------- FtmControl ------------- 1806 if (fDim ->fFtmControl.state()==FTM::kTriggerOn)1585 if (fDimFtmControl.state()==FTM::kTriggerOn) 1807 1586 { 1808 1587 string col = kHtmlGreen; … … 1818 1597 1819 1598 // --------------- BiasControl ------------- 1820 if (fDim ->fBiasControl.state()==BIAS::kRamping ||1821 fDim ->fBiasControl.state()==BIAS::kOverCurrent ||1822 fDim ->fBiasControl.state()==BIAS::kVoltageOn ||1823 fDim ->fBiasControl.state()==BIAS::kVoltageOff)1824 { 1825 const bool off = fDim ->fBiasControl.state()==BIAS::kVoltageOff;1826 const bool oc = fDim ->fBiasControl.state()==BIAS::kOverCurrent;1599 if (fDimBiasControl.state()==BIAS::kRamping || 1600 fDimBiasControl.state()==BIAS::kOverCurrent || 1601 fDimBiasControl.state()==BIAS::kVoltageOn || 1602 fDimBiasControl.state()==BIAS::kVoltageOff) 1603 { 1604 const bool off = fDimBiasControl.state()==BIAS::kVoltageOff; 1605 const bool oc = fDimBiasControl.state()==BIAS::kOverCurrent; 1827 1606 1828 1607 string col = fBiasControlVoltageMed>3?kHtmlGreen:kHtmlWhite; … … 1833 1612 1834 1613 // Bias in overcurrent => Red 1835 if (fDim ->fBiasControl.state()==BIAS::kOverCurrent)1614 if (fDimBiasControl.state()==BIAS::kOverCurrent) 1836 1615 col = kHtmlRed; 1837 1616 1838 1617 // MCP in ReadyForDatataking/Configuring/Configured/TriggerOn/TakingData 1839 1618 // and Bias not in "data-taking state' => Red 1840 if (fDim ->fMcp.state()>5 &&1841 fDim ->fBiasControl.state()!=BIAS::kVoltageOn &&1842 fDim ->fBiasControl.state()!=BIAS::kVoltageOff)1619 if (fDimMcp.state()>5 && 1620 fDimBiasControl.state()!=BIAS::kVoltageOn && 1621 fDimBiasControl.state()!=BIAS::kVoltageOff) 1843 1622 col = kHtmlRed; 1844 1623 … … 1846 1625 1847 1626 // Feedback is currently calibrating => Blue 1848 if (fDim ->fFeedback.state()==13)1627 if (fDimFeedback.state()==13) 1849 1628 { 1850 1629 out << kHtmlBlue << '\t'; … … 1882 1661 1883 1662 out.str(""); 1884 out << now.JavaDate() << '\t' << fDim ->fControl.online() << '\n';1885 1886 if (fDim ->fDNS.state()==0)1663 out << now.JavaDate() << '\t' << fDimControl.online() << '\n'; 1664 1665 if (fDimDNS.state()==0) 1887 1666 out << kHtmlWhite << "\tOffline\n\n\n\n\n\n\n\n\n\n\n\n"; 1888 1667 else 1889 1668 { 1890 out << kHtmlGreen << '\t' << fDim ->fDNS.version() << '\n';1891 1892 out << GetStateHtml(fDim ->fMcp, 4);1893 out << GetStateHtml(fDim ->fControl, 0);1894 out << GetStateHtml(fDim ->fDataLogger, 1);1895 out << GetStateHtml(fDim ->fDriveControl, 2);1896 out << GetStateHtml(fDim ->fFadControl, FAD::kConnected);1897 out << GetStateHtml(fDim ->fFtmControl, FTM::kConnected);1898 out << GetStateHtml(fDim ->fBiasControl, BIAS::kConnected);1899 out << GetStateHtml(fDim ->fFeedback, 4);1900 out << GetStateHtml(fDim ->fRateControl, 4);1901 out << GetStateHtml(fDim ->fFscControl, 2);1902 out << GetStateHtml(fDim ->fMagicWeather, 2);1903 out << GetStateHtml(fDim ->fRateScan, 4);1904 out << GetStateHtml(fDim ->fChatServer, 1);1669 out << kHtmlGreen << '\t' << fDimDNS.version() << '\n'; 1670 1671 out << GetStateHtml(fDimMcp, 4); 1672 out << GetStateHtml(fDimControl, 0); 1673 out << GetStateHtml(fDimDataLogger, 1); 1674 out << GetStateHtml(fDimDriveControl, 2); 1675 out << GetStateHtml(fDimFadControl, FAD::kConnected); 1676 out << GetStateHtml(fDimFtmControl, FTM::kConnected); 1677 out << GetStateHtml(fDimBiasControl, BIAS::kConnected); 1678 out << GetStateHtml(fDimFeedback, 4); 1679 out << GetStateHtml(fDimRateControl, 4); 1680 out << GetStateHtml(fDimFscControl, 2); 1681 out << GetStateHtml(fDimMagicWeather, 2); 1682 out << GetStateHtml(fDimRateScan, 4); 1683 out << GetStateHtml(fDimChatServer, 1); 1905 1684 } 1906 1685 … … 1909 1688 return kStateRunning; 1910 1689 } 1690 1911 1691 1912 1692 public: … … 1918 1698 fRateScanDataId(0), 1919 1699 fRateScanBoard(0), 1920 fDim(0) 1921 { 1700 // --- 1701 fDimMcp ("MCP"), 1702 fDimDataLogger ("DATA_LOGGER"), 1703 fDimDriveControl("DRIVE_CONTROL"), 1704 fDimMagicWeather("MAGIC_WEATHER"), 1705 fDimFeedback ("FEEDBACK"), 1706 fDimBiasControl ("BIAS_CONTROL"), 1707 fDimFtmControl ("FTM_CONTROL"), 1708 fDimFadControl ("FAD_CONTROL"), 1709 fDimFscControl ("FSC_CONTROL"), 1710 fDimRateControl ("RATE_CONTROL"), 1711 fDimRateScan ("RATE_SCAN"), 1712 fDimChatServer ("CHAT_SERVER") 1713 { 1714 fDimMcp.Subscribe(*this); 1715 fDimDataLogger.Subscribe(*this); 1716 fDimDriveControl.Subscribe(*this); 1717 fDimMagicWeather.Subscribe(*this); 1718 fDimFeedback.Subscribe(*this); 1719 fDimBiasControl.Subscribe(*this); 1720 fDimFtmControl.Subscribe(*this); 1721 fDimFadControl.Subscribe(*this); 1722 fDimFscControl.Subscribe(*this); 1723 fDimRateControl.Subscribe(*this); 1724 fDimRateScan.Subscribe(*this); 1725 fDimChatServer.Subscribe(*this); 1726 1727 Subscribe("DIM_CONTROL/MESSAGE") 1728 (bind(&StateMachineSmartFACT::HandleDimControlMessage, this, placeholders::_1)); 1729 1730 Subscribe("MCP/CONFIGURATION") 1731 (bind(&StateMachineSmartFACT::HandleMcpConfiguration, this, placeholders::_1)); 1732 1733 Subscribe("DRIVE_CONTROL/POINTING_POSITION") 1734 (bind(&StateMachineSmartFACT::HandleDrivePointing, this, placeholders::_1)); 1735 Subscribe("DRIVE_CONTROL/TRACKING_POSITION") 1736 (bind(&StateMachineSmartFACT::HandleDriveTracking, this, placeholders::_1)); 1737 Subscribe("DRIVE_CONTROL/SOURCE_POSITION") 1738 (bind(&StateMachineSmartFACT::HandleDriveSource, this, placeholders::_1)); 1739 1740 Subscribe("FSC_CONTROL/TEMPERATURE") 1741 (bind(&StateMachineSmartFACT::HandleFscTemperature, this, placeholders::_1)); 1742 Subscribe("FSC_CONTROL/HUMIDITY") 1743 (bind(&StateMachineSmartFACT::HandleFscHumidity, this, placeholders::_1)); 1744 1745 Subscribe("MAGIC_WEATHER/DATA") 1746 (bind(&StateMachineSmartFACT::HandleMagicWeatherData, this, placeholders::_1)); 1747 1748 Subscribe("FEEDBACK/DEVIATION") 1749 (bind(&StateMachineSmartFACT::HandleFeedbackDeviation, this, placeholders::_1)); 1750 Subscribe("FEEDBACK/CALIBRATION") 1751 (bind(&StateMachineSmartFACT::HandleFeedbackCalibration, this, placeholders::_1)); 1752 1753 Subscribe("BIAS_CONTROL/VOLTAGE") 1754 (bind(&StateMachineSmartFACT::HandleBiasVoltage, this, placeholders::_1)); 1755 Subscribe("BIAS_CONTROL/CURRENT") 1756 (bind(&StateMachineSmartFACT::HandleBiasCurrent, this, placeholders::_1)); 1757 1758 Subscribe("FAD_CONTROL/CONNECTIONS") 1759 (bind(&StateMachineSmartFACT::HandleFadConnections, this, placeholders::_1)); 1760 Subscribe("FAD_CONTROL/EVENTS") 1761 (bind(&StateMachineSmartFACT::HandleFadEvents, this, placeholders::_1)); 1762 1763 Subscribe("FTM_CONTROL/TRIGGER_RATES") 1764 (bind(&StateMachineSmartFACT::HandleFtmTriggerRates, this, placeholders::_1)); 1765 Subscribe("FTM_CONTROL/STATIC_DATA") 1766 (bind(&StateMachineSmartFACT::HandleFtmStaticData, this, placeholders::_1)); 1767 Subscribe("FTM_CONTROL/FTU_LIST") 1768 (bind(&StateMachineSmartFACT::HandleFtmFtuList, this, placeholders::_1)); 1769 1770 Subscribe("RATE_SCAN/DATA") 1771 (bind(&StateMachineSmartFACT::HandleRateScanData, this, placeholders::_1)); 1772 1773 Subscribe("FAD_CONTROL/EVENT_DATA") 1774 (bind(&StateMachineSmartFACT::HandleFadEventData, this, placeholders::_1)); 1775 1776 // ================================================================= 1777 1922 1778 // State names 1923 1779 AddStateName(kStateDimNetworkNA, "DimNetworkNotAvailable", … … 1926 1782 AddStateName(kStateRunning, "Running", ""); 1927 1783 1784 // ================================================================= 1785 1928 1786 AddEvent("PRINT") 1929 1787 (bind(&StateMachineSmartFACT::Print, this)) … … 1931 1789 1932 1790 } 1933 ~StateMachineSmartFACT()1934 {1935 delete fDim;1936 }1937 1791 int EvalOptions(Configuration &conf) 1938 1792 { … … 1945 1799 fPath = conf.Get<string>("path"); 1946 1800 1947 fDim = new DimSubscriptions(this); 1948 fDim->fControl.SetCallback(bind(&StateMachineSmartFACT::HandleControlStateChange, this, placeholders::_1)); 1949 fDim->fControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1)); 1801 fDimControl.SetCallback(bind(&StateMachineSmartFACT::HandleControlStateChange, this, placeholders::_1)); 1802 fDimControl.AddCallback("dotest.dim", bind(&StateMachineSmartFACT::HandleDoTest, this, placeholders::_1)); 1950 1803 1951 1804 return -1;
Note:
See TracChangeset
for help on using the changeset viewer.