Commit 50f4bb33 authored by Giulio Gaio's avatar Giulio Gaio
Browse files

Fixed bug in get indexes, added bunchnumber delay

parent 3e9be282
......@@ -129,6 +129,7 @@ static const char *RcsId = "$Id: VX1751.cpp,v 1.5 2019-02-20 13:45:20 giulio Exp
// Area6 | Tango::DevDouble Scalar
// Area7 | Tango::DevDouble Scalar
// EnableRegisterCaching | Tango::DevBoolean Scalar
// BunchNumberDelayUs | Tango::DevLong Scalar
// Channel0 | Tango::DevShort Spectrum ( max = 1048576)
// Channel1 | Tango::DevShort Spectrum ( max = 1048576)
// Channel2 | Tango::DevShort Spectrum ( max = 1048576)
......@@ -269,6 +270,7 @@ void VX1751::delete_device()
delete[] attr_Area6_read;
delete[] attr_Area7_read;
delete[] attr_EnableRegisterCaching_read;
delete[] attr_BunchNumberDelayUs_read;
delete[] attr_Channel0_read;
delete[] attr_Channel1_read;
delete[] attr_Channel2_read;
......@@ -344,6 +346,7 @@ void VX1751::init_device()
attr_Area6_read = new Tango::DevDouble[1];
attr_Area7_read = new Tango::DevDouble[1];
attr_EnableRegisterCaching_read = new Tango::DevBoolean[1];
attr_BunchNumberDelayUs_read = new Tango::DevLong[1];
attr_Channel0_read = new Tango::DevShort[1048576];
attr_Channel1_read = new Tango::DevShort[1048576];
attr_Channel2_read = new Tango::DevShort[1048576];
......@@ -377,6 +380,7 @@ void VX1751::init_device()
attr_ChannelPointChan_write = 0;
attr_ChannelPointWidth_write = 1;
attr_ChannelPointBackSub_write = false;
*attr_BunchNumberDelayUs_read = 0;
attr_OffsetChan0_write = 32768;
attr_OffsetChan1_write = 32768;
......@@ -2313,6 +2317,44 @@ void VX1751::write_EnableRegisterCaching(Tango::WAttribute &attr)
/*----- PROTECTED REGION END -----*/ // VX1751::write_EnableRegisterCaching
}
//--------------------------------------------------------
/**
* Read attribute BunchNumberDelayUs related method
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
//--------------------------------------------------------
void VX1751::read_BunchNumberDelayUs(Tango::Attribute &attr)
{
DEBUG_STREAM << "VX1751::read_BunchNumberDelayUs(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(VX1751::read_BunchNumberDelayUs) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_BunchNumberDelayUs_read);
/*----- PROTECTED REGION END -----*/ // VX1751::read_BunchNumberDelayUs
}
//--------------------------------------------------------
/**
* Write attribute BunchNumberDelayUs related method
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
//--------------------------------------------------------
void VX1751::write_BunchNumberDelayUs(Tango::WAttribute &attr)
{
DEBUG_STREAM << "VX1751::write_BunchNumberDelayUs(Tango::WAttribute &attr) entering... " << endl;
// Retrieve write value
Tango::DevLong w_val;
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(VX1751::write_BunchNumberDelayUs) ENABLED START -----*/
*attr_BunchNumberDelayUs_read = w_val;
/*----- PROTECTED REGION END -----*/ // VX1751::write_BunchNumberDelayUs
}
//--------------------------------------------------------
/**
* Read attribute Channel0 related method
* Description:
......@@ -4649,7 +4691,13 @@ void VX1751::get_indexes(int32_t chan, int32_t nargin, int32_t *param_in, int32_
}
*samples = (param_in[2]-param_in[1])*vx1751_data[chan].data_size;
//printf("in 0=%d 1=%d 2=%d\n",param_in[0],param_in[1],param_in[2]);
if ((param_in[2]-param_in[1]) != ((param_out[3]-param_out[2]) + (param_out[1]-param_out[0]))) {
Tango::Except::throw_exception(
(const char *)"Failed to extract data",
(const char *)"Bunchnumber not synchronized",
(const char *) "VX1751::get_indexes()", Tango::ERR);
}
}
else {
Tango::Except::throw_exception(
......
......@@ -318,6 +318,7 @@ public:
Tango::DevDouble *attr_Area6_read;
Tango::DevDouble *attr_Area7_read;
Tango::DevBoolean *attr_EnableRegisterCaching_read;
Tango::DevLong *attr_BunchNumberDelayUs_read;
Tango::DevShort *attr_Channel0_read;
Tango::DevShort *attr_Channel1_read;
Tango::DevShort *attr_Channel2_read;
......@@ -736,6 +737,16 @@ public:
virtual void read_EnableRegisterCaching(Tango::Attribute &attr);
virtual void write_EnableRegisterCaching(Tango::WAttribute &attr);
virtual bool is_EnableRegisterCaching_allowed(Tango::AttReqType type);
/**
* Attribute BunchNumberDelayUs related methods
* Description:
*
* Data type: Tango::DevLong
* Attr type: Scalar
*/
virtual void read_BunchNumberDelayUs(Tango::Attribute &attr);
virtual void write_BunchNumberDelayUs(Tango::WAttribute &attr);
virtual bool is_BunchNumberDelayUs_allowed(Tango::AttReqType type);
/**
* Attribute Channel0 related methods
* Description:
......
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="VX1751" pogoRevision="9.4">
<description description="CAEN VX1751 Digitizer interfaced through CONET 2" title="CAEN VX1751 Digitizer" sourcePath="/home/giulio/fermi/servers/vx1751/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<classes name="VX1751" pogoRevision="9.6">
<description description="CAEN VX1751 Digitizer interfaced through CONET 2" title="CAEN VX1751 Digitizer" sourcePath="/home/giulio.gaio/src/gitlab/cs/ds/vx1751/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at elettra.trieste.it - giulio.gaio" author="giulio.gaio" emailDomain="elettra.trieste.it" classFamily="Acquisition" siteSpecific="" platform="Unix Like" bus="PCI Express" manufacturer="CAEN" reference="VX175 Digitizer / Conet 2"/>
</description>
......@@ -662,6 +662,14 @@
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="Enable read register caching to avoid collisions with the datastream that comes out of the boards and make the driver or the vme board crash." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="BunchNumberDelayUs" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:IntType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="us." standardUnit="" displayUnit="us." format="%d" maxValue="999999" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="Channel0" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="1048576" maxY="" allocReadMember="true">
<dataType xsi:type="pogoDsl:ShortType"/>
<changeEvent fire="false" libCheckCriteria="true"/>
......@@ -831,6 +839,6 @@
<states name="OFF" description="">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.2.5a/share/pogo/preferences"/>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.3.4/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
......@@ -1992,6 +1992,31 @@ void VX1751Class::attribute_factory(vector<Tango::Attr *> &att_list)
enableregistercaching->set_memorized_init(true);
att_list.push_back(enableregistercaching);
// Attribute : BunchNumberDelayUs
BunchNumberDelayUsAttrib *bunchnumberdelayus = new BunchNumberDelayUsAttrib();
Tango::UserDefaultAttrProp bunchnumberdelayus_prop;
// description not set for BunchNumberDelayUs
// label not set for BunchNumberDelayUs
bunchnumberdelayus_prop.set_unit("us.");
// standard_unit not set for BunchNumberDelayUs
bunchnumberdelayus_prop.set_display_unit("us.");
bunchnumberdelayus_prop.set_format("%d");
bunchnumberdelayus_prop.set_max_value("999999");
bunchnumberdelayus_prop.set_min_value("0");
// max_alarm not set for BunchNumberDelayUs
// min_alarm not set for BunchNumberDelayUs
// max_warning not set for BunchNumberDelayUs
// min_warning not set for BunchNumberDelayUs
// delta_t not set for BunchNumberDelayUs
// delta_val not set for BunchNumberDelayUs
bunchnumberdelayus->set_default_properties(bunchnumberdelayus_prop);
// Not Polled
bunchnumberdelayus->set_disp_level(Tango::OPERATOR);
bunchnumberdelayus->set_memorized();
bunchnumberdelayus->set_memorized_init(true);
att_list.push_back(bunchnumberdelayus);
// Attribute : Channel0
Channel0Attrib *channel0 = new Channel0Attrib();
Tango::UserDefaultAttrProp channel0_prop;
......@@ -2807,7 +2832,7 @@ void VX1751Class::erase_dynamic_attributes(const Tango::DevVarStringArray *devli
//--------------------------------------------------------
/**
* Method : VX1751Class::get_attr_by_name()
* Method : VX1751Class::get_attr_object_by_name()
* Description : returns Tango::Attr * object found by name
*/
//--------------------------------------------------------
......
......@@ -547,6 +547,21 @@ public:
{return (static_cast<VX1751 *>(dev))->is_EnableRegisterCaching_allowed(ty);}
};
// Attribute BunchNumberDelayUs class definition
class BunchNumberDelayUsAttrib: public Tango::Attr
{
public:
BunchNumberDelayUsAttrib():Attr("BunchNumberDelayUs",
Tango::DEV_LONG, Tango::READ_WRITE) {};
~BunchNumberDelayUsAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<VX1751 *>(dev))->read_BunchNumberDelayUs(att);}
virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att)
{(static_cast<VX1751 *>(dev))->write_BunchNumberDelayUs(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<VX1751 *>(dev))->is_BunchNumberDelayUs_allowed(ty);}
};
// Attribute Channel0 class definition
class Channel0Attrib: public Tango::SpectrumAttr
{
......
......@@ -695,6 +695,26 @@ bool VX1751::is_EnableRegisterCaching_allowed(TANGO_UNUSED(Tango::AttReqType typ
return true;
}
//--------------------------------------------------------
/**
* Method : VX1751::is_BunchNumberDelayUs_allowed()
* Description : Execution allowed for BunchNumberDelayUs attribute
*/
//--------------------------------------------------------
bool VX1751::is_BunchNumberDelayUs_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for BunchNumberDelayUs attribute in Write access.
/*----- PROTECTED REGION ID(VX1751::BunchNumberDelayUsStateAllowed_WRITE) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // VX1751::BunchNumberDelayUsStateAllowed_WRITE
// Not any excluded states for BunchNumberDelayUs attribute in read access.
/*----- PROTECTED REGION ID(VX1751::BunchNumberDelayUsStateAllowed_READ) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // VX1751::BunchNumberDelayUsStateAllowed_READ
return true;
}
//--------------------------------------------------------
/**
* Method : VX1751::is_Channel0_allowed()
......
......@@ -71,8 +71,12 @@ void vx1751thread::run(void *)
myvx1751->man.addr = myvx1751->vmeAddress;
try {
#ifdef VX1751_RNM
if (myvx1751->rnmEnabled)
if (myvx1751->rnmEnabled) {
if (*myvx1751->attr_BunchNumberDelayUs_read > 0) {
usleep(*myvx1751->attr_BunchNumberDelayUs_read);
}
rnm_bunch_number_get_value(0, 1, &myvx1751->bunchnumber, &check_flag);
}
#endif
if (!myvx1751->rnmEnabled)
myvx1751->bunchnumber = myvx1751->eventcounter;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment