Commit 8b524ef1 authored by Jean-Luc Pons's avatar Jean-Luc Pons

Added reset triger counter

parent d620dba8
......@@ -90,12 +90,13 @@ if(thread==NULL) { \
// The following table gives the correspondence
// between command and method names.
//
// Command name | Method name
// Command name | Method name
//================================================================
// State | dev_state
// Status | Inherited (no method)
// SetIncoherencyRef | set_incoherency_ref
// CalibCalculate | calib_calculate
// State | dev_state
// Status | Inherited (no method)
// SetIncoherencyRef | set_incoherency_ref
// CalibCalculate | calib_calculate
// ResetTriggerCounter | reset_trigger_counter
//================================================================
//================================================================
......@@ -519,6 +520,7 @@ void LiberaSparkSRBPM::init_device()
attr_TBT_AntiSmearing_read[0] = false;
ddThread = NULL;
iqThread = NULL;
triggerCounterOffset = 0;
// Default for ADC
attr_ADC_BufSize_read[0] = 100;
......@@ -2062,9 +2064,16 @@ void LiberaSparkSRBPM::read_TBT_TriggerCounter(Tango::Attribute &attr)
DEBUG_STREAM << "LiberaSparkSRBPM::read_TBT_TriggerCounter(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(LiberaSparkSRBPM::read_TBT_TriggerCounter) ENABLED START -----*/
READ_ATTR<uint64_t,Tango::DevULong64>(attr,attr_TBT_TriggerCounter_read,"application.events.t2.count");
Tango::DevULong64 t2Counter;
READ_VALUE<uint64_t,Tango::DevULong64>(&t2Counter,"application.events.t2.count");
if( t2Counter>=triggerCounterOffset )
attr_TBT_TriggerCounter_read[0] = t2Counter - triggerCounterOffset;
else
attr_TBT_TriggerCounter_read[0] = 0;
attr.set_value(attr_TBT_TriggerCounter_read);
/*----- PROTECTED REGION END -----*/ // LiberaSparkSRBPM::read_TBT_TriggerCounter
}
//--------------------------------------------------------
......@@ -3524,6 +3533,22 @@ void LiberaSparkSRBPM::calib_calculate()
/*----- PROTECTED REGION END -----*/ // LiberaSparkSRBPM::calib_calculate
}
//--------------------------------------------------------
/**
* Command ResetTriggerCounter related method
* Description: Reset trigger counter to 0.
*
*/
//--------------------------------------------------------
void LiberaSparkSRBPM::reset_trigger_counter()
{
DEBUG_STREAM << "LiberaSparkSRBPM::ResetTriggerCounter() - " << device_name << endl;
/*----- PROTECTED REGION ID(LiberaSparkSRBPM::reset_trigger_counter) ENABLED START -----*/
READ_VALUE<uint64_t,Tango::DevULong64>(&triggerCounterOffset,"application.events.t2.count");
/*----- PROTECTED REGION END -----*/ // LiberaSparkSRBPM::reset_trigger_counter
}
//--------------------------------------------------------
/**
* Method : LiberaSparkSRBPM::add_dynamic_commands()
* Description : Create the dynamic commands if any
......@@ -3543,6 +3568,29 @@ void LiberaSparkSRBPM::add_dynamic_commands()
// Additional Methods
template<typename lType,typename tType>
void LiberaSparkSRBPM::READ_VALUE(tType *value,string name,double conv) {
try {
lType lValue;
mci::Node node = m_root.GetNode(mci::Tokenize(name));
node.Get(lValue);
if(conv!=0.0) {
*value = (tType) ((double)lValue*conv);
} else {
*value = (tType) lValue;
}
} catch (istd::Exception& ie) {
Tango::Except::throw_exception(
"istd::Exception",
string("MCI error:") + ie.what(),
"LiberaSparkSRBPM::READ_ATTR");
}
}
template<typename lType,typename tType>
void LiberaSparkSRBPM::READ_ATTR(Tango::Attribute &attr,tType *value,string name,double conv) {
......
......@@ -223,6 +223,8 @@ private:
int nbPolynomialSet;
Tango::DevULong64 triggerCounterOffset;
void StartSA();
void StartDD();
void StartIQ();
......@@ -234,6 +236,8 @@ private:
void parsePolynomial(string polyName,vector<string>& in,vector<POLY>& poly);
void split(vector<string> &tokens, const string &text, char sep);
template<typename lType,typename tType>
void READ_VALUE(tType *value,string name,double conv = 0.0);
template<typename lType,typename tType>
void READ_ATTR(Tango::Attribute &attr,tType *value,string name,double conv = 0.0);
template<typename lType,typename tType>
......@@ -1357,6 +1361,13 @@ public:
*/
virtual void calib_calculate();
virtual bool is_CalibCalculate_allowed(const CORBA::Any &any);
/**
* Command ResetTriggerCounter related method
* Description: Reset trigger counter to 0.
*
*/
virtual void reset_trigger_counter();
virtual bool is_ResetTriggerCounter_allowed(const CORBA::Any &any);
//--------------------------------------------------------
......
......@@ -65,6 +65,15 @@
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="ResetTriggerCounter" description="Reset trigger counter to 0." execMethod="reset_trigger_counter" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="DeviceType" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
......
......@@ -188,6 +188,24 @@ CORBA::Any *CalibCalculateClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : ResetTriggerCounterClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *ResetTriggerCounterClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "ResetTriggerCounterClass::execute(): arrived" << endl;
((static_cast<LiberaSparkSRBPM *>(device))->reset_trigger_counter());
return new CORBA::Any();
}
//===================================================================
// Properties management
......@@ -2840,6 +2858,15 @@ void LiberaSparkSRBPMClass::command_factory()
Tango::OPERATOR);
command_list.push_back(pCalibCalculateCmd);
// Command ResetTriggerCounter
ResetTriggerCounterClass *pResetTriggerCounterCmd =
new ResetTriggerCounterClass("ResetTriggerCounter",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(pResetTriggerCounterCmd);
/*----- PROTECTED REGION ID(LiberaSparkSRBPMClass::command_factory_after) ENABLED START -----*/
// Add your own code
......
......@@ -1430,6 +1430,29 @@ public:
{return (static_cast<LiberaSparkSRBPM *>(dev))->is_CalibCalculate_allowed(any);}
};
// Command ResetTriggerCounter class definition
class ResetTriggerCounterClass : public Tango::Command
{
public:
ResetTriggerCounterClass(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) {};
ResetTriggerCounterClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~ResetTriggerCounterClass() {};
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<LiberaSparkSRBPM *>(dev))->is_ResetTriggerCounter_allowed(any);}
};
/**
* The LiberaSparkSRBPMClass singleton definition
......
......@@ -1763,6 +1763,21 @@ bool LiberaSparkSRBPM::is_CalibCalculate_allowed(TANGO_UNUSED(const CORBA::Any &
return true;
}
//--------------------------------------------------------
/**
* Method : LiberaSparkSRBPM::is_ResetTriggerCounter_allowed()
* Description : Execution allowed for ResetTriggerCounter attribute
*/
//--------------------------------------------------------
bool LiberaSparkSRBPM::is_ResetTriggerCounter_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for ResetTriggerCounter command.
/*----- PROTECTED REGION ID(LiberaSparkSRBPM::ResetTriggerCounterStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // LiberaSparkSRBPM::ResetTriggerCounterStateAllowed
return true;
}
/*----- PROTECTED REGION ID(LiberaSparkSRBPM::LiberaSparkSRBPMStateAllowed.AdditionalMethods) ENABLED START -----*/
......
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