diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f768f7909ca84a190cd6d52a1522bf55d0a7e55d --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +.pydevproject +.project +.cproject +.settings +obj +bin +core* +*~ +*.pyc +*.so +*.so* +.pylintrc +.metadata +.idea +.cvsignore +.nse_depinfo +software +oldsrc +CVS diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..65c5ca88a67c30becee01c5a8816d964b03862f9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..23edb40286d41c516c94ef6bd871b191b32b7b3d --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +NAME_SRV = gun-intlk-srv + +CXXFLAGS = +LDFLAGS = + +include ../makefiles/Make-9.3.3.in diff --git a/README.md b/README.md index acb212100d8b4e1121fde02d718259934d5c9305..074185dced509d30eb55849284c1a84899b04437 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -# gun-intlk +# Project Name +gun-intlk + +## Description + +Tango device server for Elettra proinjector gun interlock + +Imported from CVS repo booster/servers/interlock/gunintlk , release_11. +The former name of the executable was gunintlk-srv. + +## Installation & deployment + +Follow the institute standards for Tango C++ server. + +## History + +2020-05-26: cration of project on gitlab + +# Credits + +Original project developed by Sara Fontanini. + +Maintenance adn developments by Giulio Graziano. + +Imported on gitlab by Claudio Scafuri. + + +Elettra-Sincrotrone Trieste S.C.p.A. di interesse nazionale +Strada Statale 14 - km 163,5 in AREA Science Park +34149 Basovizza, Trieste ITALY + +## License + +GPL 3 diff --git a/src/ClassFactory.cpp b/src/ClassFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..111a11eaeafc283ae07b4d082362015004785fe4 --- /dev/null +++ b/src/ClassFactory.cpp @@ -0,0 +1,46 @@ +//+============================================================================= +// +// file : ClassFactory.cpp +// +// description : C++ source for the class_factory method of the DServer +// device class. This method is responsible to create +// all class singletin for a device server. It is called +// at device server startup +// +// project : TANGO Device Server +// +// $Author: sara $ +// +// $Revision: 1.1.1.1 $ +// +// $Log: ClassFactory.cpp,v $ +// Revision 1.1.1.1 2007-08-31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + +#include <tango.h> +#include <IntlkGunClass.h> + +/** + * Create IntlkGunClass singleton and store it in DServer object. + */ + +void Tango::DServer::class_factory() +{ + + add_class(IntlkGun_ns::IntlkGunClass::init("IntlkGun")); + +} diff --git a/src/IntlkGun.cpp b/src/IntlkGun.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e42c3bfcdd96e6a5e0552c83b149064be493a35b --- /dev/null +++ b/src/IntlkGun.cpp @@ -0,0 +1,1520 @@ +//+============================================================================= +// +// file : IntlkGun.cpp +// +// description : C++ source for the IntlkGun and its commands. +// The class is derived from Device. It represents the +// CORBA servant object which will be accessed from the +// network. All commands which can be executed on the +// IntlkGun are implemented in this file. +// +// project : TANGO Device Server +// +// $Author: graziano $ +// +// $Revision: 1.12 $ +// +// $Log: IntlkGun.cpp,v $ +// Revision 1.12 2019-12-23 10:29:44 graziano +// Fix realfiltimer to unsigned +// +// Revision 1.11 2019-01-07 15:21:34 graziano +// fixed for upgrade of plc interlock booster +// +// Revision 1.10 2017-03-30 11:34:28 claudio +// ticket 1934 porting to tango-9 +// +// Revision 1.9 2014-07-29 12:23:19 claudio +// removed lots of cout, use ERROR_STREAM +// +// Revision 1.8 2013-08-26 10:35:52 claudio +// Device_4Impl for tango-8 +// +// Revision 1.7 2008-09-02 10:29:50 sara +// improver attribute read from lower level srv +// +// Revision 1.6 2008/09/01 08:16:45 sara +// fixed bug -delete- in always_executed_hook +// +// Revision 1.5 2008/08/11 10:29:15 sara +// cached attributes +// +// Revision 1.4 2008/02/06 11:07:01 sara +// Gun Fil.Timer correction +// +// Revision 1.3 2008/02/01 14:20:21 sara +// added RealFilTimer attribute for gun current timer bar +// +// Revision 1.2 2007/12/06 14:26:37 sara +// Alarm attributes corresponding to PLC outputs take their value from +// the state of the outputs +// +// Revision 1.1.1.1 2007/08/31 16:24:36 sara +// server for gun interlock +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + + +//=================================================================== +// +// The following table gives the correspondance +// between commands and method's name. +// +// Command's name | Method's name +// ---------------------------------------- +// State | dev_state() +// Status | dev_status() +// Acknowledge_all | acknowledge_all() +// +//=================================================================== + + +#include <tango.h> +#include <IntlkGun.h> +#include <IntlkGunClass.h> +//------------------------------- +static char* GunSafetyMask[] = { + "Gun _VAC_OK_SLOW", + "Gun_I_Fil<MAX", + "Gun_safety_key", + "Gun dr closed", + "Gun safety foil", + "Gun earth", + "Gun air flux", + "Gun fuse" +}; +static char* FilAbiMask[] = { + "Abi Fil Gun", + "I_Fil_Gun_OK" +}; +static char* FilCurrMask[] = { + "Start_I_Fil_timer" +}; +static char* FilReadyMask[] = { + "I_Fil_Gun_ready", + "H.V.ABI", + "H.V.ABI", + "RF_ALR_SIP40_P 1.1", + "Gun_V_GRILL>MIN", + "Catode 80 V" +}; +static char* GunHVMask[] = { + "Gun HV abi", + "Gun HV OK", + "Gun_ABI_VLV", + "RF_ALR_SIP40_P 1.2", + "RF_ALR_SIP40_P 1.3", + "RF_ALR_SIP40_P 1.4", + "RF_ALR_SIP300_P 1.1", + "RF_ALR_SIP300_P 1.2", + "RF_ALR_SIP300_P 1.3", + "RF_ALR_SIP300_P 1.4" +}; +static char* AbiTrigGunMask[] = { + "Gun trigger abi" +}; +//------------------------------- +namespace IntlkGun_ns +{ + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::IntlkGun(string &s) +// +// description : constructor for simulated IntlkGun +// +// in : - cl : Pointer to the DeviceClass object +// - s : Device name +// +//----------------------------------------------------------------------------- +IntlkGun::IntlkGun(Tango::DeviceClass *cl,string &s) +:TANGO_BASE_CLASS(cl,s.c_str()) +{ + init_device(); +} + +IntlkGun::IntlkGun(Tango::DeviceClass *cl,const char *s) +:TANGO_BASE_CLASS(cl,s) +{ + init_device(); +} + +IntlkGun::IntlkGun(Tango::DeviceClass *cl,const char *s,const char *d) +:TANGO_BASE_CLASS(cl,s,d) +{ + init_device(); +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::delete_device() +// +// description : will be called at device destruction or at init command. +// +//----------------------------------------------------------------------------- +void IntlkGun::delete_device() +{ + // Delete device's allocated object +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::init_device() +// +// description : will be called at device initialization. +// +//----------------------------------------------------------------------------- +void IntlkGun::init_device() +{ + INFO_STREAM << "IntlkGun::IntlkGun() create device " << device_name << endl; + + // Initialise variables to default values + //-------------------------------------------- + + get_device_property(); + + // connect to interlock device + devintlk = new Tango::DeviceProxy(intlk_srv); + + timestamp_50 = 0; + timestamp_53 = 0; + curr_fil_val = 0; + grid_val = 0; + fil_timer = 0; + real_fil_timer = 0; + + // send command + try { + if (devintlk->ping()) { + set_state(Tango::ON); + set_status("Connected to device " + intlk_srv); + ERROR_STREAM << "IntlkGun::IntlkGun() Connected to devintlk:" << intlk_srv << endl; + } + } + catch(Tango::DevFailed e) { + set_state(Tango::FAULT); + set_status("Failed to connect to devintlk " + intlk_srv); + ERROR_STREAM <<"IntlkGun::IntlkGun() Failed to connect to devintlk " + intlk_srv << endl; + } + //init position, names of the signals + vector <string> gun_saf, fl_ab, fl_crr, fl_rdy, gun_hv, abi_trg_gn; + for(int k=0;k<GUNSAFETY_DIM;k++){ + pos_gun_safety[k] = -1; + name_gun_safety[k] = GunSafetyMask[k]; + pos_alm_gun_safety[k] = -1; + alm_gun_safety[k] = true; + name_alm_gun_safety[k] = GunSafetyMask[k]; + gun_saf.push_back(string(name_gun_safety[k])); + } + for(int k=0;k<FILABI_DIM;k++){ + pos_fil_abi[k] = -1; + name_fil_abi[k] = FilAbiMask[k]; + alm_fil_abi[k] = true; + name_alm_fil_abi[k] = FilAbiMask[k]; + fl_ab.push_back(string(name_fil_abi[k])); + } + for(int k=0;k<FILCURR_DIM;k++){ + pos_fil_curr[k] = -1; + name_fil_curr[k] = FilCurrMask[k]; + pos_alm_fil_curr[k] = -1; + alm_fil_curr[k] = true; + name_alm_fil_curr[k] = FilCurrMask[k]; + fl_crr.push_back(string(name_fil_curr[k])); + } + for(int k=0;k<FILREADY_DIM;k++){ + pos_fil_ready[k] = -1; + name_fil_ready[k] = FilReadyMask[k]; + pos_alm_fil_ready[k] = -1; + alm_fil_ready[k] = true; + name_alm_fil_ready[k] = FilReadyMask[k]; + fl_rdy.push_back(string(name_fil_ready[k])); + } + for(int k=0;k<GUNHV_DIM;k++){ + pos_gun_hv[k] = -1; + name_gun_hv[k] = GunHVMask[k]; + pos_alm_gun_hv[k] = -1; + alm_gun_hv[k] = true; + name_alm_gun_hv[k] = GunHVMask[k]; + gun_hv.push_back(string(name_gun_hv[k])); + } + for(int k=0;k<ABITRIGGUN_DIM;k++){ + pos_abi_trig_gun[k] = -1; + name_abi_trig_gun[k] = AbiTrigGunMask[k]; + pos_alm_abi_trig_gun[k] = -1; + alm_abi_trig_gun[k] = true; + name_alm_abi_trig_gun[k] = AbiTrigGunMask[k]; + abi_trg_gn.push_back(string(name_abi_trig_gun[k])); + } + Tango::Database *db = new Tango::Database(); + Tango::DbData db_gun_saf, db_fl_ab, db_fl_crr, db_fl_rdy, db_gun_hv, db_abi_trg_gn; + + Tango::DbDatum GunSafety("gunSafety"), sig_n1("signal_names"); + GunSafety << (short int) 1; + db_gun_saf.push_back(GunSafety); + sig_n1 << gun_saf; + db_gun_saf.push_back(sig_n1); + + Tango::DbDatum FilAbi("filAbi"), sig_n2("signal_names"); + FilAbi << (short int) 1; + db_fl_ab.push_back(FilAbi); + sig_n2 << fl_ab; + db_fl_ab.push_back(sig_n2); + + Tango::DbDatum FilCurr("filCurr"), sig_n3("signal_names"); + FilCurr << (short int) 1; + db_fl_crr.push_back(FilCurr); + sig_n3 << fl_crr; + db_fl_crr.push_back(sig_n3); + + Tango::DbDatum FilReady("filReady"), sig_n4("signal_names"); + FilReady << (short int) 1; + db_fl_rdy.push_back(FilReady); + sig_n4 << fl_rdy; + db_fl_rdy.push_back(sig_n4); + + Tango::DbDatum GunHV("gunHV"), sig_n5("signal_names"); + GunHV << (short int) 1; + db_gun_hv.push_back(GunHV); + sig_n5 << gun_hv; + db_gun_hv.push_back(sig_n5); + + Tango::DbDatum AbiTrigGun("abiTrigGun"), sig_n6("signal_names"); + AbiTrigGun << (short int) 1; + db_abi_trg_gn.push_back(AbiTrigGun); + sig_n6 << abi_trg_gn; + db_abi_trg_gn.push_back(sig_n6); + + //makes -signal_names- visible through attribute property + try { + db->set_timeout_millis(10000); + db->put_device_attribute_property(get_name(), db_gun_saf); + db->put_device_attribute_property(get_name(), db_fl_ab); + db->put_device_attribute_property(get_name(), db_fl_crr); + db->put_device_attribute_property(get_name(), db_fl_rdy); + db->put_device_attribute_property(get_name(), db_gun_hv); + db->put_device_attribute_property(get_name(), db_abi_trg_gn); + } catch (Tango::DevFailed &e) { + Tango::Except::print_exception(e); + } + //check if signals in the Masks are available from the low-level server + match_labels("labels_50"); + match_labels("labels_53"); +} + + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::get_device_property() +// +// description : Read the device properties from database. +// +//----------------------------------------------------------------------------- +void IntlkGun::get_device_property() +{ + // Initialize your default values here (if not done with POGO). + //------------------------------------------------------------------ + + // Read device properties from database.(Automatic code generation) + //------------------------------------------------------------------ + Tango::DbData dev_prop; + dev_prop.push_back(Tango::DbDatum("Intlk_srv")); + + // Call database and extract values + //-------------------------------------------- + if (Tango::Util::instance()->_UseDb==true) + get_db_device()->get_property(dev_prop); + Tango::DbDatum def_prop, cl_prop; + IntlkGunClass *ds_class = + (static_cast<IntlkGunClass *>(get_device_class())); + int i = -1; + + // Try to initialize Intlk_srv from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> intlk_srv; + // Try to initialize Intlk_srv from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> intlk_srv; + // And try to extract Intlk_srv value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> intlk_srv; + + + + // End of Automatic code generation + //------------------------------------------------------------------ + +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::always_executed_hook() +// +// description : method always executed before any command is executed +// +//----------------------------------------------------------------------------- +void IntlkGun::always_executed_hook() +{ + + struct timeval now; + vector<Tango::DeviceAttribute> *devattr_states = 0; + vector<Tango::DeviceAttribute> *devattr_alarm = 0; + vector<string> attr_names_states; + vector<string> attr_names_alarm; + vector<double> raw_val; + vector<bool> values53; + vector<bool> values50; + + gettimeofday(&now, NULL); + + if (abs((now.tv_sec - last_cache_update.tv_sec)*1000000+ + (now.tv_usec - last_cache_update.tv_usec)) > RFSH_CACHE) { + try { + + attr_names_states.push_back("db10"); + attr_names_states.push_back("db_50"); + devattr_states = devintlk->read_attributes(attr_names_states); + (*devattr_states)[0] >> raw_val; + (*devattr_states)[1] >> values50; + delete devattr_states; + for(size_t i=0;i<values50.size() && i<MESG_50_LEN_B;i++){ + msg_50[i] = (Tango::DevBoolean)(values50.at(i)); + } + for(size_t i=0;i<raw_val.size() && i<RAW_MSG_10_LEN;i++){ + rawmsg_10[i] = (Tango::DevDouble)(raw_val.at(i)); + } + + gettimeofday(&last_cache_update,NULL); + } + catch(Tango::DevFailed &e) { + ERROR_STREAM <<"attribute refresh db_50 failed at "<< now.tv_sec<<"/"<< now.tv_usec<<endl; + if(devattr_states) + delete devattr_states; + } + try { + + attr_names_alarm.push_back("rt_db_53"); + devattr_alarm = devintlk->read_attributes(attr_names_alarm); + (*devattr_alarm)[0] >> values53; + delete devattr_alarm; + for(size_t i=0;i<values53.size() && i<MESG_53_LEN_B;i++){ + msg_53[i] = (Tango::DevBoolean)(values53.at(i)); + } + + gettimeofday(&last_cache_update,NULL); + } + catch(Tango::DevFailed &e) { + ERROR_STREAM << "attribute refresh rt_db_53 failed at "<< now.tv_sec<<"/"<< now.tv_usec<<endl; + if(devattr_alarm) + delete devattr_alarm; + } + } + +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_attr_hardware +// +// description : Hardware acquisition for attributes. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_attr_hardware(vector<long> &attr_list) +{ + //DEBUG_STREAM << "IntlkGun::read_attr_hardware(vector<long> &attr_list) entering... "<< endl; + // Add your own code here +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_RealFilTimer +// +// description : Extract real attribute values for RealFilTimer acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_RealFilTimer(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_RealFilTimer(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<u_short> raw_val; + + attr_names.push_back("raw_msg_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> raw_val; + delete devattr; +*/ +#if 0 + unsigned char arr[2]; + for(int j=0, k=1;j<2;j++, k--){ +// DEBUG_STREAM << j+294 << "-"<< ((Tango::DevUShort)(raw_val.at(j+294))) << endl; + DEBUG_STREAM << j+294 << "-"<< rawmsg_50[j+294] << endl; +// bcopy(&(raw_val.at(j+294)), &(arr[k]), 1); + bcopy(&(rawmsg_50[j+294]), &(arr[k]), 1); + } + u_short timer = 0; + + bcopy(&arr[0], &timer, 2); + timer = 0xffff-timer; +#else + unsigned short timer = (unsigned short)rawmsg_10[0]; +#endif + real_fil_timer = (float)timer; + real_fil_timer /= 60;// div 600 mul 10 + + attr_RealFilTimer_read = &real_fil_timer; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_RealFilTimer_read, taim, Tango::ATTR_VALID, 1,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_FilTimer_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_FilTimer +// +// description : Extract real attribute values for FilTimer acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_FilTimer(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_FilTimer(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<u_short> raw_val; + + attr_names.push_back("raw_msg_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> raw_val; + delete devattr; +*/ +#if 0 + unsigned char arr[4]; + for(int j=0, k=3;j<4;j++, k--){ + +// DEBUG_STREAM << j+292 << "-"<< ((Tango::DevUShort)(raw_val.at(j+292))) << "/"; + DEBUG_STREAM << j+292 << "-"<< rawmsg_50[j+292] << "/"; +// bcopy(&(raw_val.at(j+292)), &(arr[k]), 1); + bcopy(&(rawmsg_50[j+292]), &(arr[k]), 1); + } + u_short counter = 0; + + bcopy(&arr[0], &counter, 2); + DEBUG_STREAM <<"counter:"<< counter << endl; + fil_timer = (u_short)counter; +#else + double fil_timer_d = rawmsg_10[0]; + fil_timer = (u_short)fil_timer_d; +#endif + + attr_FilTimer_read = &fil_timer; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_FilTimer_read, taim, Tango::ATTR_VALID, 1,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_FilTimer_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmAbiTrigGun +// +// description : Extract real attribute values for AlmAbiTrigGun acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmAbiTrigGun(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmAbiTrigGun(Tango::Attribute &attr) entering... "<< endl; + +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values50; + vector<bool> values53; + + attr_names.push_back("rt_db_53"); + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values53; + (*devattr)[1] >> values50; + delete devattr; +*/ + + for(int j=0;j<ABITRIGGUN_DIM;j++){ + if(j==0){ +// alm_abi_trig_gun[j] = ((Tango::DevBoolean)(values50.at(pos_abi_trig_gun[j]))); + alm_abi_trig_gun[j] = msg_50[pos_abi_trig_gun[j]]; + DEBUG_STREAM << "read values " << name_alm_abi_trig_gun[j]<< " val: "<< alm_abi_trig_gun[j]<<endl; + } + else{ +// alm_abi_trig_gun[j] = ((Tango::DevBoolean)(values53.at(pos_alm_abi_trig_gun[j]))); + alm_abi_trig_gun[j] = msg_53[pos_alm_abi_trig_gun[j]]; + DEBUG_STREAM << "read values " << name_alm_abi_trig_gun[j]<< " val: "<< alm_abi_trig_gun[j]<<endl; + } + } + + attr_AlmAbiTrigGun_read = &alm_abi_trig_gun[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmAbiTrigGun_read, taim, Tango::ATTR_VALID, ABITRIGGUN_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmGunSafety +// +// description : Extract real attribute values for AlmGunSafety acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmGunSafety(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmGunSafety(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("rt_db_53"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<GUNSAFETY_DIM;j++){ +// alm_gun_safety[j] = ((Tango::DevBoolean)(values.at(pos_alm_gun_safety[j]))); + alm_gun_safety[j] = msg_53[pos_alm_gun_safety[j]]; + DEBUG_STREAM << "read values " << name_alm_gun_safety[j]<< " val: "<< alm_gun_safety[j]<<endl; + } + + attr_AlmGunSafety_read = &alm_gun_safety[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmGunSafety_read, taim, Tango::ATTR_VALID, GUNSAFETY_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } + +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::write_AlmGunSafety +// +// description : Write AlmGunSafety attribute values to hardware. +// +//----------------------------------------------------------------------------- +void IntlkGun::write_AlmGunSafety(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "IntlkGun::write_AlmGunSafety(Tango::WAttribute &attr) entering... "<< endl; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmFilAbi +// +// description : Extract real attribute values for AlmFilAbi acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmFilAbi(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmFilAbi(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values50; + vector<bool> values53; + + attr_names.push_back("rt_db_53"); + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values53; + (*devattr)[1] >> values50; + delete devattr; +*/ + + + for(int j=0;j<FILABI_DIM;j++){ + if(j==0){ +// alm_fil_abi[j] = ((Tango::DevBoolean)(values50.at(pos_fil_abi[j]))); + alm_fil_abi[j] = msg_50[pos_fil_abi[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_abi[j]<< " val: "<< alm_fil_abi[j]<<endl; + } + else{ +// alm_fil_abi[j] = ((Tango::DevBoolean)(values53.at(pos_alm_fil_abi[j]))); + alm_fil_abi[j] = msg_53[pos_alm_fil_abi[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_abi[j]<< " val: "<< alm_fil_abi[j]<<endl; + } + } + + attr_AlmFilAbi_read = &alm_fil_abi[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmFilAbi_read, taim, Tango::ATTR_VALID, FILABI_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::write_AlmFilAbi +// +// description : Write AlmFilAbi attribute values to hardware. +// +//----------------------------------------------------------------------------- +void IntlkGun::write_AlmFilAbi(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "IntlkGun::write_AlmFilAbi(Tango::WAttribute &attr) entering... "<< endl; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmFilCurr +// +// description : Extract real attribute values for AlmFilCurr acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmFilCurr(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmFilCurr(Tango::Attribute &attr) entering... "<< endl; + +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values50; + vector<bool> values53; + + attr_names.push_back("rt_db_53"); + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values53; + (*devattr)[1] >> values50; + delete devattr; +*/ + + for(int j=0;j<FILCURR_DIM;j++){ + if(j==0){ +// alm_fil_curr[j] = ((Tango::DevBoolean)(values50.at(pos_fil_curr[j]))); + alm_fil_curr[j] = msg_50[pos_fil_curr[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_curr[j]<< " val: "<< alm_fil_curr[j]<<endl; + } + else{ +// alm_fil_curr[j] = ((Tango::DevBoolean)(values53.at(pos_alm_fil_curr[j]))); + alm_fil_curr[j] = msg_53[pos_alm_fil_curr[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_curr[j]<< " val: "<< alm_fil_curr[j]<<endl; + } + } + + attr_AlmFilCurr_read = &alm_fil_curr[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmFilCurr_read, taim, Tango::ATTR_VALID, FILCURR_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::write_AlmFilCurr +// +// description : Write AlmFilCurr attribute values to hardware. +// +//----------------------------------------------------------------------------- +void IntlkGun::write_AlmFilCurr(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "IntlkGun::write_AlmFilCurr(Tango::WAttribute &attr) entering... "<< endl; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmFilReady +// +// description : Extract real attribute values for AlmFilReady acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmFilReady(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmFilReady(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values50; + vector<bool> values53; + + attr_names.push_back("rt_db_53"); + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values53; + (*devattr)[1] >> values50; + delete devattr; +*/ + for(int j=0;j<FILREADY_DIM;j++){ + if(j==0){ +// alm_fil_ready[j] = ((Tango::DevBoolean)(values50.at(pos_fil_ready[j]))); + alm_fil_ready[j] = msg_50[pos_fil_ready[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_ready[j]<< " val: "<< alm_fil_ready[j]<<endl; + } + else{ +// alm_fil_ready[j] = ((Tango::DevBoolean)(values53.at(pos_alm_fil_ready[j]))); + alm_fil_ready[j] = msg_53[pos_alm_fil_ready[j]]; + DEBUG_STREAM << "read values " << name_alm_fil_ready[j]<< " val: "<< alm_fil_ready[j]<<endl; + } + } + + attr_AlmFilReady_read = &alm_fil_ready[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmFilReady_read, taim, Tango::ATTR_VALID, FILREADY_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::write_AlmFilReady +// +// description : Write AlmFilReady attribute values to hardware. +// +//----------------------------------------------------------------------------- +void IntlkGun::write_AlmFilReady(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "IntlkGun::write_AlmFilReady(Tango::WAttribute &attr) entering... "<< endl; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AlmGunHV +// +// description : Extract real attribute values for AlmGunHV acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AlmGunHV(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AlmGunHV(Tango::Attribute &attr) entering... "<< endl; + +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values50; + vector<bool> values53; + + attr_names.push_back("rt_db_53"); + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values53; + (*devattr)[1] >> values50; + delete devattr; +*/ + + for(int j=0;j<GUNHV_DIM;j++){ + if(j==0){ +// alm_gun_hv[j] = ((Tango::DevBoolean)(values50.at(pos_gun_hv[j]))); + alm_gun_hv[j] = msg_50[pos_gun_hv[j]]; + DEBUG_STREAM << "read values " << name_alm_gun_hv[j]<< " val: "<< alm_gun_hv[j]<<endl; + } + else{ +// alm_gun_hv[j] = ((Tango::DevBoolean)(values53.at(pos_alm_gun_hv[j]))); + alm_gun_hv[j] = msg_53[pos_alm_gun_hv[j]]; + DEBUG_STREAM << "read values " << name_alm_gun_hv[j]<< " val: "<< alm_gun_hv[j]<<endl; + } + } + + attr_AlmGunHV_read = &alm_gun_hv[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_53 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AlmGunHV_read, taim, Tango::ATTR_VALID, GUNHV_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::write_AlmGunHV +// +// description : Write AlmGunHV attribute values to hardware. +// +//----------------------------------------------------------------------------- +void IntlkGun::write_AlmGunHV(Tango::WAttribute &attr) +{ + DEBUG_STREAM << "IntlkGun::write_AlmGunHV(Tango::WAttribute &attr) entering... "<< endl; +} + + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_CurrFilVal +// +// description : Extract real attribute values for CurrFilVal acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_CurrFilVal(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_CurrFilVal(Tango::Attribute &attr) entering... "<< endl; +#if 0 + unsigned char arr[4]; + for(int j=0, k=3;j<4;j++, k--){ + bcopy(&(rawmsg_50[j+296]), &(arr[k]), 1); + } + float curr; + bcopy(&arr[0], &curr, 4); + DEBUG_STREAM <<"curr:"<< curr << endl; + curr_fil_val = (double)curr; +#else + curr_fil_val = rawmsg_10[2]; +#endif + attr_CurrFilVal_read = &curr_fil_val; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + attr.set_value_date_quality(attr_CurrFilVal_read, taim, Tango::ATTR_VALID, 1,0,false); +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_GridVal +// +// description : Extract real attribute values for GridVal acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_GridVal(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_GridVal(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; +// vector<bool> values; + vector<u_short> raw_val; + +// attr_names.push_back("db_50"); + attr_names.push_back("raw_msg_50"); + devattr = devintlk->read_attributes(attr_names); +// (*devattr)[0] >> values; +// (*devattr)[1] >> raw_val; + (*devattr)[0] >> raw_val; + delete devattr; +*/ +#if 0 + unsigned char arr[4]; + for(int j=0, k=3;j<4;j++, k--){ + +// DEBUG_STREAM << j+300 << "-"<< ((Tango::DevUShort)(raw_val.at(j+300))) << "/"; + DEBUG_STREAM << j+300 << "-"<< rawmsg_50[j+300] << "/"; +// bcopy(&(raw_val.at(j+300)), &(arr[k]), 1); + bcopy(&(rawmsg_50[j+300]), &(arr[k]), 1); + } + float volt; + + bcopy(&arr[0], &volt, 4); + DEBUG_STREAM <<"volt:"<< volt << endl; + grid_val = (double)volt; +#else + grid_val = rawmsg_10[3]; +#endif + + attr_GridVal_read = &grid_val; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_GridVal_read, taim, Tango::ATTR_VALID, 1,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_GunSafety +// +// description : Extract real attribute values for GunSafety acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_GunSafety(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_GunSafety(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<GUNSAFETY_DIM;j++){ +// gun_safety[j] = (Tango::DevBoolean)(values.at(pos_gun_safety[j])); + gun_safety[j] = msg_50[pos_gun_safety[j]]; + DEBUG_STREAM << "read values " << name_gun_safety[j]<< " val: "<< gun_safety[j]<<endl; + } + + attr_GunSafety_read = &gun_safety[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_GunSafety_read, taim, Tango::ATTR_VALID, GUNSAFETY_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_FilAbi +// +// description : Extract real attribute values for FilAbi acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_FilAbi(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_FilAbi(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<FILABI_DIM;j++){ +// fil_abi[j] = (Tango::DevBoolean)(values.at(pos_fil_abi[j])); + fil_abi[j] = msg_50[pos_fil_abi[j]]; + DEBUG_STREAM << "read values " << name_fil_abi[j]<< " val: "<< fil_abi[j]<<endl; + } + + attr_FilAbi_read = &fil_abi[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_FilAbi_read, taim, Tango::ATTR_VALID, FILABI_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_FilCurr +// +// description : Extract real attribute values for FilCurr acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_FilCurr(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_FilCurr(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<FILCURR_DIM;j++){ +// fil_curr[j] = (Tango::DevBoolean)(values.at(pos_fil_curr[j])); + fil_curr[j] = msg_50[pos_fil_curr[j]]; + DEBUG_STREAM << "read values " << name_fil_curr[j]<< " val: "<< fil_curr[j]<<endl; + } + + attr_FilCurr_read = &fil_curr[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_FilCurr_read, taim, Tango::ATTR_VALID, FILCURR_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_FilReady +// +// description : Extract real attribute values for FilReady acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_FilReady(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_FilReady(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<FILREADY_DIM;j++){ +// fil_ready[j] = (Tango::DevBoolean)(values.at(pos_fil_ready[j])); + fil_ready[j] = msg_50[pos_fil_ready[j]]; + DEBUG_STREAM << "read values " << name_fil_ready[j]<< " val: "<< fil_ready[j]<<endl; + } + + attr_FilReady_read = &fil_ready[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_FilReady_read, taim, Tango::ATTR_VALID, FILREADY_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_GunHv +// +// description : Extract real attribute values for GunHv acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_GunHv(Tango::Attribute &attr) +{ +/* DEBUG_STREAM << "IntlkGun::read_GunHv(Tango::Attribute &attr) entering... "<< endl; + vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<GUNHV_DIM;j++){ +// gun_hv[j] = (Tango::DevBoolean)(values.at(pos_gun_hv[j])); + gun_hv[j] = msg_50[pos_gun_hv[j]]; + DEBUG_STREAM << "read values " << name_gun_hv[j]<< " val: "<< gun_hv[j]<<endl; + } + + attr_GunHv_read = &gun_hv[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_GunHv_read, taim, Tango::ATTR_VALID, GUNHV_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::read_AbiTrigGun +// +// description : Extract real attribute values for AbiTrigGun acquisition result. +// +//----------------------------------------------------------------------------- +void IntlkGun::read_AbiTrigGun(Tango::Attribute &attr) +{ + DEBUG_STREAM << "IntlkGun::read_AbiTrigGun(Tango::Attribute &attr) entering... "<< endl; +/* vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<bool> values; + + attr_names.push_back("db_50"); + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> values; + delete devattr; +*/ + + for(int j=0;j<ABITRIGGUN_DIM;j++){ +// abi_trig_gun[j] = (Tango::DevBoolean)(values.at(pos_abi_trig_gun[j])); + abi_trig_gun[j] = msg_50[pos_abi_trig_gun[j]]; + DEBUG_STREAM << "read values " << name_abi_trig_gun[j]<< " val: "<< abi_trig_gun[j]<<endl; + } + + attr_AbiTrigGun_read = &abi_trig_gun[0]; + + timeval taim; + double fractpart, intpart; + + fractpart = modf (timestamp_50 , &intpart); + taim.tv_sec = (__time_t)intpart; + taim.tv_usec = (__suseconds_t)fractpart*1000000; + +// attr.set_value(attr_Db_50_read, MESG_50_LEN_B, 0, false); +// if(timestamp_50!=0){ + attr.set_value_date_quality(attr_AbiTrigGun_read, taim, Tango::ATTR_VALID, ABITRIGGUN_DIM,0,false); +// } +// else{ +// attr.set_value_date_quality(attr_Db_50_read, 0, Tango::ATTR_INVALID, 3,0,false); +// } +} + +//+---------------------------------------------------------------------------- +// +// method : match_labels(char* dbn) +// +// description : search labels +// +//----------------------------------------------------------------------------- +void IntlkGun::match_labels(const char* dbn) +{ + DEBUG_STREAM << "IntlkGun::match_labels(char* dbn) entering... "<< endl; + vector<Tango::DeviceAttribute> *devattr; + vector<string> attr_names; + vector<string> labels; + attr_names.push_back(dbn); + try { + devattr = devintlk->read_attributes(attr_names); + (*devattr)[0] >> labels; + delete devattr; + set_state(Tango::ON); + set_status("Connected to device " + intlk_srv); + DEBUG_STREAM << "IntlkGun::IntlkGun() Connected to devintlk:" << intlk_srv << endl; + } + catch(Tango::DevFailed e) { + set_state(Tango::FAULT); + set_status("Failed to connect to devintlk " + intlk_srv); + ERROR_STREAM <<"IntlkGun::IntlkGun() Failed to connect to devintlk " + intlk_srv << endl; + } +switch(dbn[8]){ + case '0': + if(labels.size()!=0){ + string cur_lab; + for(size_t j=0;j<labels.size();j++){ + cur_lab = (string)(labels.at(j)); + for(int k=0;k<GUNSAFETY_DIM;k++){ + if((cur_lab.find(GunSafetyMask[k]))!=string::npos)pos_gun_safety[k] = j; + } + for(int k=0;k<FILABI_DIM;k++){ + if((cur_lab.find(FilAbiMask[k]))!=string::npos)pos_fil_abi[k] = j; + } + for(int k=0;k<FILCURR_DIM;k++){ + if((cur_lab.find(FilCurrMask[k]))!=string::npos)pos_fil_curr[k] = j; + } + for(int k=0;k<FILREADY_DIM;k++){ + if((cur_lab.find(FilReadyMask[k]))!=string::npos)pos_fil_ready[k] = j; + } + for(int k=0;k<GUNHV_DIM;k++){ + if((cur_lab.find(GunHVMask[k]))!=string::npos)pos_gun_hv[k] = j; + } + for(int k=0;k<ABITRIGGUN_DIM;k++){ + if((cur_lab.find(AbiTrigGunMask[k]))!=string::npos)pos_abi_trig_gun[k] = j; + } + } + // if names of the signal don't correspond + bool found_err = false; + for(int k=0;k<GUNSAFETY_DIM;k++){ + if(pos_gun_safety[k] == -1){ + ERROR_STREAM << "not found pos gun_safety: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILABI_DIM;k++){ + if(pos_fil_abi[k] == -1){ + ERROR_STREAM << "not found pos fil_abi: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILCURR_DIM;k++){ + if(pos_fil_curr[k] == -1){ + ERROR_STREAM << "not found pos fil_curr: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILREADY_DIM;k++){ + if(pos_fil_ready[k] == -1){ + ERROR_STREAM << "not found pos fil_ready: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<GUNHV_DIM;k++){ + if(pos_gun_hv[k] == -1){ + ERROR_STREAM << "not found pos gun_hv: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<ABITRIGGUN_DIM;k++){ + if(pos_abi_trig_gun[k] == -1){ + ERROR_STREAM << "not found pos abi_trig_gun: " << k<< endl; + found_err = true; + } + } + if(found_err){ + ERROR_STREAM << "signal names not corresponding db 50" << endl; + set_state(Tango::FAULT); + set_status("signal names not corresponding "); + } + } + break; + case '3': + if(labels.size()!=0){ + string cur_lab; + for(size_t j=0;j<labels.size();j++){ + cur_lab = (string)(labels.at(j)); + for(int k=0;k<GUNSAFETY_DIM;k++){ + if((cur_lab.find(GunSafetyMask[k]))!=string::npos)pos_alm_gun_safety[k] = j; + } + for(int k=0;k<FILABI_DIM;k++){ + if((cur_lab.find(FilAbiMask[k]))!=string::npos)pos_alm_fil_abi[k] = j; + } + for(int k=0;k<FILCURR_DIM;k++){ + if((cur_lab.find(FilCurrMask[k]))!=string::npos)pos_alm_fil_curr[k] = j; + } + for(int k=0;k<FILREADY_DIM;k++){ + if((cur_lab.find(FilReadyMask[k]))!=string::npos)pos_alm_fil_ready[k] = j; + } + for(int k=0;k<GUNHV_DIM;k++){ + if((cur_lab.find(GunHVMask[k]))!=string::npos)pos_alm_gun_hv[k] = j; + } + } + // if names of the signal don't correspond + bool found_err = false; + for(int k=0;k<GUNSAFETY_DIM;k++){ + if(pos_alm_gun_safety[k] == -1){ + ERROR_STREAM << "not found pos alm_gun_safety: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILABI_DIM;k++){ + if((pos_alm_fil_abi[k] == -1)&&(k!=0)){ + ERROR_STREAM << "not found pos alm_fil_abi: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILCURR_DIM;k++){ + if((pos_alm_fil_curr[k] == -1)&&(k!=0)){ + ERROR_STREAM << "not found pos alm_fil_curr: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<FILREADY_DIM;k++){ + if((pos_alm_fil_ready[k] == -1)&&(k!=0)){ + ERROR_STREAM << "not found pos alm_fil_ready: " << k<< endl; + found_err = true; + } + } + for(int k=0;k<GUNHV_DIM;k++){ + if((pos_alm_gun_hv[k] == -1)&&(k!=0)){ + ERROR_STREAM << "not found pos alm_gun_hv: " << k<< endl; + found_err = true; + } + } + if(found_err){ + ERROR_STREAM<<"signal names not corresponding db 53"<<endl; + set_state(Tango::FAULT); + set_status("signal names not corresponding "); + } + } + break; +} + +} + + + +//+------------------------------------------------------------------ +/** + * method: IntlkGun::acknowledge_all + * + * description: method to execute "Acknowledge_all" + * + * + */ +//+------------------------------------------------------------------ +void IntlkGun::acknowledge_all() +{ + DEBUG_STREAM << "IntlkGun::acknowledge_all(): entering... !" << endl; + + // Add your own code to control device here + // Add your own code to control device here + Tango::DevVarLongArray indxs; +// indxs.svalue.length(0); + indxs.length(23); + int count = 0; + + for(int k=0;k<GUNSAFETY_DIM;k++){ + if(pos_alm_gun_safety[k] != -1){ + indxs[count] = pos_alm_gun_safety[k]; + count++; + } + } + for(int k=0;k<FILABI_DIM;k++){ + if((pos_alm_fil_abi[k] !=-1)&&(k!=0)){ + indxs[count] = pos_alm_fil_abi[k]; + count++; + } + } + for(int k=0;k<FILCURR_DIM;k++){ + if((pos_alm_fil_curr[k] != -1)&&(k!=0)){ + indxs[count] = pos_alm_fil_curr[k]; + count++; + } + } + for(int k=0;k<FILREADY_DIM;k++){ + if((pos_alm_fil_ready[k] != -1)&&(k!=0)){ + indxs[count] = pos_alm_fil_ready[k]; + count++; + } + } + for(int k=0;k<GUNHV_DIM;k++){ + if((pos_alm_gun_hv[k] != -1)&&(k!=0)){ + indxs[count] = pos_alm_gun_hv[k]; + count++; + } + } + for(int k=0;k<ABITRIGGUN_DIM;k++){ + if((pos_alm_abi_trig_gun[k] != -1)&&(k!=0)){ + indxs[count] = pos_alm_abi_trig_gun[k]; + count++; + } + } +//ack selected on all gun signals + DEBUG_STREAM << "ack to " <<count << " signals " << endl; + + Tango::DeviceData Din; + Din << indxs; + + try { +// devintlk->command_inout("Acknowledge_all"); + devintlk->command_inout("Ack_selected", Din); + set_state(Tango::ON); + set_status("command ack sent " ); + } + catch(Tango::DevFailed e) { + set_state(Tango::FAULT); + set_status("Cannot send command ack " ); + ERROR_STREAM << "Cannot send command ack" << endl; + } + + +} + +} // namespace diff --git a/src/IntlkGun.h b/src/IntlkGun.h new file mode 100644 index 0000000000000000000000000000000000000000..6358e3eba30c6d89a76de33f0a8b0542b9191a87 --- /dev/null +++ b/src/IntlkGun.h @@ -0,0 +1,447 @@ +//============================================================================= +// +// file : IntlkGun.h +// +// description : Include for the IntlkGun class. +// +// project : +// +// $Author: graziano $ +// +// $Revision: 1.8 $ +// +// $Log: IntlkGun.h,v $ +// Revision 1.8 2019-01-07 15:21:34 graziano +// fixed for upgrade of plc interlock booster +// +// Revision 1.7 2017-03-30 11:34:28 claudio +// ticket 1934 porting to tango-9 +// +// Revision 1.6 2013-08-26 10:35:52 claudio +// Device_4Impl for tango-8 +// +// Revision 1.5 2008-08-11 10:29:15 sara +// cached attributes +// +// Revision 1.4 2008/03/31 14:43:07 sara +// updated signal names +// +// Revision 1.3 2008/03/20 10:57:12 sara +// Changed signals access control 1 and 2 to single signal CONTROLLO_ACCESSI +// +// Revision 1.2 2008/02/01 14:20:21 sara +// added RealFilTimer attribute for gun current timer bar +// +// Revision 1.1.1.1 2007/08/31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= +#ifndef _INTLKGUN_H +#define _INTLKGUN_H + +#include <tango.h> +#include <math.h> +#include <stdlib.h> +#include <sys/time.h> +//using namespace Tango; + +/** + * @author $Author: graziano $ + * @version $Revision: 1.8 $ + */ + + // Add your own constants definitions here. + //----------------------------------------------- + + +namespace IntlkGun_ns +{ +//number of bits in the message from low level interlock server (attr db_50) +#define MESG_50_LEN_B 3200 +//size of db53 in bit (attr rt_db_53) +#define MESG_53_LEN_B 3200 +//size of raw_msg_50 +#define RAW_MSG_50_LEN 410 +//size of raw_msg_10 +#define RAW_MSG_10_LEN 26 + +//attribute cache refresh period in us +#define RFSH_CACHE 1000000 + +//length of attributes in bit +#define GUNSAFETY_DIM 8 +#define FILABI_DIM 2 +#define FILCURR_DIM 1 +#define FILREADY_DIM 6 +#define GUNHV_DIM 10 +#define ABITRIGGUN_DIM 1 + +/** + * Class Description: + * + */ + +/* + * Device States Description: +* Tango::ON : +* Tango::FAULT : + */ + + +class IntlkGun: public TANGO_BASE_CLASS +{ +public : + // Add your own data members here + //----------------------------------------- + + + // Here is the Start of the automatic code generation part + //------------------------------------------------------------- +/** + * @name attributes + * Attributs member data. + */ +//@{ + Tango::DevDouble *attr_CurrFilVal_read; + Tango::DevDouble *attr_GridVal_read; + Tango::DevUShort *attr_FilTimer_read; + Tango::DevFloat *attr_RealFilTimer_read; + Tango::DevBoolean *attr_GunSafety_read; + Tango::DevBoolean *attr_FilAbi_read; + Tango::DevBoolean *attr_FilCurr_read; + Tango::DevBoolean *attr_FilReady_read; + Tango::DevBoolean *attr_GunHv_read; + Tango::DevBoolean *attr_AbiTrigGun_read; + Tango::DevBoolean *attr_AlmGunSafety_read; + Tango::DevBoolean attr_AlmGunSafety_write; + Tango::DevBoolean *attr_AlmFilAbi_read; + Tango::DevBoolean attr_AlmFilAbi_write; + Tango::DevBoolean *attr_AlmFilCurr_read; + Tango::DevBoolean attr_AlmFilCurr_write; + Tango::DevBoolean *attr_AlmFilReady_read; + Tango::DevBoolean attr_AlmFilReady_write; + Tango::DevBoolean *attr_AlmGunHV_read; + Tango::DevBoolean attr_AlmGunHV_write; + Tango::DevBoolean *attr_AlmAbiTrigGun_read; +//@} + +/** + * @name Device properties + * Device properties member data. + */ +//@{ +/** + * + */ + string intlk_srv; +//@} + +/**@name Constructors + * Miscellaneous constructors */ +//@{ +/** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + IntlkGun(Tango::DeviceClass *cl,string &s); +/** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device Name + */ + IntlkGun(Tango::DeviceClass *cl,const char *s); +/** + * Constructs a newly allocated Command object. + * + * @param cl Class. + * @param s Device name + * @param d Device description. + */ + IntlkGun(Tango::DeviceClass *cl,const char *s,const char *d); +//@} + +/**@name Destructor + * Only one desctructor is defined for this class */ +//@{ +/** + * The object desctructor. + */ + ~IntlkGun() {delete_device();}; +/** + * will be called at device destruction or at init command. + */ + void delete_device(); +//@} + + +/**@name Miscellaneous methods */ +//@{ +/** + * Initialize the device + */ + virtual void init_device(); +/** + * Always executed method befor execution command method. + */ + virtual void always_executed_hook(); + +//@} + +/** + * @name IntlkGun methods prototypes + */ + +//@{ +/** + * Hardware acquisition for attributes. + */ + virtual void read_attr_hardware(vector<long> &attr_list); +/** + * Extract real attribute values for CurrFilVal acquisition result. + */ + virtual void read_CurrFilVal(Tango::Attribute &attr); +/** + * Extract real attribute values for GridVal acquisition result. + */ + virtual void read_GridVal(Tango::Attribute &attr); +/** + * Extract real attribute values for FilTimer acquisition result. + */ + virtual void read_FilTimer(Tango::Attribute &attr); +/** + * Extract real attribute values for RealFilTimer acquisition result. + */ + virtual void read_RealFilTimer(Tango::Attribute &attr); +/** + * Extract real attribute values for GunSafety acquisition result. + */ + virtual void read_GunSafety(Tango::Attribute &attr); +/** + * Extract real attribute values for FilAbi acquisition result. + */ + virtual void read_FilAbi(Tango::Attribute &attr); +/** + * Extract real attribute values for FilCurr acquisition result. + */ + virtual void read_FilCurr(Tango::Attribute &attr); +/** + * Extract real attribute values for FilReady acquisition result. + */ + virtual void read_FilReady(Tango::Attribute &attr); +/** + * Extract real attribute values for GunHv acquisition result. + */ + virtual void read_GunHv(Tango::Attribute &attr); +/** + * Extract real attribute values for AbiTrigGun acquisition result. + */ + virtual void read_AbiTrigGun(Tango::Attribute &attr); +/** + * Extract real attribute values for AlmGunSafety acquisition result. + */ + virtual void read_AlmGunSafety(Tango::Attribute &attr); +/** + * Write AlmGunSafety attribute values to hardware. + */ + virtual void write_AlmGunSafety(Tango::WAttribute &attr); +/** + * Extract real attribute values for AlmFilAbi acquisition result. + */ + virtual void read_AlmFilAbi(Tango::Attribute &attr); +/** + * Write AlmFilAbi attribute values to hardware. + */ + virtual void write_AlmFilAbi(Tango::WAttribute &attr); +/** + * Extract real attribute values for AlmFilCurr acquisition result. + */ + virtual void read_AlmFilCurr(Tango::Attribute &attr); +/** + * Write AlmFilCurr attribute values to hardware. + */ + virtual void write_AlmFilCurr(Tango::WAttribute &attr); +/** + * Extract real attribute values for AlmFilReady acquisition result. + */ + virtual void read_AlmFilReady(Tango::Attribute &attr); +/** + * Write AlmFilReady attribute values to hardware. + */ + virtual void write_AlmFilReady(Tango::WAttribute &attr); +/** + * Extract real attribute values for AlmGunHV acquisition result. + */ + virtual void read_AlmGunHV(Tango::Attribute &attr); +/** + * Write AlmGunHV attribute values to hardware. + */ + virtual void write_AlmGunHV(Tango::WAttribute &attr); +/** + * Extract real attribute values for AlmAbiTrigGun acquisition result. + */ + virtual void read_AlmAbiTrigGun(Tango::Attribute &attr); +/** + * Read/Write allowed for CurrFilVal attribute. + */ + virtual bool is_CurrFilVal_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for GridVal attribute. + */ + virtual bool is_GridVal_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for FilTimer attribute. + */ + virtual bool is_FilTimer_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for RealFilTimer attribute. + */ + virtual bool is_RealFilTimer_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for GunSafety attribute. + */ + virtual bool is_GunSafety_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for FilAbi attribute. + */ + virtual bool is_FilAbi_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for FilCurr attribute. + */ + virtual bool is_FilCurr_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for FilReady attribute. + */ + virtual bool is_FilReady_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for GunHv attribute. + */ + virtual bool is_GunHv_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AbiTrigGun attribute. + */ + virtual bool is_AbiTrigGun_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmGunSafety attribute. + */ + virtual bool is_AlmGunSafety_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmFilAbi attribute. + */ + virtual bool is_AlmFilAbi_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmFilCurr attribute. + */ + virtual bool is_AlmFilCurr_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmFilReady attribute. + */ + virtual bool is_AlmFilReady_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmGunHV attribute. + */ + virtual bool is_AlmGunHV_allowed(Tango::AttReqType type); +/** + * Read/Write allowed for AlmAbiTrigGun attribute. + */ + virtual bool is_AlmAbiTrigGun_allowed(Tango::AttReqType type); +/** + * Execution allowed for Acknowledge_all command. + */ + virtual bool is_Acknowledge_all_allowed(const CORBA::Any &any); +/** + * + * @exception DevFailed + */ + void acknowledge_all(); + +/** + * Read the device properties from database + */ + void get_device_property(); +//@} + + // Here is the end of the automatic code generation part + //------------------------------------------------------------- + + + +protected : + // Add your own data members here + //----------------------------------------- + Tango::DeviceProxy *devintlk; + Tango::DevBoolean msg_50[MESG_50_LEN_B]; + Tango::DevBoolean msg_53[MESG_53_LEN_B]; +// Tango::DevShort rawmsg_50[RAW_MSG_50_LEN]; + Tango::DevDouble rawmsg_10[RAW_MSG_10_LEN]; + + Tango::DevBoolean gun_safety[GUNSAFETY_DIM]; + short int pos_gun_safety[GUNSAFETY_DIM]; + Tango::DevString name_gun_safety[GUNSAFETY_DIM]; + Tango::DevBoolean alm_gun_safety[GUNSAFETY_DIM]; + short int pos_alm_gun_safety[GUNSAFETY_DIM]; + Tango::DevString name_alm_gun_safety[GUNSAFETY_DIM]; + + Tango::DevBoolean fil_abi[FILABI_DIM]; + short int pos_fil_abi[FILABI_DIM]; + Tango::DevString name_fil_abi[FILABI_DIM]; + Tango::DevBoolean alm_fil_abi[FILABI_DIM]; + short int pos_alm_fil_abi[FILABI_DIM]; + Tango::DevString name_alm_fil_abi[FILABI_DIM]; + + Tango::DevBoolean fil_curr[FILCURR_DIM]; + short int pos_fil_curr[FILCURR_DIM]; + Tango::DevString name_fil_curr[FILCURR_DIM]; + Tango::DevBoolean alm_fil_curr[FILCURR_DIM]; + short int pos_alm_fil_curr[FILCURR_DIM]; + Tango::DevString name_alm_fil_curr[FILCURR_DIM]; + + Tango::DevBoolean fil_ready[FILREADY_DIM]; + short int pos_fil_ready[FILREADY_DIM]; + Tango::DevString name_fil_ready[FILREADY_DIM]; + Tango::DevBoolean alm_fil_ready[FILREADY_DIM]; + short int pos_alm_fil_ready[FILREADY_DIM]; + Tango::DevString name_alm_fil_ready[FILREADY_DIM]; + + Tango::DevBoolean gun_hv[GUNHV_DIM]; + short int pos_gun_hv[GUNHV_DIM]; + Tango::DevString name_gun_hv[GUNHV_DIM]; + Tango::DevBoolean alm_gun_hv[GUNHV_DIM]; + short int pos_alm_gun_hv[GUNHV_DIM]; + Tango::DevString name_alm_gun_hv[GUNHV_DIM]; + + Tango::DevBoolean abi_trig_gun[ABITRIGGUN_DIM]; + short int pos_abi_trig_gun[ABITRIGGUN_DIM]; + Tango::DevString name_abi_trig_gun[ABITRIGGUN_DIM]; + Tango::DevBoolean alm_abi_trig_gun[ABITRIGGUN_DIM]; + short int pos_alm_abi_trig_gun[ABITRIGGUN_DIM]; + Tango::DevString name_alm_abi_trig_gun[ABITRIGGUN_DIM]; + + Tango::DevDouble curr_fil_val; + Tango::DevDouble grid_val; + Tango::DevUShort fil_timer; + Tango::DevFloat real_fil_timer; + + double timestamp_50; + double timestamp_53; + + void match_labels(const char* dbn); + struct timeval last_cache_update; +}; + +} // namespace_ns + +#endif // _INTLKGUN_H diff --git a/src/IntlkGunClass.cpp b/src/IntlkGunClass.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a85ab5c25529f138fd2626ff186b7f03fced969 --- /dev/null +++ b/src/IntlkGunClass.cpp @@ -0,0 +1,503 @@ +static const char *RcsId = "$Header: /home/cvsadm/cvsroot/booster/servers/interlock/gunintlk/src/IntlkGunClass.cpp,v 1.4 2017-07-31 12:16:45 claudio Exp $"; +static const char *TagName = "$Name: $"; +static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/"; +//+============================================================================= +// +// file : IntlkGunClass.cpp +// +// description : C++ source for the IntlkGunClass. A singleton +// class derived from DeviceClass. It implements the +// command list and all properties and methods required +// by the IntlkGun once per process. +// +// project : TANGO Device Server +// +// $Author: claudio $ +// +// $Revision: 1.4 $ +// +// $Log: IntlkGunClass.cpp,v $ +// Revision 1.4 2017-07-31 12:16:45 claudio +// ticket #1554: porting to tango-9.2.5.a/QTANGO_BASE_CLASS +// +// Revision 1.3 2013-08-26 10:35:52 claudio +// Device_4Impl for tango-8 +// +// Revision 1.2 2008-02-01 14:20:21 sara +// added RealFilTimer attribute for gun current timer bar +// +// Revision 1.1.1.1 2007/08/31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + + +#include <tango.h> + +#include <IntlkGun.h> +#include <IntlkGunClass.h> + + +//+---------------------------------------------------------------------------- +/** + * Create IntlkGunClass singleton and return it in a C function for Python usage + */ +//+---------------------------------------------------------------------------- +extern "C" { +#ifdef WIN32 + +__declspec(dllexport) + +#endif + + Tango::DeviceClass *_create_IntlkGun_class(const char *name) { + return IntlkGun_ns::IntlkGunClass::init(name); + } +} + + +namespace IntlkGun_ns +{ +//+---------------------------------------------------------------------------- +// +// method : Acknowledge_allClass::execute() +// +// description : method to trigger the execution of the command. +// PLEASE DO NOT MODIFY this method core without pogo +// +// in : - device : The device on which the command must be excuted +// - in_any : The command input data +// +// returns : The command output data (packed in the Any object) +// +//----------------------------------------------------------------------------- +CORBA::Any *Acknowledge_allClass::execute(Tango::DeviceImpl *device,const CORBA::Any &in_any) +{ + + cout2 << "Acknowledge_allClass::execute(): arrived" << endl; + + ((static_cast<IntlkGun *>(device))->acknowledge_all()); + return new CORBA::Any(); +} + + + +// +//---------------------------------------------------------------- +// Initialize pointer for singleton pattern +//---------------------------------------------------------------- +// +IntlkGunClass *IntlkGunClass::_instance = NULL; + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::IntlkGunClass(string &s) +// +// description : constructor for the IntlkGunClass +// +// in : - s : The class name +// +//----------------------------------------------------------------------------- +IntlkGunClass::IntlkGunClass(string &s):DeviceClass(s) +{ + + cout2 << "Entering IntlkGunClass constructor" << endl; + set_default_property(); + get_class_property(); + write_class_property(); + + cout2 << "Leaving IntlkGunClass constructor" << endl; + +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::~IntlkGunClass() +// +// description : destructor for the IntlkGunClass +// +//----------------------------------------------------------------------------- +IntlkGunClass::~IntlkGunClass() +{ + _instance = NULL; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::instance +// +// description : Create the object if not already done. Otherwise, just +// return a pointer to the object +// +// in : - name : The class name +// +//----------------------------------------------------------------------------- +IntlkGunClass *IntlkGunClass::init(const char *name) +{ + if (_instance == NULL) + { + try + { + string s(name); + _instance = new IntlkGunClass(s); + } + catch (bad_alloc) + { + throw; + } + } + return _instance; +} + +IntlkGunClass *IntlkGunClass::instance() +{ + if (_instance == NULL) + { + cerr << "Class is not initialised !!" << endl; + exit(-1); + } + return _instance; +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::command_factory +// +// description : Create the command object(s) and store them in the +// command list +// +//----------------------------------------------------------------------------- +void IntlkGunClass::command_factory() +{ + command_list.push_back(new Acknowledge_allClass("Acknowledge_all", + Tango::DEV_VOID, Tango::DEV_VOID, + "", + "", + Tango::OPERATOR)); + + // add polling if any + for (unsigned int i=0 ; i<command_list.size(); i++) + { + } +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::get_class_property +// +// description : Get the class property for specified name. +// +// in : string name : The property name +// +//+---------------------------------------------------------------------------- +Tango::DbDatum IntlkGunClass::get_class_property(string &prop_name) +{ + for (unsigned int i=0 ; i<cl_prop.size() ; i++) + if (cl_prop[i].name == prop_name) + return cl_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::get_default_device_property() +// +// description : Return the default value for device property. +// +//----------------------------------------------------------------------------- +Tango::DbDatum IntlkGunClass::get_default_device_property(string &prop_name) +{ + for (unsigned int i=0 ; i<dev_def_prop.size() ; i++) + if (dev_def_prop[i].name == prop_name) + return dev_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::get_default_class_property() +// +// description : Return the default value for class property. +// +//----------------------------------------------------------------------------- +Tango::DbDatum IntlkGunClass::get_default_class_property(string &prop_name) +{ + for (unsigned int i=0 ; i<cl_def_prop.size() ; i++) + if (cl_def_prop[i].name == prop_name) + return cl_def_prop[i]; + // if not found, return an empty DbDatum + return Tango::DbDatum(prop_name); +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::device_factory +// +// description : Create the device object(s) and store them in the +// device list +// +// in : Tango::DevVarStringArray *devlist_ptr : The device name list +// +//----------------------------------------------------------------------------- +void IntlkGunClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) +{ + + // Create all devices.(Automatic code generation) + //------------------------------------------------------------- + for (unsigned long i=0 ; i < devlist_ptr->length() ; i++) + { + cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; + + // Create devices and add it into the device list + //---------------------------------------------------- + device_list.push_back(new IntlkGun(this, (*devlist_ptr)[i])); + + // Export device to the outside world + // Check before if database used. + //--------------------------------------------- + if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) + export_device(device_list.back()); + else + export_device(device_list.back(), (*devlist_ptr)[i]); + } + // End of Automatic code generation + //------------------------------------------------------------- + +} +//+---------------------------------------------------------------------------- +// Method: IntlkGunClass::attribute_factory(vector<Tango::Attr *> &att_list) +//----------------------------------------------------------------------------- +void IntlkGunClass::attribute_factory(vector<Tango::Attr *> &att_list) +{ + // Attribute : CurrFilVal + CurrFilValAttrib *curr_fil_val = new CurrFilValAttrib(); + att_list.push_back(curr_fil_val); + + // Attribute : GridVal + GridValAttrib *grid_val = new GridValAttrib(); + att_list.push_back(grid_val); + + // Attribute : FilTimer + FilTimerAttrib *fil_timer = new FilTimerAttrib(); + att_list.push_back(fil_timer); + + // Attribute : RealFilTimer + RealFilTimerAttrib *real_fil_timer = new RealFilTimerAttrib(); + att_list.push_back(real_fil_timer); + + // Attribute : GunSafety + GunSafetyAttrib *gun_safety = new GunSafetyAttrib(); + att_list.push_back(gun_safety); + + // Attribute : FilAbi + FilAbiAttrib *fil_abi = new FilAbiAttrib(); + att_list.push_back(fil_abi); + + // Attribute : FilCurr + FilCurrAttrib *fil_curr = new FilCurrAttrib(); + att_list.push_back(fil_curr); + + // Attribute : FilReady + FilReadyAttrib *fil_ready = new FilReadyAttrib(); + att_list.push_back(fil_ready); + + // Attribute : GunHv + GunHvAttrib *gun_hv = new GunHvAttrib(); + att_list.push_back(gun_hv); + + // Attribute : AbiTrigGun + AbiTrigGunAttrib *abi_trig_gun = new AbiTrigGunAttrib(); + att_list.push_back(abi_trig_gun); + + // Attribute : AlmGunSafety + AlmGunSafetyAttrib *alm_gun_safety = new AlmGunSafetyAttrib(); + att_list.push_back(alm_gun_safety); + + // Attribute : AlmFilAbi + AlmFilAbiAttrib *alm_fil_abi = new AlmFilAbiAttrib(); + att_list.push_back(alm_fil_abi); + + // Attribute : AlmFilCurr + AlmFilCurrAttrib *alm_fil_curr = new AlmFilCurrAttrib(); + att_list.push_back(alm_fil_curr); + + // Attribute : AlmFilReady + AlmFilReadyAttrib *alm_fil_ready = new AlmFilReadyAttrib(); + att_list.push_back(alm_fil_ready); + + // Attribute : AlmGunHV + AlmGunHVAttrib *alm_gun_hv = new AlmGunHVAttrib(); + att_list.push_back(alm_gun_hv); + + // Attribute : AlmAbiTrigGun + AlmAbiTrigGunAttrib *alm_abi_trig_gun = new AlmAbiTrigGunAttrib(); + att_list.push_back(alm_abi_trig_gun); + + // End of Automatic code generation + //------------------------------------------------------------- +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::get_class_property() +// +// description : Read the class properties from database. +// +//----------------------------------------------------------------------------- +void IntlkGunClass::get_class_property() +{ + // Initialize your default values here (if not done with POGO). + //------------------------------------------------------------------ + + // Read class properties from database.(Automatic code generation) + //------------------------------------------------------------------ + + // Call database and extract values + //-------------------------------------------- + if (Tango::Util::instance()->_UseDb==true) + get_db_class()->get_property(cl_prop); + Tango::DbDatum def_prop; + int i = -1; + + + // End of Automatic code generation + //------------------------------------------------------------------ + +} + +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::set_default_property +// +// description: Set default property (class and device) for wizard. +// For each property, add to wizard property name and description +// If default value has been set, add it to wizard property and +// store it in a DbDatum. +// +//----------------------------------------------------------------------------- +void IntlkGunClass::set_default_property() +{ + string prop_name; + string prop_desc; + string prop_def; + + vector<string> vect_data; + // Set Default Class Properties + // Set Default Device Properties + prop_name = "Intlk_srv"; + prop_desc = ""; + prop_def = ""; + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); + +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGunClass::write_class_property +// +// description : Set class description as property in database +// +//----------------------------------------------------------------------------- +void IntlkGunClass::write_class_property() +{ + // First time, check if database used + //-------------------------------------------- + if (Tango::Util::_UseDb == false) + return; + + Tango::DbData data; + string classname = get_name(); + string header; + string::size_type start, end; + + // Put title + Tango::DbDatum title("ProjectTitle"); + string str_title(""); + title << str_title; + data.push_back(title); + + // Put Description + Tango::DbDatum description("Description"); + vector<string> str_desc; + str_desc.push_back(" "); + description << str_desc; + data.push_back(description); + + // put cvs location + string rcsId(RcsId); + string filename(classname); + start = rcsId.find("/"); + if (start!=string::npos) + { + filename += "Class.cpp"; + end = rcsId.find(filename); + if (end>start) + { + string strloc = rcsId.substr(start, end-start); + // Check if specific repository + start = strloc.find("/cvsroot/"); + if (start!=string::npos && start>0) + { + string repository = strloc.substr(0, start); + if (repository.find("/segfs/")!=string::npos) + strloc = "ESRF:" + strloc.substr(start, strloc.length()-start); + } + Tango::DbDatum cvs_loc("cvs_location"); + cvs_loc << strloc; + data.push_back(cvs_loc); + } + } + + // Get CVS tag revision + string tagname(TagName); + header = "$Name: "; + start = header.length(); + string endstr(" $"); + end = tagname.find(endstr); + if (end!=string::npos && end>start) + { + string strtag = tagname.substr(start, end-start); + Tango::DbDatum cvs_tag("cvs_tag"); + cvs_tag << strtag; + data.push_back(cvs_tag); + } + + // Get URL location + string httpServ(HttpServer); + if (httpServ.length()>0) + { + Tango::DbDatum db_doc_url("doc_url"); + db_doc_url << httpServ; + data.push_back(db_doc_url); + } + + // Put inheritance + Tango::DbDatum inher_datum("InheritedFrom"); + vector<string> inheritance; + inheritance.push_back("Device_4Impl"); + inher_datum << inheritance; + data.push_back(inher_datum); + + // Call database and and values + //-------------------------------------------- + get_db_class()->put_property(data); +} + +} // namespace diff --git a/src/IntlkGunClass.h b/src/IntlkGunClass.h new file mode 100644 index 0000000000000000000000000000000000000000..6f683b254be9f4af7da393a607fd667874cd891d --- /dev/null +++ b/src/IntlkGunClass.h @@ -0,0 +1,318 @@ +//============================================================================= +// +// file : IntlkGunClass.h +// +// description : Include for the IntlkGunClass root class. +// This class is represents the singleton class for +// the IntlkGun device class. +// It contains all properties and methods which the +// IntlkGun requires only once e.g. the commands. +// +// project : TANGO Device Server +// +// $Author: sara $ +// +// $Revision: 1.2 $ +// +// $Log: IntlkGunClass.h,v $ +// Revision 1.2 2008-02-01 14:20:21 sara +// added RealFilTimer attribute for gun current timer bar +// +// Revision 1.1.1.1 2007/08/31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + +#ifndef _INTLKGUNCLASS_H +#define _INTLKGUNCLASS_H + +#include <tango.h> +#include <IntlkGun.h> + + +namespace IntlkGun_ns +{//===================================== +// Define classes for attributes +//===================================== +class AlmAbiTrigGunAttrib: public Tango::SpectrumAttr +{ +public: + AlmAbiTrigGunAttrib():SpectrumAttr("AlmAbiTrigGun", Tango::DEV_BOOLEAN, Tango::READ, 1) {}; + ~AlmAbiTrigGunAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmAbiTrigGun(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmAbiTrigGun_allowed(ty);} +}; + +class AlmGunHVAttrib: public Tango::SpectrumAttr +{ +public: + AlmGunHVAttrib():SpectrumAttr("AlmGunHV", Tango::DEV_BOOLEAN, Tango::READ_WRITE, 10) {}; + ~AlmGunHVAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmGunHV(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<IntlkGun *>(dev))->write_AlmGunHV(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmGunHV_allowed(ty);} +}; + +class AlmFilReadyAttrib: public Tango::SpectrumAttr +{ +public: + AlmFilReadyAttrib():SpectrumAttr("AlmFilReady", Tango::DEV_BOOLEAN, Tango::READ_WRITE, 6) {}; + ~AlmFilReadyAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmFilReady(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<IntlkGun *>(dev))->write_AlmFilReady(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmFilReady_allowed(ty);} +}; + +class AlmFilCurrAttrib: public Tango::SpectrumAttr +{ +public: + AlmFilCurrAttrib():SpectrumAttr("AlmFilCurr", Tango::DEV_BOOLEAN, Tango::READ_WRITE, 1) {}; + ~AlmFilCurrAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmFilCurr(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<IntlkGun *>(dev))->write_AlmFilCurr(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmFilCurr_allowed(ty);} +}; + +class AlmFilAbiAttrib: public Tango::SpectrumAttr +{ +public: + AlmFilAbiAttrib():SpectrumAttr("AlmFilAbi", Tango::DEV_BOOLEAN, Tango::READ_WRITE, 2) {}; + ~AlmFilAbiAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmFilAbi(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<IntlkGun *>(dev))->write_AlmFilAbi(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmFilAbi_allowed(ty);} +}; + +class AlmGunSafetyAttrib: public Tango::SpectrumAttr +{ +public: + AlmGunSafetyAttrib():SpectrumAttr("AlmGunSafety", Tango::DEV_BOOLEAN, Tango::READ_WRITE, 8) {}; + ~AlmGunSafetyAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AlmGunSafety(att);} + virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att) + {(static_cast<IntlkGun *>(dev))->write_AlmGunSafety(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AlmGunSafety_allowed(ty);} +}; + +class AbiTrigGunAttrib: public Tango::SpectrumAttr +{ +public: + AbiTrigGunAttrib():SpectrumAttr("AbiTrigGun", Tango::DEV_BOOLEAN, Tango::READ, 1) {}; + ~AbiTrigGunAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_AbiTrigGun(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_AbiTrigGun_allowed(ty);} +}; + +class GunHvAttrib: public Tango::SpectrumAttr +{ +public: + GunHvAttrib():SpectrumAttr("GunHv", Tango::DEV_BOOLEAN, Tango::READ, 10) {}; + ~GunHvAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_GunHv(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_GunHv_allowed(ty);} +}; + +class FilReadyAttrib: public Tango::SpectrumAttr +{ +public: + FilReadyAttrib():SpectrumAttr("FilReady", Tango::DEV_BOOLEAN, Tango::READ, 6) {}; + ~FilReadyAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_FilReady(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_FilReady_allowed(ty);} +}; + +class FilCurrAttrib: public Tango::SpectrumAttr +{ +public: + FilCurrAttrib():SpectrumAttr("FilCurr", Tango::DEV_BOOLEAN, Tango::READ, 2) {}; + ~FilCurrAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_FilCurr(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_FilCurr_allowed(ty);} +}; + +class FilAbiAttrib: public Tango::SpectrumAttr +{ +public: + FilAbiAttrib():SpectrumAttr("FilAbi", Tango::DEV_BOOLEAN, Tango::READ, 2) {}; + ~FilAbiAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_FilAbi(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_FilAbi_allowed(ty);} +}; + +class GunSafetyAttrib: public Tango::SpectrumAttr +{ +public: + GunSafetyAttrib():SpectrumAttr("GunSafety", Tango::DEV_BOOLEAN, Tango::READ, 8) {}; + ~GunSafetyAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_GunSafety(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_GunSafety_allowed(ty);} +}; + +class RealFilTimerAttrib: public Tango::Attr +{ +public: + RealFilTimerAttrib():Attr("RealFilTimer", Tango::DEV_FLOAT, Tango::READ) {}; + ~RealFilTimerAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_RealFilTimer(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_RealFilTimer_allowed(ty);} +}; + +class FilTimerAttrib: public Tango::Attr +{ +public: + FilTimerAttrib():Attr("FilTimer", Tango::DEV_USHORT, Tango::READ) {}; + ~FilTimerAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_FilTimer(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_FilTimer_allowed(ty);} +}; + +class GridValAttrib: public Tango::Attr +{ +public: + GridValAttrib():Attr("GridVal", Tango::DEV_DOUBLE, Tango::READ) {}; + ~GridValAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_GridVal(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_GridVal_allowed(ty);} +}; + +class CurrFilValAttrib: public Tango::Attr +{ +public: + CurrFilValAttrib():Attr("CurrFilVal", Tango::DEV_DOUBLE, Tango::READ) {}; + ~CurrFilValAttrib() {}; + + virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att) + {(static_cast<IntlkGun *>(dev))->read_CurrFilVal(att);} + virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty) + {return (static_cast<IntlkGun *>(dev))->is_CurrFilVal_allowed(ty);} +}; + +//========================================= +// Define classes for commands +//========================================= +class Acknowledge_allClass : public Tango::Command +{ +public: + Acknowledge_allClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out, + const char *in_desc, + const char *out_desc, + Tango::DispLevel level) + :Command(name,in,out,in_desc,out_desc, level) {}; + + Acknowledge_allClass(const char *name, + Tango::CmdArgType in, + Tango::CmdArgType out) + :Command(name,in,out) {}; + ~Acknowledge_allClass() {}; + + virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any); + virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any) + {return (static_cast<IntlkGun *>(dev))->is_Acknowledge_all_allowed(any);} +}; + + + +// +// The IntlkGunClass singleton definition +// + +class IntlkGunClass : public Tango::DeviceClass +{ +public: +// properties member data + +// add your own data members here +//------------------------------------ + +public: + Tango::DbData cl_prop; + Tango::DbData cl_def_prop; + Tango::DbData dev_def_prop; + +// Method prototypes + static IntlkGunClass *init(const char *); + static IntlkGunClass *instance(); + ~IntlkGunClass(); + Tango::DbDatum get_class_property(string &); + Tango::DbDatum get_default_device_property(string &); + Tango::DbDatum get_default_class_property(string &); + +protected: + IntlkGunClass(string &); + static IntlkGunClass *_instance; + void command_factory(); + void get_class_property(); + void attribute_factory(vector<Tango::Attr *> &); + void write_class_property(); + void set_default_property(); + +private: + void device_factory(const Tango::DevVarStringArray *); +}; + + +} // namespace IntlkGun_ns + +#endif // _INTLKGUNCLASS_H diff --git a/src/IntlkGunStateMachine.cpp b/src/IntlkGunStateMachine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4105862c22557a34449d7811bf291b40385b2672 --- /dev/null +++ b/src/IntlkGunStateMachine.cpp @@ -0,0 +1,300 @@ +//+============================================================================= +// +// file : IntlkGunStateMachine.cpp +// +// description : C++ source for the IntlkGun and its alowed. +// method for commands and attributes +// +// project : TANGO Device Server +// +// $Author: sara $ +// +// $Revision: 1.2 $ +// +// $Log: IntlkGunStateMachine.cpp,v $ +// Revision 1.2 2008-02-01 14:20:21 sara +// added RealFilTimer attribute for gun current timer bar +// +// Revision 1.1.1.1 2007/08/31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + +#include <tango.h> +#include <IntlkGun.h> +#include <IntlkGunClass.h> + +/*==================================================================== + * This file contains the methods to allow commands and attributes + * read or write execution. + * + * If you wand to add your own code, add it between + * the "End/Re-Start of Generated Code" comments. + * + * If you want, you can also add your own methods. + *==================================================================== + */ + +namespace IntlkGun_ns +{ + +//================================================= +// Attributes Allowed Methods +//================================================= + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_CurrFilVal_allowed +// +// description : Read/Write allowed for CurrFilVal attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_CurrFilVal_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_GridVal_allowed +// +// description : Read/Write allowed for GridVal attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_GridVal_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_GunSafety_allowed +// +// description : Read/Write allowed for GunSafety attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_GunSafety_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_FilAbi_allowed +// +// description : Read/Write allowed for FilAbi attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_FilAbi_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_FilCurr_allowed +// +// description : Read/Write allowed for FilCurr attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_FilCurr_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_FilReady_allowed +// +// description : Read/Write allowed for FilReady attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_FilReady_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_GunHv_allowed +// +// description : Read/Write allowed for GunHv attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_GunHv_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AbiTrigGun_allowed +// +// description : Read/Write allowed for AbiTrigGun attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AbiTrigGun_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmGunSafety_allowed +// +// description : Read/Write allowed for AlmGunSafety attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmGunSafety_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmFilAbi_allowed +// +// description : Read/Write allowed for AlmFilAbi attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmFilAbi_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmFilCurr_allowed +// +// description : Read/Write allowed for AlmFilCurr attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmFilCurr_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmFilReady_allowed +// +// description : Read/Write allowed for AlmFilReady attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmFilReady_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmGunHV_allowed +// +// description : Read/Write allowed for AlmGunHV attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmGunHV_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_AlmAbiTrigGun_allowed +// +// description : Read/Write allowed for AlmAbiTrigGun attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_AlmAbiTrigGun_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_FilTimer_allowed +// +// description : Read/Write allowed for FilTimer attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_FilTimer_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_RealFilTimer_allowed +// +// description : Read/Write allowed for RealFilTimer attribute. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_RealFilTimer_allowed(Tango::AttReqType type) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} + +//================================================= +// Commands Allowed Methods +//================================================= + +//+---------------------------------------------------------------------------- +// +// method : IntlkGun::is_Acknowledge_all_allowed +// +// description : Execution allowed for Acknowledge_all command. +// +//----------------------------------------------------------------------------- +bool IntlkGun::is_Acknowledge_all_allowed(const CORBA::Any &any) +{ + // End of Generated Code + + // Re-Start of Generated Code + return true; +} + +} // namespace IntlkGun_ns diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..739ddd1c31f8cce348c144450b45c7a76587ad94 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,70 @@ +//+============================================================================= +// +// file : main.cpp +// +// description : C++ source for a TANGO device server main. +// The main rule is to initialise (and create) the Tango +// system and to create the DServerClass singleton. +// The main should be the same for every Tango device server. +// +// project : TANGO Device Server +// +// $Author: sara $ +// +// $Revision: 1.1.1.1 $ $ +// +// $Log: main.cpp,v $ +// Revision 1.1.1.1 2007-08-31 16:24:36 sara +// server for gun interlock +// +// +// copyleft : European Synchrotron Radiation Facility +// BP 220, Grenoble 38043 +// FRANCE +// +//-============================================================================= +// +// This file is generated by POGO +// (Program Obviously used to Generate tango Object) +// +// (c) - Software Engineering Group - ESRF +//============================================================================= + +#include <tango.h> + + +int main(int argc,char *argv[]) +{ + + Tango::Util *tg; + try + { + // Initialise the device server + //---------------------------------------- + tg = Tango::Util::init(argc,argv); + + // Create the device server singleton + // which will create everything + //---------------------------------------- + tg->server_init(false); + + // Run the endless loop + //---------------------------------------- + cout << "Ready to accept request" << endl; + tg->server_run(); + } + catch (bad_alloc) + { + cout << "Can't allocate memory to store device object !!!" << endl; + cout << "Exiting" << endl; + } + catch (CORBA::Exception &e) + { + Tango::Except::print_exception(e); + + cout << "Received a CORBA_Exception" << endl; + cout << "Exiting" << endl; + } + tg->server_cleanup(); + return(0); +}