Go to the documentation of this file.00001 #include "bnet/RocClusterApplication.h"
00002
00003 #include "bnet/RocClusterFactory.h"
00004 #include "roc/Commands.h"
00005 #include "roc/Board.h"
00006
00007 #include "dabc/Manager.h"
00008 #include "dabc/Configuration.h"
00009
00010 bnet::RocClusterApplication::RocClusterApplication() :
00011 bnet::ClusterApplication(xmlRocClusterClass)
00012 {
00013 CreateParBool("DLMmaster", false);
00014
00015 fDLMDev = "";
00016 }
00017
00018 int bnet::RocClusterApplication::ExecuteCommand(dabc::Command* cmd)
00019 {
00020
00021 if (cmd->IsName(roc::CmdCalibration::CmdName())) {
00022
00023 bool flag = cmd->GetBool(roc::CmdCalibration::FlagName(), true);
00024
00025 for (int n=0;n<NumWorkers();n++)
00026 if (IsWorkerActive(n)) {
00027 dabc::Command* gcmd = new roc::CmdGlobalCalibration(flag);
00028 dabc::SetCmdReceiver(gcmd, GetWorkerNodeName(n), dabc::xmlAppDfltName);
00029 dabc::mgr()->Submit(gcmd);
00030 }
00031
00032 return dabc::cmd_true;
00033 }
00034
00035 return bnet::ClusterApplication::ExecuteCommand(cmd);
00036
00037 }
00038
00039
00040 bool bnet::RocClusterApplication::CreateAppModules()
00041 {
00042 if (GetParBool("DLMmaster", false)) {
00043
00044 fDLMDev = "AbbDev";
00045
00046 if (dabc::mgr()->FindDevice(fDLMDev.c_str()) == 0) {
00047
00048 dabc::Command* cmd = new dabc::CmdCreateDevice(roc::typeAbbDevice, fDLMDev.c_str(), "AbbDevThrd");
00049 cmd->SetBool(roc::xmlUseDLM, true);
00050
00051 if (!dabc::mgr()->Execute(cmd)) {
00052 EOUT(("Cannot create DLM device"));
00053 return false;
00054 }
00055 }
00056 }
00057
00058 return bnet::ClusterApplication::CreateAppModules();
00059 }
00060
00061 bool bnet::RocClusterApplication::BeforeAppModulesStarted()
00062 {
00063 if (fDLMDev.length() > 0) {
00064 dabc::Command* cmd = new roc::CmdDLM(8);
00065 dabc::SetCmdReceiver(cmd, FORMAT(("%s/%s", dabc::Manager::DevicesFolderName(), fDLMDev.c_str())));
00066 dabc::mgr()->Submit(cmd);
00067 }
00068
00069 return bnet::ClusterApplication::BeforeAppModulesStarted();
00070 }
00071
00072 bool bnet::RocClusterApplication::AfterAppModulesStopped()
00073 {
00074 if (fDLMDev.length() > 0) {
00075 dabc::Command* cmd = new roc::CmdDLM(9);
00076 dabc::SetCmdReceiver(cmd, FORMAT(("%s/%s", dabc::Manager::DevicesFolderName(), fDLMDev.c_str())));
00077 dabc::mgr()->Submit(cmd);
00078 }
00079 return bnet::ClusterApplication::AfterAppModulesStopped();
00080 }
00081
00082 bool bnet::RocClusterApplication::BeforeAppModulesDestroyed()
00083 {
00084 if (fDLMDev.length() > 0) {
00085
00086
00087 DOUT0(("One should here destroy DLM device"));
00088 }
00089
00090 fDLMDev = "";
00091 return bnet::ClusterApplication::BeforeAppModulesDestroyed();
00092 }