24 #include <cmw-rda/RDAService.h>
25 #include <cmw-rda/Config.h>
26 #include <cmw-rda/DeviceHandle.h>
27 #include <cmw-rda/ReplyHandler.h>
39 for (
unsigned x=0;x<
sizex;x++)
40 for (
unsigned y=0;y<
sizey;y++)
44 void fill(
int kind = 0)
46 for (
unsigned x=0;x<
sizex;x++)
47 for (
unsigned y=0;y<
sizey;y++)
49 case 0:
arr[x][y] = x+y;
break;
51 case 2:
arr[x][y] =
sizex - x + y;
break;
52 case 3:
arr[x][y] = x +
sizey-y;
break;
65 dabc::ModuleAsync(name, cmd),
72 fWorkerHierarchy.Create(
"FESA",
true);
77 item.
SetField(
"_autoload",
"dabcsys/plugins/fesa/fesa.js");
81 fWorkerHierarchy.CreateHChild(
"BeamRate").SetField(
dabc::prop_kind,
"rate");
91 CreateCmdDef(
"CmdReset").AddArg(
"counter",
"int",
true,
"5");
93 fServerName = Cfg(
"Server", cmd).AsStr();
94 fDeviceName = Cfg(
"Device", cmd).AsStr();
95 fCycles = Cfg(
"Cycles", cmd).AsStr();
96 fService = Cfg(
"Service", cmd).AsStr();
97 fField = Cfg(
"Field", cmd).AsStr();
99 CreateTimer(
"update", 1.);
104 if (!fServerName.empty() && !fDeviceName.empty()) {
105 fRDAService = rdaRDAService::init();
108 fDevice = fRDAService->getDeviceHandle(fDeviceName.c_str(), fServerName.c_str());
110 EOUT(
"Device %s on server %s not found", fDeviceName.c_str(), fServerName.c_str());
113 if ((fDevice!=0) && !fService.empty()) {
122 Publish(fWorkerHierarchy,
"FESA/Player");
138 rec->
fill(fCounter % 7);
142 if (fCounter == 10) {
143 DOUT0(
"Create BeamProfile2 10 seconds later");
148 item2.
SetField(
"_autoload",
"dabcsys/plugins/fesa/fesa.js");
155 rec2->
fill((fCounter+4) % 7);
160 if ((fDevice!=0) && !fService.empty()) {
161 double res = doGet(fService, fField);
163 fWorkerHierarchy.GetHChild(fService).SetField(
"value", res);
174 item()->bindata() = buf;
181 item2()->bindata() = buf2;
185 double v1 = 100. * (1.3 + sin(
dabc::Now().AsDouble()/5.));
186 fWorkerHierarchy.GetHChild(
"BeamRate").SetField(
"value",
dabc::format(
"%4.2f", v1));
195 v1 = 100. * (1.3 + cos(
dabc::Now().AsDouble()/8.));
196 fWorkerHierarchy.GetHChild(
"BeamRate2").SetField(
"value",
dabc::format(
"%4.2f", v1));
198 int test = fCounter % 100;
199 v1 = 20 + (test & 0xfffffc) + (test & 3)*0.01;
200 fWorkerHierarchy.GetHChild(
"TestRate").SetField(
"value",
dabc::format(
"%4.2f", v1));
202 fWorkerHierarchy.MarkChangedItems();
204 #ifdef DABC_EXTRA_CHECKS
213 if (cmd.
IsName(dabc::CmdGetBinary::CmdName())) {
215 std::string itemname = cmd.
GetStr(
"subitem");
216 std::string binkind = cmd.
GetStr(
"Kind");
217 std::string query = cmd.
GetStr(
"Query");
226 EOUT(
"Item %s not found to get binary", itemname.c_str());
232 if (binkind ==
"dabc.bin") {
233 buf = item()->bindata();
238 EOUT(
"No find binary data for item %s", itemname.c_str());
246 if (cmd.
IsName(
"CmdReset")) {
248 fCounter = cmd.
GetInt(
"counter", 0);
249 DOUT0(
"****************** CmdReset counter=%d ****************", fCounter);
261 if (fDevice==0)
return 0.;
264 rdaData* value = fDevice->get(service.c_str(), fCycles.c_str(), context);
266 res = value->extractDouble(field.c_str());
270 catch (
const rdaException& ex)
272 EOUT(
"Exception caught in doGet: %s %s", ex.getType(), ex.getMessage());
276 EOUT(
"Uncknown exception caught in doGet");;
Reference on memory from memory pool.
static Buffer CreateBuffer(BufferSize_t sz)
This static method create independent buffer for any other memory pools Therefore it can be used in s...
void * SegmentPtr(unsigned n=0) const
Returns pointer on the segment, no any boundary checks.
Represents command with its arguments.
bool SetRawData(Buffer rawdata)
Set raw data to the command, which can be transported also between nodes.
std::string GetStr(const std::string &name, const std::string &dflt="") const
int GetInt(const std::string &name, int dflt=0) const
Represents objects hierarchy of remote (or local) DABC process.
bool FillBinHeader(const std::string &itemname, dabc::Command &cmd, uint64_t mhash=0, const std::string &dflt_master_name="")
Fill binary header with item and master versions.
Hierarchy CreateHChild(const std::string &name, bool allowslahes=false, bool sortorder=false)
Create child item in hierarchy with specified name If allowslahes enabled, instead of subfolders item...
Hierarchy GetHChild(const std::string &name, bool allowslahes=false, bool force=false, bool sortorder=false)
Return child, if necessary creates with full subfolder If force specified, missing childs and folders...
void EnableHistory(unsigned length=100, bool withchilds=false)
Activate history production for selected element and its childs.
Lock guard for posix mutex.
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
bool SetField(const std::string &name, const RecordField &v)
bool IsName(const char *name) const
Returns true if object name is the same as specified one.
bool null() const
Returns true if reference contains nullptr.
virtual void ProcessTimerEvent(unsigned timer)
Method called by framework when timer event is produced.
virtual int ExecuteCommand(dabc::Command cmd)
Main method where commands are executed.
double doGet(const std::string &service, const std::string &field)
Player(const std::string &name, dabc::Command cmd=nullptr)
std::string format(const char *fmt,...)
Support for FESA - the control system of GSI/FAIR accelerator.
uint32_t arr[sizex][sizey]