/usr/include/tango/device_3.tpp is in libtango-dev 9.2.5a+dfsg1-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | //===================================================================================================================
//
// file : device_3.tpp
//
// description : C++ source code for the Device_3Impl class template methods
//
// project : TANGO
//
// author(s) : E.Taurel
//
// Copyright (C) : 2011,2012,2013,2014,2015
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This file is part of Tango.
//
// Tango is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with Tango.
// If not, see <http://www.gnu.org/licenses/>.
//
// $Revision$
//
//==================================================================================================================
#ifndef _DEVICE_3_TPP
#define _DEVICE_3_TPP
namespace Tango
{
//+---------------------------------------------------------------------------------------------------------------
//
// method :
// Device_3Impl::set_attribute_config_3_local
//
// description :
// Set attribute configuration for both AttributeConfig_3 and AttributeConfig_5
//
// args :
// in :
// - new_conf : The new attribute configuration
// - dummy_arg : Dummy and unnused arg. Just to help template coding
// - fwd_cb : Set to true if called from fwd att call back
// - caller_idl : IDL release used by caller
//
//----------------------------------------------------------------------------------------------------------------
template <typename T,typename V>
void Device_3Impl::set_attribute_config_3_local(const T &new_conf,TANGO_UNUSED(const V &dummy_arg),
bool fwd_cb,int caller_idl)
{
cout4 << "Entering Device_3Impl::set_attribute_config_3_local" << endl;
//
// Return exception if the device does not have any attribute
//
long nb_dev_attr = dev_attr->get_attr_nb();
if (nb_dev_attr == 0)
{
Except::throw_exception((const char *)API_AttrNotFound,
(const char *)"The device does not have any attribute",
(const char *)"Device_3Impl::set_attribute_config_3_local");
}
//
// Get some event related data
//
EventSupplier *event_supplier_nd = NULL;
EventSupplier *event_supplier_zmq = NULL;
Tango::Util *tg = Tango::Util::instance();
//
// Update attribute config first locally then in database
//
long nb_attr = new_conf.length();
long i;
EventSupplier::SuppliedEventData ad;
::memset(&ad,0,sizeof(ad));
try
{
for (i = 0;i < nb_attr;i++)
{
Attribute &attr = dev_attr->get_attr_by_name(new_conf[i].name);
bool old_alarm = attr.is_alarmed().any();
//
// Special case for forwarded attributes
//
if (attr.is_fwd_att() == true)
{
FwdAttribute &fwd_attr = static_cast<FwdAttribute &>(attr);
if (fwd_cb == true)
fwd_attr.set_att_config(new_conf[i]);
else
{
fwd_attr.upd_att_config_base(new_conf[i].label.in());
fwd_attr.upd_att_config(new_conf[i]);
}
}
else
{
attr.set_upd_properties(new_conf[i],device_name);
}
//
// In case the attribute quality factor was set to ALARM, reset it to VALID
//
if ((attr.get_quality() == Tango::ATTR_ALARM) &&
(old_alarm == true) &&
(attr.is_alarmed().any() == false))
attr.set_quality(Tango::ATTR_VALID);
//
// Send the event
//
if (attr.use_notifd_event() == true)
event_supplier_nd = tg->get_notifd_event_supplier();
else
event_supplier_nd = NULL;
if (attr.use_zmq_event() == true)
event_supplier_zmq = tg->get_zmq_event_supplier();
else
event_supplier_zmq = NULL;
if ((event_supplier_nd != NULL) || (event_supplier_zmq != NULL))
{
string tmp_name(new_conf[i].name);
//
// The event data has to be the new attribute conf which could be different than the one we received (in case some
// of the parameters are reset to lib/user/class default value)
//
V mod_conf;
attr.get_prop(mod_conf);
const V *tmp_ptr = &mod_conf;
Tango::AttributeConfig_3 conf3;
Tango::AttributeConfig_5 conf5;
AttributeConfig_3 *tmp_conf_ptr;
AttributeConfig_5 *tmp_conf_ptr5;
if (get_dev_idl_version() > 4)
{
vector<int> cl_lib = attr.get_client_lib(ATTR_CONF_EVENT);
if (caller_idl <= 4)
{
//
// Even if device is IDL 5, the change has been done from one old client (IDL4) thus with AttributeConfig_3.
// If a new client is listening to event, don't forget to send it.
//
for (size_t i = 0;i < cl_lib.size();i++)
{
if (cl_lib[i] == 5)
{
attr.AttributeConfig_3_2_AttributeConfig_5(mod_conf,conf5);
attr.add_config_5_specific(conf5);
tmp_conf_ptr5 = &conf5;
::memcpy(&(ad.attr_conf_5),&(tmp_conf_ptr5),sizeof(V *));
}
else
{
::memcpy(&(ad.attr_conf_3),&(tmp_ptr),sizeof(V *));
}
if (event_supplier_nd != NULL)
event_supplier_nd->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
if (event_supplier_zmq != NULL)
event_supplier_zmq->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
if (cl_lib[i] == 5)
ad.attr_conf_5 = NULL;
else
ad.attr_conf_3 = NULL;
}
}
else
{
for (size_t i = 0;i < cl_lib.size();i++)
{
if (cl_lib[i] < 5)
{
attr.AttributeConfig_5_2_AttributeConfig_3(mod_conf,conf3);
tmp_conf_ptr = &conf3;
::memcpy(&(ad.attr_conf_3),&(tmp_conf_ptr),sizeof(V *));
}
else
{
::memcpy(&(ad.attr_conf_5),&(tmp_ptr),sizeof(V *));
}
if (event_supplier_nd != NULL)
event_supplier_nd->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
if (event_supplier_zmq != NULL)
event_supplier_zmq->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
if (cl_lib[i] == 5)
ad.attr_conf_5 = NULL;
else
ad.attr_conf_3 = NULL;
}
}
}
else
{
::memcpy(&(ad.attr_conf_3),&(tmp_ptr),sizeof(V *));
if (event_supplier_nd != NULL)
event_supplier_nd->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
if (event_supplier_zmq != NULL)
event_supplier_zmq->push_att_conf_events(this,ad,(Tango::DevFailed *)NULL,tmp_name);
}
}
}
}
catch (Tango::DevFailed &e)
{
//
// Re build the list of "alarmable" attribute
//
dev_attr->get_alarm_list().clear();
for (long j = 0;j < nb_dev_attr;j++)
{
Attribute &att = dev_attr->get_attr_by_ind(j);
if (att.is_alarmed().any() == true)
{
if (att.get_writable() != Tango::WRITE)
dev_attr->get_alarm_list().push_back(j);
}
}
//
// Change the exception reason flag
//
TangoSys_OMemStream o;
o << e.errors[0].reason;
if (i != 0)
o << "\nAll previous attribute(s) have been successfully updated";
if (i != (nb_attr - 1))
o << "\nAll remaining attribute(s) have not been updated";
o << ends;
string s = o.str();
e.errors[0].reason = CORBA::string_dup(s.c_str());
throw;
}
//
// Re build the list of "alarmable" attribute
//
dev_attr->get_alarm_list().clear();
for (i = 0;i < nb_dev_attr;i++)
{
Tango::Attribute &attr = dev_attr->get_attr_by_ind(i);
Tango::AttrWriteType w_type = attr.get_writable();
if (attr.is_alarmed().any() == true)
{
if (w_type != Tango::WRITE)
dev_attr->get_alarm_list().push_back(i);
}
}
//
// Return to caller
//
cout4 << "Leaving Device_3Impl::set_attribute_config_3_local" << endl;
}
template <typename T>
inline void Device_3Impl::error_from_devfailed(T &back,DevFailed &e,const char *na)
{
back.err_list = e.errors;
back.quality = ATTR_INVALID;
back.name = CORBA::string_dup(na);
clear_att_dim(back);
}
template <typename T>
inline void Device_3Impl::error_from_errorlist(T &back,DevErrorList &e,const char *na)
{
back.err_list = e;
back.quality = ATTR_INVALID;
back.name = CORBA::string_dup(na);
clear_att_dim(back);
}
template <typename T>
inline void Device_3Impl::one_error(T &back,const char *reas,const char *ori,string &mess,Attribute &att)
{
back.err_list.length(1);
back.err_list[0].severity = Tango::ERR;
back.err_list[0].reason = CORBA::string_dup(reas);
back.err_list[0].origin = CORBA::string_dup(ori);
back.err_list[0].desc = CORBA::string_dup(mess.c_str());
back.quality = Tango::ATTR_INVALID;
back.name = CORBA::string_dup(att.get_name().c_str());
clear_att_dim(back);
}
template <typename T>
inline void Device_3Impl::one_error(T &back,const char *reas,const char *ori,string &mess,const char *na)
{
back.err_list.length(1);
back.err_list[0].severity = Tango::ERR;
back.err_list[0].reason = CORBA::string_dup(reas);
back.err_list[0].origin = CORBA::string_dup(ori);
back.err_list[0].desc = CORBA::string_dup(mess.c_str());
back.quality = Tango::ATTR_INVALID;
back.name = CORBA::string_dup(na);
clear_att_dim(back);
}
template <typename T,typename V>
inline void Device_3Impl::init_polled_out_data(T &back,V &att_val)
{
back.quality = att_val.quality;
back.time = att_val.time;
back.r_dim = att_val.r_dim;
back.w_dim = att_val.w_dim;
back.name = CORBA::string_dup(att_val.name);
}
template <typename T>
inline void Device_3Impl::init_out_data(T &back,Attribute &att,AttrWriteType &w_type)
{
back.time = att.get_when();
back.quality = att.get_quality();
back.name = CORBA::string_dup(att.get_name().c_str());
back.r_dim.dim_x = att.get_x();
back.r_dim.dim_y = att.get_y();
if ((w_type == Tango::READ_WRITE) ||
(w_type == Tango::READ_WITH_WRITE))
{
WAttribute &assoc_att = dev_attr->get_w_attr_by_ind(att.get_assoc_ind());
back.w_dim.dim_x = assoc_att.get_w_dim_x();
back.w_dim.dim_y = assoc_att.get_w_dim_y();
}
else
{
if ( w_type == Tango::WRITE)
{
// for write only attributes read and set value are the same!
back.w_dim.dim_x = att.get_x();
back.w_dim.dim_y = att.get_y();
}
else
{
// Tango::Read : read only attributes
back.w_dim.dim_x = 0;
back.w_dim.dim_y = 0;
}
}
}
template <typename T>
inline void Device_3Impl::init_out_data_quality(T &back,Attribute &att,AttrQuality qual)
{
back.time = att.get_when();
back.quality = qual;
back.name = CORBA::string_dup(att.get_name().c_str());
back.r_dim.dim_x = att.get_x();
back.r_dim.dim_y = att.get_y();
back.r_dim.dim_x = 0;
back.r_dim.dim_y = 0;
back.w_dim.dim_x = 0;
back.w_dim.dim_y = 0;
}
template <typename T>
inline void Device_3Impl::base_state2attr(T &back)
{
#ifdef _TG_WINDOWS_
struct _timeb after_win;
_ftime(&after_win);
back.time.tv_sec = (long)after_win.time;
back.time.tv_usec = (long)after_win.millitm * 1000;
back.time.tv_nsec = 0;
#else
struct timeval after;
gettimeofday(&after,NULL);
back.time.tv_sec = after.tv_sec;
back.time.tv_usec = after.tv_usec;
back.time.tv_nsec = 0;
#endif
back.quality = Tango::ATTR_VALID;
back.name = CORBA::string_dup("State");
back.r_dim.dim_x = 1;
back.r_dim.dim_y = 0;
back.w_dim.dim_x = 0;
back.w_dim.dim_y = 0;
}
template <typename T>
inline void Device_3Impl::base_status2attr(T &back)
{
#ifdef _TG_WINDOWS_
struct _timeb after_win;
_ftime(&after_win);
back.time.tv_sec = (long)after_win.time;
back.time.tv_usec = (long)after_win.millitm * 1000;
back.time.tv_nsec = 0;
#else
struct timeval after;
gettimeofday(&after,NULL);
back.time.tv_sec = after.tv_sec;
back.time.tv_usec = after.tv_usec;
back.time.tv_nsec = 0;
#endif
back.quality = Tango::ATTR_VALID;
back.name = CORBA::string_dup("Status");
back.r_dim.dim_x = 1;
back.r_dim.dim_y = 0;
back.w_dim.dim_x = 0;
back.w_dim.dim_y = 0;
}
} // End of Tango namespace
#endif /* DEVICE_3_TPP */
|